diff --git a/build.properties b/build.properties index b5f0d40..c764f96 100644 --- a/build.properties +++ b/build.properties @@ -1,8 +1,8 @@ -gendustry.version=1.5.0 +gendustry.version=1.5.1 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 @@ -13,7 +13,7 @@ ccc.version=1.0.4.35 buildcraft.version=7.0.7 ic2.version=2.2.719-experimental -forestry.version=3.7.0.614-unstable +forestry.version=3.7.0.619-unstable waila.version=1.5.10 cofhlib.cf=2236/777 diff --git a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala index 9cf68a9..0500bea 100644 --- a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala +++ b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala @@ -110,26 +110,22 @@ 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 - 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._