mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-19 11:59:32 +00:00
Merged changes from main branch
Build against forestry 3.6.1, bump version Fixed apiary chunk update spam due to errorstate changes (#107)
This commit is contained in:
commit
3daa3ca9b4
3 files changed
+34
-22
No files matched your search
+3
-3
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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._
|
||||
|
||||
Reference in new issue
Block a user