mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-14 01:04:12 +00:00
#19 use a tick count like Railcraft
This commit is contained in:
1 parent
a679d46c57
commit
2fce803456
3 files changed
+6
-13
No files matched your search
@@ -62,14 +62,11 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
updateClientSide();
|
||||
} else {
|
||||
if (!isInited) {
|
||||
initialize();
|
||||
isInited = true;
|
||||
}
|
||||
|
||||
// Periodic validation if needed
|
||||
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
|
||||
validateStructure();
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
protected final AdjacentTileCache tileCache = new AdjacentTileCache(this);
|
||||
protected boolean isInited = false;
|
||||
private IInventoryAdapter inventory = FakeInventoryAdapter.instance();
|
||||
private final int tickUpdateOffset = rand.nextInt();
|
||||
private int tickCount = rand.nextInt(128);
|
||||
|
||||
public AdjacentTileCache getTileCache() {
|
||||
return tileCache;
|
||||
@@ -114,6 +114,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
// / UPDATING
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
tickCount++;
|
||||
if (!isInited) {
|
||||
initialize();
|
||||
isInited = true;
|
||||
@@ -121,7 +122,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
}
|
||||
|
||||
public final boolean updateOnInterval(int tickInterval) {
|
||||
return (worldObj.getTotalWorldTime() + tickUpdateOffset) % tickInterval == 0;
|
||||
return tickCount % tickInterval == 0;
|
||||
}
|
||||
|
||||
public abstract void initialize();
|
||||
|
||||
@@ -97,16 +97,11 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
updateClientSide();
|
||||
} else {
|
||||
|
||||
if (!isInited) {
|
||||
initialize();
|
||||
isInited = true;
|
||||
}
|
||||
|
||||
// Periodic validation if needed
|
||||
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
|
||||
validateStructure();
|
||||
|
||||
Reference in new issue
Block a user