Collector and Pool binding coordinates are cached rather than loaded directly from NBT.

This commit is contained in:
Vasco Lavos committed 2014-03-24 15:20:52 +00:00
1 parent 3ade0024de
commit 0bddc4b573
2 files changed
+29 -12

No files matched your search

@@ -42,6 +42,8 @@ public class SubTileFunctional extends SubTileEntity {
TileEntity linkedPool = null;
public int knownMana = -1;
ChunkCoordinates cachedPoolCoordinates = null;
@Override
public boolean canUpdate() {
return true;
@@ -74,8 +76,18 @@ public class SubTileFunctional extends SubTileEntity {
final int range = 6;
boolean needsNew = false;
if(linkedPool == null)
if(linkedPool == null) {
needsNew = true;
if(cachedPoolCoordinates != null) {
TileEntity tileAt = supertile.worldObj.getBlockTileEntity(cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ);
if(tileAt != null && tileAt instanceof IManaPool) {
linkedPool = tileAt;
needsNew = false;
}
cachedPoolCoordinates = null;
}
}
if(!needsNew) {
TileEntity tileAt = supertile.worldObj.getBlockTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord);
@@ -124,11 +136,7 @@ public class SubTileFunctional extends SubTileEntity {
int y = cmp.getInteger(TAG_POOL_Y);
int z = cmp.getInteger(TAG_POOL_Z);
if(supertile.worldObj != null) {
TileEntity tileAt = supertile.worldObj.getBlockTileEntity(x, y, z);
if(tileAt != null && tileAt instanceof IManaPool)
linkedPool = tileAt;
}
cachedPoolCoordinates = new ChunkCoordinates(x, y, z);
}
@Override
@@ -24,6 +24,7 @@ import net.minecraft.util.StatCollector;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.internal.IManaNetwork;
import vazkii.botania.api.mana.IManaCollector;
import vazkii.botania.api.mana.IManaPool;
import cpw.mods.fml.common.network.PacketDispatcher;
/**
@@ -43,6 +44,8 @@ public class SubTileGenerating extends SubTileEntity {
protected TileEntity linkedCollector = null;
public int knownMana = -1;
ChunkCoordinates cachedCollectorCoordinates = null;
@Override
public boolean canUpdate() {
return true;
@@ -76,9 +79,19 @@ public class SubTileGenerating extends SubTileEntity {
final int range = 6;
boolean needsNew = false;
if(linkedCollector == null)
if(linkedCollector == null) {
needsNew = true;
if(cachedCollectorCoordinates != null) {
TileEntity tileAt = supertile.worldObj.getBlockTileEntity(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ);
if(tileAt != null && tileAt instanceof IManaCollector) {
linkedCollector = tileAt;
needsNew = false;
}
cachedCollectorCoordinates = null;
}
}
if(!needsNew) {
TileEntity tileAt = supertile.worldObj.getBlockTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord);
if(!(tileAt instanceof IManaCollector)) {
@@ -156,11 +169,7 @@ public class SubTileGenerating extends SubTileEntity {
int y = cmp.getInteger(TAG_COLLECTOR_Y);
int z = cmp.getInteger(TAG_COLLECTOR_Z);
if(supertile.worldObj != null) {
TileEntity tileAt = supertile.worldObj.getBlockTileEntity(x, y, z);
if(tileAt != null && tileAt instanceof IManaCollector)
linkedCollector = tileAt;
}
cachedCollectorCoordinates = new ChunkCoordinates(x, y, z);
}
@Override