From fd92e83b47423eb9dc662b300981d5e4abf82c13 Mon Sep 17 00:00:00 2001 From: bdew Date: Sat, 27 Jun 2015 19:58:46 +0300 Subject: [PATCH 1/4] update bdlib --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 4a9791a..b58dedf 100644 --- a/build.properties +++ b/build.properties @@ -2,7 +2,7 @@ gendustry.version=1.5.0 gendustry.api.version=2.1.0 curseforge.id=70492 -bdlib.version=1.9.0.93 +bdlib.version=1.9.0.94 minecraft.version=1.7.10 forge.version=10.13.4.1448-1.7.10 From 55706e90e2ecdc680259a78e5482d20813f508ec Mon Sep 17 00:00:00 2001 From: bdew Date: Sun, 28 Jun 2015 10:02:37 +0300 Subject: [PATCH 2/4] Fixed apiary chunk update spam due to errorstate changes (#107) --- .../machines/apiary/TileApiary.scala | 24 +++++++++---------- .../gendustry/misc/DataSlotErrorStates.scala | 22 ++++++++++++++--- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala index 9cf68a9..b7a6e39 100644 --- a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala +++ b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala @@ -118,18 +118,18 @@ with IIndustrialApiary { movePrincess = false - val canWork = logic.canWork() - - val powered = getWorldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) - setErrorCondition((rsmode :== RSMode.RS_OFF) && powered, ForestryErrorStates.disabledRedstone) - setErrorCondition((rsmode :== RSMode.RS_ON) && !powered, ForestryErrorStates.noRedstone) - setErrorCondition(rsmode :== RSMode.NEVER, GendustryErrorStates.Disabled) - setErrorCondition(power.stored < cfg.baseMjPerTick * mods.energy, ForestryErrorStates.noPower) - - if (errorConditions.isOk && canWork) { - logic.doWork() - if (errorConditions.isOk && (logic.getQueen != null || logic.getBreedingTime > 0)) { - power.extract(cfg.baseMjPerTick * mods.energy, false) + errorConditions.withSuspendedUpdates { + val canWork = logic.canWork + val powered = getWorldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) + setErrorCondition((rsmode :== RSMode.RS_OFF) && powered, ForestryErrorStates.disabledRedstone) + setErrorCondition((rsmode :== RSMode.RS_ON) && !powered, ForestryErrorStates.noRedstone) + setErrorCondition(rsmode :== RSMode.NEVER, GendustryErrorStates.Disabled) + setErrorCondition(power.stored < cfg.baseMjPerTick * mods.energy, ForestryErrorStates.noPower) + if (errorConditions.isOk && canWork) { + logic.doWork() + if (errorConditions.isOk && (logic.getQueen != null || logic.getBreedingTime > 0)) { + power.extract(cfg.baseMjPerTick * mods.energy, false) + } } } diff --git a/src/net/bdew/gendustry/misc/DataSlotErrorStates.scala b/src/net/bdew/gendustry/misc/DataSlotErrorStates.scala index 152d923..fec632c 100644 --- a/src/net/bdew/gendustry/misc/DataSlotErrorStates.scala +++ b/src/net/bdew/gendustry/misc/DataSlotErrorStates.scala @@ -13,22 +13,29 @@ import forestry.api.core.{ErrorStateRegistry, IErrorState} import net.bdew.lib.data.base.{DataSlotContainer, DataSlotVal, UpdateKind} import net.minecraft.nbt.NBTTagCompound +import scala.util.DynamicVariable + case class DataSlotErrorStates(name: String, parent: DataSlotContainer) extends DataSlotVal[Set[IErrorState]] { override var value: Set[IErrorState] = Set.empty + val suspendUpdates = new DynamicVariable(false) + def set(v: IErrorState): Unit = { value += v - parent.dataSlotChanged(this) + if (!suspendUpdates.value) + parent.dataSlotChanged(this) } def clear(v: IErrorState): Unit = { value -= v - parent.dataSlotChanged(this) + if (!suspendUpdates.value) + parent.dataSlotChanged(this) } def clearAll(): Unit = { value = Set.empty - parent.dataSlotChanged(this) + if (!suspendUpdates.value) + parent.dataSlotChanged(this) } def toggle(v: IErrorState, on: Boolean): Unit = { @@ -38,6 +45,15 @@ case class DataSlotErrorStates(name: String, parent: DataSlotContainer) extends clear(v) } + def withSuspendedUpdates(f: => Unit) = { + val oldValue = value + suspendUpdates.withValue(true) { + f + } + if (value != oldValue) + parent.dataSlotChanged(this) + } + def isOk = value.isEmpty import net.bdew.lib.nbt._ From 239912b4aa2a2d2d7a833d6c86d2f3ee239b2f7b Mon Sep 17 00:00:00 2001 From: bdew Date: Sun, 28 Jun 2015 10:06:02 +0300 Subject: [PATCH 3/4] Build against forestry 3.6.1, bump version --- build.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.properties b/build.properties index b58dedf..724f012 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -gendustry.version=1.5.0 +gendustry.version=1.5.1 gendustry.api.version=2.1.0 curseforge.id=70492 @@ -13,7 +13,7 @@ ccc.version=1.0.4.35 buildcraft.version=7.0.7 ic2.version=2.2.719-experimental -forestry.version=3.6.0.17 +forestry.version=3.6.1.18 waila.version=1.5.10 cofhlib.cf=2236/777 From 78384e820ef9507c1cfa0d0ba9f7b4db31defd2b Mon Sep 17 00:00:00 2001 From: bdew Date: Sun, 28 Jun 2015 12:04:11 +0300 Subject: [PATCH 4/4] Removed useless stuff --- src/net/bdew/gendustry/machines/apiary/TileApiary.scala | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala index b7a6e39..0500bea 100644 --- a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala +++ b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala @@ -110,10 +110,6 @@ with IIndustrialApiary { } ) - // Internal errors that don't involve beekeeping logic - // If any of those errors are present - logic.update will be skipped - val ourErrorStates = Set(ForestryErrorStates.disabledRedstone, ForestryErrorStates.noRedstone, GendustryErrorStates.Disabled, ForestryErrorStates.noPower) - serverTick.listen(() => { movePrincess = false