Try to handle better the flowers' cache. Another stab at fixing the "flowers bind poorly after chunk reload" issue.

This commit is contained in:
Lizbeth Rika committed 2015-06-24 17:18:33 +01:00
1 parent 1fb93ac7ce
commit d6aa993649
3 files changed
+43 -21

No files matched your search

@@ -1,4 +1,4 @@
@API(owner = "Botania", apiVersion = "52", provides = "BotaniaAPI")
@API(owner = "Botania", apiVersion = "53", provides = "BotaniaAPI")
package vazkii.botania.api;
import cpw.mods.fml.common.API;
@@ -106,11 +106,16 @@ public class SubTileFunctional extends SubTileEntity {
}
if(!needsNew && linkedPool != null) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord);
if(!(tileAt instanceof IManaPool) || tileAt.isInvalid()) {
if(supertile.getWorldObj().blockExists(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord) && !linkedPool.isInvalid()) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord);
if(!(tileAt instanceof IManaPool) || tileAt.isInvalid()) {
linkedPool = null;
needsNew = true;
} else linkedPool = tileAt;
} else {
cachedPoolCoordinates = new ChunkCoordinates(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord);
linkedPool = null;
needsNew = true;
} else linkedPool = tileAt;
}
}
if(needsNew) {
@@ -162,13 +167,19 @@ public class SubTileFunctional extends SubTileEntity {
public void writeToPacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_MANA, mana);
int x = linkedPool == null ? 0 : linkedPool.xCoord;
int y = linkedPool == null ? -1 : linkedPool.yCoord;
int z = linkedPool == null ? 0 : linkedPool.zCoord;
if(cachedPoolCoordinates != null) {
cmp.setInteger(TAG_POOL_X, cachedPoolCoordinates.posX);
cmp.setInteger(TAG_POOL_Y, cachedPoolCoordinates.posY);
cmp.setInteger(TAG_POOL_Z, cachedPoolCoordinates.posZ);
} else {
int x = linkedPool == null ? 0 : linkedPool.xCoord;
int y = linkedPool == null ? -1 : linkedPool.yCoord;
int z = linkedPool == null ? 0 : linkedPool.zCoord;
cmp.setInteger(TAG_POOL_X, x);
cmp.setInteger(TAG_POOL_Y, y);
cmp.setInteger(TAG_POOL_Z, z);
cmp.setInteger(TAG_POOL_X, x);
cmp.setInteger(TAG_POOL_Y, y);
cmp.setInteger(TAG_POOL_Z, z);
}
}
@Override
@@ -99,11 +99,16 @@ public class SubTileGenerating extends SubTileEntity {
}
if(!needsNew && linkedCollector != null) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord);
if(!(tileAt instanceof IManaCollector) || tileAt.isInvalid()) {
if(supertile.getWorldObj().blockExists(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord) && !linkedCollector.isInvalid()) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord);
if(!(tileAt instanceof IManaCollector) || tileAt.isInvalid()) {
linkedCollector = null;
needsNew = true;
} else linkedCollector = tileAt;
} else {
cachedCollectorCoordinates = new ChunkCoordinates(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord);
linkedCollector = null;
needsNew = true;
} else linkedCollector = tileAt;
}
}
if(needsNew) {
@@ -190,13 +195,19 @@ public class SubTileGenerating extends SubTileEntity {
cmp.setInteger(TAG_MANA, mana);
cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted);
int x = linkedCollector == null ? 0 : linkedCollector.xCoord;
int y = linkedCollector == null ? -1 : linkedCollector.yCoord;
int z = linkedCollector == null ? 0 : linkedCollector.zCoord;
if(cachedCollectorCoordinates != null) {
cmp.setInteger(TAG_COLLECTOR_X, cachedCollectorCoordinates.posX);
cmp.setInteger(TAG_COLLECTOR_Y, cachedCollectorCoordinates.posY);
cmp.setInteger(TAG_COLLECTOR_Z, cachedCollectorCoordinates.posZ);
} else {
int x = linkedCollector == null ? 0 : linkedCollector.xCoord;
int y = linkedCollector == null ? -1 : linkedCollector.yCoord;
int z = linkedCollector == null ? 0 : linkedCollector.zCoord;
cmp.setInteger(TAG_COLLECTOR_X, x);
cmp.setInteger(TAG_COLLECTOR_Y, y);
cmp.setInteger(TAG_COLLECTOR_Z, z);
cmp.setInteger(TAG_COLLECTOR_X, x);
cmp.setInteger(TAG_COLLECTOR_Y, y);
cmp.setInteger(TAG_COLLECTOR_Z, z);
}
}
@Override