#606 Fixed performance issue when EIO machines where full.

This commit is contained in:
CrazyPants committed 2014-04-29 13:31:26 +08:00
1 parent 7b02ea766b
commit 7c8382c067
3 files changed
+28 -3

No files matched your search

@@ -38,6 +38,7 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
protected int ticksSinceSync = -1;
protected boolean forceClientUpdate = true;
protected boolean lastActive;
protected int ticksSinceActiveChanged = 0;
protected float lastSyncPowerStored = -1;
// Power
@@ -289,15 +290,22 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
if(worldObj.isRemote) {
// check if the block on the client needs to update its texture
if(isActive() != lastActive) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
ticksSinceActiveChanged++;
if(ticksSinceActiveChanged > 20 || isActive()) {
ticksSinceActiveChanged = 0;
lastActive = isActive();
forceClientUpdate = false;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
lastActive = isActive();
if(forceClientUpdate) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
forceClientUpdate = false;
}
return;
} // else is server, do all logic only on the server
updateStoredEnergyFromPowerHandler();
@@ -17,6 +17,9 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
protected final Random random = new Random();
protected int ticksSinceCheckedRecipe = 0;
protected boolean startFailed = false;
public AbstractPoweredTaskEntity(SlotDefinition slotDefinition) {
super(slotDefinition);
}
@@ -86,12 +89,25 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
return requiresClientSync;
}
if(startFailed) {
ticksSinceCheckedRecipe++;
if(ticksSinceCheckedRecipe < 20) {
return false;
}
}
ticksSinceCheckedRecipe = 0;
float chance = random.nextFloat();
// Then see if we need to start a new one
IMachineRecipe nextRecipe = canStartNextTask(chance);
if(nextRecipe != null) {
requiresClientSync |= startNextTask(nextRecipe, chance);
boolean started = startNextTask(nextRecipe, chance);
startFailed = !started;
requiresClientSync |= started;
} else {
startFailed = true;
}
return requiresClientSync;
}