Phased out any usage of World.getTotalWorldTime() in favor of internal tickers. SubTileEntity now has a session and packet safe internal ticker.

This commit is contained in:
Lizbeth Rika committed 2014-12-05 19:20:17 +00:00
1 parent 0a7d5ec220
commit 765e302c7e
23 files changed
+47 -46

No files matched your search

@@ -33,20 +33,36 @@ import cpw.mods.fml.relauncher.SideOnly;
public class SubTileEntity {
protected TileEntity supertile;
public int ticksExisted = 0;
/** The Tag items should use to store which sub tile they are. **/
public static final String TAG_TYPE = "type";
public static final String TAG_TICKS_EXISTED = "ticksExisted";
public void setSupertile(TileEntity tile) {
supertile = tile;
}
public boolean canUpdate() {
return false;
return true;
}
public void onUpdate() { }
public void onUpdate() {
ticksExisted++;
}
public final void writeToPacketNBTInternal(NBTTagCompound cmp) {
cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted);
writeToPacketNBT(cmp);
}
public final void readFromPacketNBTInternal(NBTTagCompound cmp) {
if(cmp.hasKey(TAG_TICKS_EXISTED))
ticksExisted = cmp.getInteger(TAG_TICKS_EXISTED);
readFromPacketNBT(cmp);
}
/**
* Writes some extra data to a network packet. This data is read
* by readFromPacketNBT on the client that receives the packet.
@@ -47,11 +47,6 @@ public class SubTileFunctional extends SubTileEntity {
ChunkCoordinates cachedPoolCoordinates = null;
@Override
public boolean canUpdate() {
return true;
}
/**
* If set to true, redstoneSignal will be updated every tick.
*/
@@ -32,7 +32,6 @@ import vazkii.botania.api.mana.IManaCollector;
public class SubTileGenerating extends SubTileEntity {
private static final String TAG_MANA = "mana";
private static final String TAG_TICKS_EXISTED = "ticksExisted";
private static final String TAG_COLLECTOR_X = "collectorX";
private static final String TAG_COLLECTOR_Y = "collectorY";
@@ -40,18 +39,12 @@ public class SubTileGenerating extends SubTileEntity {
protected int mana;
int ticksExisted = 0;
int sizeLastCheck = -1;
protected TileEntity linkedCollector = null;
public int knownMana = -1;
ChunkCoordinates cachedCollectorCoordinates = null;
@Override
public boolean canUpdate() {
return true;
}
@Override
public void onUpdate() {
super.onUpdate();
@@ -60,7 +53,7 @@ public class SubTileGenerating extends SubTileEntity {
if(canGeneratePassively()) {
int delay = getDelayBetweenPassiveGeneration();
if(delay > 0 && supertile.getWorldObj().getWorldTime() % delay == 0) {
if(delay > 0 && ticksExisted % delay == 0) {
if(shouldSyncPassiveGeneration())
sync();
addMana(getValueForPassiveGeneration());