From f4c401aa67fed4e228f71921e7cc8401cc934962 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 19 Nov 2015 22:13:52 +0100 Subject: [PATCH] Fixed TileEntities Updating less often --- .../java/ellpeck/actuallyadditions/tile/TileEntityBase.java | 6 +++++- .../actuallyadditions/tile/TileEntityCanolaPress.java | 3 +-- .../actuallyadditions/tile/TileEntityCoalGenerator.java | 3 +-- .../actuallyadditions/tile/TileEntityCoffeeMachine.java | 3 +-- .../tile/TileEntityDirectionalBreaker.java | 3 +-- .../ellpeck/actuallyadditions/tile/TileEntityEnergizer.java | 3 +-- .../ellpeck/actuallyadditions/tile/TileEntityEnervator.java | 3 +-- .../ellpeck/actuallyadditions/tile/TileEntityFeeder.java | 3 +-- .../actuallyadditions/tile/TileEntityFermentingBarrel.java | 3 +-- .../actuallyadditions/tile/TileEntityFluidCollector.java | 3 +-- .../actuallyadditions/tile/TileEntityFurnaceDouble.java | 3 +-- .../ellpeck/actuallyadditions/tile/TileEntityGrinder.java | 3 +-- .../ellpeck/actuallyadditions/tile/TileEntityInputter.java | 3 +-- .../actuallyadditions/tile/TileEntityItemRepairer.java | 3 +-- .../actuallyadditions/tile/TileEntityOilGenerator.java | 3 +-- .../actuallyadditions/tile/TileEntityRangedCollector.java | 3 +-- .../actuallyadditions/tile/TileEntitySmileyCloud.java | 3 +-- .../actuallyadditions/tile/TileEntityXPSolidifier.java | 3 +-- 18 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java index 666778624..43e839808 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java @@ -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){ this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + return true; + } + else{ + return false; } } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java index 843230e04..a289e1213 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java @@ -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.lastProcessTime = this.currentProcessTime; this.lastTankAmount = this.tank.getFluidAmount(); - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java index 8e9bc9427..8d4a0a5d1 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java @@ -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.lastCurrentBurnTime = this.currentBurnTime; this.lastBurnTime = this.currentBurnTime; - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java index aa5de18f4..2e99c4595 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java @@ -58,12 +58,11 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements 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.lastEnergy = this.storage.getEnergyStored(); this.lastTank = this.tank.getFluidAmount(); this.lastBrewTime = this.brewTime; - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDirectionalBreaker.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDirectionalBreaker.java index b3324e104..319e36519 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDirectionalBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDirectionalBreaker.java @@ -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.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java index 8ce2d9ffe..a2b5fb7d4 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java @@ -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.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java index 3a475727d..b547cc178 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java @@ -57,9 +57,8 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne 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.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java index 6476ec5ca..ee684c248 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java @@ -74,10 +74,9 @@ public class TileEntityFeeder extends TileEntityInventoryBase{ 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.lastTimer = this.currentTimer; - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java index f604c3ae4..e0ef4492b 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java @@ -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.lastCanola = this.canolaTank.getFluidAmount(); this.lastOil = this.oilTank.getFluidAmount(); - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java index 553cae63c..5fb12b30c 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java @@ -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(); - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java index 924a17255..693ed8aa5 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java @@ -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.lastFirstSmelt = this.firstSmeltTime; this.lastSecondSmelt = this.secondSmeltTime; - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java index 0f91059ae..69a1fad7d 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java @@ -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.lastFirstCrush = this.firstCrushTime; this.lastSecondCrush = this.secondCrushTime; - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java index 6cea4ffa4..565ad4379 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java @@ -99,7 +99,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt } //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.lastPullSide = this.sideToPull; this.lastPullStart = this.slotToPullStart; @@ -108,7 +108,6 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt this.lastPutEnd = this.slotToPutEnd; this.lastPullWhite = this.isPullWhitelist; this.lastPutWhite = this.isPutWhitelist; - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java index e5f4d5848..8397c2fc6 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java @@ -58,9 +58,8 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I this.nextRepairTick = 0; } - if(this.lastEnergy != this.storage.getEnergyStored()){ + if(this.lastEnergy != this.storage.getEnergyStored() && this.trySendUpdate()){ this.lastEnergy = this.storage.getEnergyStored(); - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java index 904ee9667..44b959eab 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java @@ -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.lastTank = this.tank.getFluidAmount(); this.lastBurnTime = this.currentBurnTime; - this.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityRangedCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityRangedCollector.java index d032ca8b1..6162d9d1c 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityRangedCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityRangedCollector.java @@ -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.sendUpdate(); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntitySmileyCloud.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntitySmileyCloud.java index fd8bf285d..c3395aea6 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntitySmileyCloud.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntitySmileyCloud.java @@ -43,9 +43,8 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac public void updateEntity(){ super.updateEntity(); if(!worldObj.isRemote){ - if(!Objects.equals(this.name, this.nameBefore)){ + if(!Objects.equals(this.name, this.nameBefore) && this.trySendUpdate()){ this.nameBefore = this.name; - this.sendUpdate(); this.markDirty(); } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java index 2e67d5a49..4a03cfdc0 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java @@ -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.sendUpdate(); } } }