Fixed TileEntities Updating less often

This commit is contained in:
Ellpeck 2015-11-19 22:13:52 +01:00
parent a6c8ea596c
commit f4c401aa67
18 changed files with 22 additions and 35 deletions

View file

@ -111,9 +111,13 @@ public abstract class TileEntityBase extends TileEntity{
} }
protected void sendUpdate(){ protected boolean trySendUpdate(){
if(this.ticksElapsed % ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0){ if(this.ticksElapsed % ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0){
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
return true;
}
else{
return false;
} }
} }
} }

View file

@ -76,11 +76,10 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
} }
} }
if(this.storage.getEnergyStored() != this.lastEnergyStored || this.tank.getFluidAmount() != this.lastTankAmount | this.currentProcessTime != this.lastProcessTime){ if((this.storage.getEnergyStored() != this.lastEnergyStored || this.tank.getFluidAmount() != this.lastTankAmount | this.currentProcessTime != this.lastProcessTime) && this.trySendUpdate()){
this.lastEnergyStored = this.storage.getEnergyStored(); this.lastEnergyStored = this.storage.getEnergyStored();
this.lastProcessTime = this.currentProcessTime; this.lastProcessTime = this.currentProcessTime;
this.lastTankAmount = this.tank.getFluidAmount(); this.lastTankAmount = this.tank.getFluidAmount();
this.sendUpdate();
} }
} }
} }

View file

@ -80,11 +80,10 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
} }
} }
if(this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime){ if((this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime) && this.trySendUpdate()){
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.lastCurrentBurnTime = this.currentBurnTime; this.lastCurrentBurnTime = this.currentBurnTime;
this.lastBurnTime = this.currentBurnTime; this.lastBurnTime = this.currentBurnTime;
this.sendUpdate();
} }
} }
} }

View file

@ -58,12 +58,11 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
this.brew(); this.brew();
} }
if(this.coffeeCacheAmount != this.lastCoffeeAmount || this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.brewTime != this.lastBrewTime){ if((this.coffeeCacheAmount != this.lastCoffeeAmount || this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.brewTime != this.lastBrewTime) && this.trySendUpdate()){
this.lastCoffeeAmount = coffeeCacheAmount; this.lastCoffeeAmount = coffeeCacheAmount;
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.lastTank = this.tank.getFluidAmount(); this.lastTank = this.tank.getFluidAmount();
this.lastBrewTime = this.brewTime; this.lastBrewTime = this.brewTime;
this.sendUpdate();
} }
} }
} }

View file

@ -77,9 +77,8 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
} }
} }
if(this.storage.getEnergyStored() != this.lastEnergy){ if(this.storage.getEnergyStored() != this.lastEnergy && this.trySendUpdate()){
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.sendUpdate();
} }
} }
} }

View file

@ -47,9 +47,8 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
} }
} }
if(lastEnergy != this.storage.getEnergyStored()){ if(lastEnergy != this.storage.getEnergyStored() && this.trySendUpdate()){
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.sendUpdate();
} }
} }
} }

View file

@ -57,9 +57,8 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage); WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage);
} }
if(lastEnergy != this.storage.getEnergyStored()){ if(lastEnergy != this.storage.getEnergyStored() && this.trySendUpdate()){
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.sendUpdate();
} }
} }
} }

View file

@ -74,10 +74,9 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
this.markDirty(); this.markDirty();
} }
if(this.lastAnimalAmount != this.currentAnimalAmount || this.lastTimer != this.currentTimer){ if((this.lastAnimalAmount != this.currentAnimalAmount || this.lastTimer != this.currentTimer) && this.trySendUpdate()){
this.lastAnimalAmount = this.currentAnimalAmount; this.lastAnimalAmount = this.currentAnimalAmount;
this.lastTimer = this.currentTimer; this.lastTimer = this.currentTimer;
this.sendUpdate();
} }
} }
} }

View file

@ -66,11 +66,10 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
} }
} }
if(this.canolaTank.getFluidAmount() != this.lastCanola || this.oilTank.getFluidAmount() != this.lastOil || this.currentProcessTime != this.lastProcessTime){ if((this.canolaTank.getFluidAmount() != this.lastCanola || this.oilTank.getFluidAmount() != this.lastOil || this.currentProcessTime != this.lastProcessTime) && this.trySendUpdate()){
this.lastProcessTime = this.currentProcessTime; this.lastProcessTime = this.currentProcessTime;
this.lastCanola = this.canolaTank.getFluidAmount(); this.lastCanola = this.canolaTank.getFluidAmount();
this.lastOil = this.oilTank.getFluidAmount(); this.lastOil = this.oilTank.getFluidAmount();
this.sendUpdate();
} }
} }
} }

View file

@ -147,9 +147,8 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
} }
} }
if(lastTankAmount != this.tank.getFluidAmount()){ if(lastTankAmount != this.tank.getFluidAmount() && this.trySendUpdate()){
lastTankAmount = this.tank.getFluidAmount(); lastTankAmount = this.tank.getFluidAmount();
this.sendUpdate();
} }
} }
} }

View file

@ -92,11 +92,10 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
} }
} }
if(lastEnergy != this.storage.getEnergyStored() || this.lastFirstSmelt != this.firstSmeltTime || this.lastSecondSmelt != this.secondSmeltTime){ if((lastEnergy != this.storage.getEnergyStored() || this.lastFirstSmelt != this.firstSmeltTime || this.lastSecondSmelt != this.secondSmeltTime) && this.trySendUpdate()){
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.lastFirstSmelt = this.firstSmeltTime; this.lastFirstSmelt = this.firstSmeltTime;
this.lastSecondSmelt = this.secondSmeltTime; this.lastSecondSmelt = this.secondSmeltTime;
this.sendUpdate();
} }
} }
} }

View file

@ -126,11 +126,10 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
} }
} }
if(lastEnergy != this.storage.getEnergyStored() || this.lastFirstCrush != this.firstCrushTime || this.lastSecondCrush != this.secondCrushTime){ if((lastEnergy != this.storage.getEnergyStored() || this.lastFirstCrush != this.firstCrushTime || this.lastSecondCrush != this.secondCrushTime) && this.trySendUpdate()){
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.lastFirstCrush = this.firstCrushTime; this.lastFirstCrush = this.firstCrushTime;
this.lastSecondCrush = this.secondCrushTime; this.lastSecondCrush = this.secondCrushTime;
this.sendUpdate();
} }
} }
} }

View file

@ -99,7 +99,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
} }
//Update the Client //Update the Client
if(this.sideToPut != this.lastPutSide || this.sideToPull != this.lastPullSide || this.slotToPullStart != this.lastPullStart || this.slotToPullEnd != this.lastPullEnd || this.slotToPutStart != this.lastPutStart || this.slotToPutEnd != this.lastPutEnd || this.isPullWhitelist != lastPullWhite || this.isPutWhitelist != this.lastPutWhite){ if((this.sideToPut != this.lastPutSide || this.sideToPull != this.lastPullSide || this.slotToPullStart != this.lastPullStart || this.slotToPullEnd != this.lastPullEnd || this.slotToPutStart != this.lastPutStart || this.slotToPutEnd != this.lastPutEnd || this.isPullWhitelist != lastPullWhite || this.isPutWhitelist != this.lastPutWhite) && this.trySendUpdate()){
this.lastPutSide = this.sideToPut; this.lastPutSide = this.sideToPut;
this.lastPullSide = this.sideToPull; this.lastPullSide = this.sideToPull;
this.lastPullStart = this.slotToPullStart; this.lastPullStart = this.slotToPullStart;
@ -108,7 +108,6 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
this.lastPutEnd = this.slotToPutEnd; this.lastPutEnd = this.slotToPutEnd;
this.lastPullWhite = this.isPullWhitelist; this.lastPullWhite = this.isPullWhitelist;
this.lastPutWhite = this.isPutWhitelist; this.lastPutWhite = this.isPutWhitelist;
this.sendUpdate();
} }
} }
} }

View file

@ -58,9 +58,8 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
this.nextRepairTick = 0; this.nextRepairTick = 0;
} }
if(this.lastEnergy != this.storage.getEnergyStored()){ if(this.lastEnergy != this.storage.getEnergyStored() && this.trySendUpdate()){
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.sendUpdate();
} }
} }
} }

View file

@ -78,11 +78,10 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
} }
} }
if(this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime){ if((this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime) && this.trySendUpdate()){
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.lastTank = this.tank.getFluidAmount(); this.lastTank = this.tank.getFluidAmount();
this.lastBurnTime = this.currentBurnTime; this.lastBurnTime = this.currentBurnTime;
this.sendUpdate();
} }
} }
} }

View file

@ -57,9 +57,8 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
} }
} }
if(this.isWhitelist != this.lastWhitelist){ if(this.isWhitelist != this.lastWhitelist && this.trySendUpdate()){
this.lastWhitelist = this.isWhitelist; this.lastWhitelist = this.isWhitelist;
this.sendUpdate();
} }
} }
} }

View file

@ -43,9 +43,8 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
if(!worldObj.isRemote){ if(!worldObj.isRemote){
if(!Objects.equals(this.name, this.nameBefore)){ if(!Objects.equals(this.name, this.nameBefore) && this.trySendUpdate()){
this.nameBefore = this.name; this.nameBefore = this.name;
this.sendUpdate();
this.markDirty(); this.markDirty();
} }
} }

View file

@ -47,9 +47,8 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
} }
} }
if(this.lastAmount != this.amount){ if(this.lastAmount != this.amount && this.trySendUpdate()){
this.lastAmount = this.amount; this.lastAmount = this.amount;
this.sendUpdate();
} }
} }
} }