Updated to forestry unstable 4.0

This commit is contained in:
bdew committed 2015-07-25 21:59:46 +03:00
1 parent 138546ac74
commit 6cd613a85c
13 files changed
+152 -123

No files matched your search

+1 -1
View File
@@ -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.635-unstable
forestry.version=4.0.0.644-unstable
waila.version=1.5.10
cofhlib.cf=2236/777
@@ -9,38 +9,46 @@
package net.bdew.gendustry.compat
import java.util
import java.io.{DataInputStream, DataOutputStream}
import java.lang.Iterable
import java.util.Collections
import com.google.common.collect.ImmutableSet
import com.mojang.authlib.GameProfile
import forestry.api.apiculture.{IBee, IBeeGenome, IBeeHousing}
import forestry.api.core.{EnumHumidity, EnumTemperature, ErrorStateRegistry, IErrorState}
import forestry.api.genetics.IIndividual
import forestry.api.apiculture._
import forestry.api.core._
import forestry.api.genetics.{AlleleManager, IIndividual}
import net.bdew.gendustry.api.blocks.IMutatron
import net.minecraft.item.ItemStack
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.ChunkCoordinates
import net.minecraft.world.World
class FakeMutatronBeeHousing(tile: TileEntity with IMutatron) extends IBeeHousing {
override def getWorld: World = tile.getWorldObj
override def getXCoord: Int = tile.xCoord
override def getYCoord: Int = tile.yCoord
override def getZCoord: Int = tile.zCoord
class FakeMutatronBeeHousing(tile: TileEntity with IMutatron) extends IBeeHousing with IBeeModifier with IBeeListener with IBeeHousingInventory with IErrorLogic {
val beeRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees").asInstanceOf[IBeeRoot]
override def getOwnerName: GameProfile = tile.getOwner
override def getWorld: World = tile.getWorldObj
override def getCoordinates: ChunkCoordinates = new ChunkCoordinates(tile.xCoord, tile.yCoord, tile.zCoord)
override def getBlockLightValue: Int = getWorld.getBlockLightValue(tile.xCoord, tile.yCoord, tile.zCoord)
override def canBlockSeeTheSky: Boolean = getWorld.canBlockSeeTheSky(tile.xCoord, tile.yCoord, tile.zCoord)
override def getBeeListeners: Iterable[IBeeListener] = Collections.singletonList(this)
override def getBeeInventory: IBeeHousingInventory = this
override def getBeeModifiers: Iterable[IBeeModifier] = Collections.singletonList(this)
override def getBeekeepingLogic: IBeekeepingLogic = beeRoot.createBeekeepingLogic(this)
override def getErrorLogic: IErrorLogic = this
override def getOwner: GameProfile = tile.getOwner
override def getDrone: ItemStack = tile.getParent1
override def getQueen: ItemStack = tile.getParent2
override def setQueen(itemStack: ItemStack): Unit = throw new UnsupportedOperationException("Not supported in mutatron")
override def setDrone(itemStack: ItemStack): Unit = throw new UnsupportedOperationException("Not supported in mutatron")
override def canBreed: Boolean = true
override def onQueenDeath(iBee: IBee): Unit = {}
override def onQueenDeath(): Unit = {}
override def wearOutEquipment(i: Int): Unit = {}
override def onPostQueenDeath(iBee: IBee): Unit = {}
override def onQueenChange(itemStack: ItemStack): Unit = {}
override def onEggLaid(iBee: IBee): Boolean = false
override def onPollenRetrieved(iBee: IBee, iIndividual: IIndividual, b: Boolean): Boolean = false
override def onPollenRetrieved(iIndividual: IIndividual): Boolean = false
override def addProduct(product: ItemStack, all: Boolean): Boolean = false
override def isSunlightSimulated: Boolean = false
@@ -54,10 +62,13 @@ class FakeMutatronBeeHousing(tile: TileEntity with IMutatron) extends IBeeHousin
override def getFloweringModifier(iBeeGenome: IBeeGenome, v: Float): Float = v
override def getTerritoryModifier(iBeeGenome: IBeeGenome, v: Float): Float = v
override def setErrorCondition(b: Boolean, iErrorState: IErrorState): Boolean = false
override def getErrorStates: util.Set[IErrorState] = new util.HashSet
override def setErrorState(state: IErrorState): Unit = {}
override def getErrorState: IErrorState = ErrorStateRegistry.getErrorState("Forestry:ok")
override def setCondition(condition: Boolean, errorState: IErrorState): Boolean = false
override def hasErrors: Boolean = false
override def writeData(data: DataOutputStream): Unit = {}
override def readData(data: DataInputStream): Unit = {}
override def contains(state: IErrorState): Boolean = false
override def clearErrors(): Unit = {}
override def getErrorStates: ImmutableSet[IErrorState] = ImmutableSet.of()
override def getBiome = tile.getWorldObj.getBiomeGenForCoordsBody(tile.xCoord, tile.zCoord)
override def getHumidity: EnumHumidity = EnumHumidity.getFromValue(getBiome.rainfall)
@@ -10,7 +10,7 @@
package net.bdew.gendustry.compat.triggers
import buildcraft.api.statements.StatementManager
import forestry.api.core.{ErrorStateRegistry, IErrorState}
import forestry.api.core.{ForestryAPI, IErrorState}
import net.bdew.gendustry.Gendustry
import net.bdew.gendustry.api.blocks.IForestryMultiErrorSource
import net.bdew.lib.Misc
@@ -33,6 +33,8 @@ case class ForestryErrorTrigger(state: IErrorState) extends BaseTrigger("forestr
object ForestryErrorTriggers {
val errorStateRegistry = ForestryAPI.errorStateRegistry
val apiaryTriggerStates = List(
"Forestry:ok",
"Forestry:invalidBiome",
@@ -49,7 +51,7 @@ object ForestryErrorTriggers {
"Forestry:noPower",
"Forestry:noRedstone",
"Forestry:disabledRedstone"
) map ErrorStateRegistry.getErrorState
) map errorStateRegistry.getErrorState
val validTriggerStates = apiaryTriggerStates.toSet
val validTriggers = validTriggerStates.map(x => x -> ForestryErrorTrigger(x)).toMap
+11 -12
View File
@@ -11,7 +11,7 @@ package net.bdew.gendustry.custom
import forestry.api.apiculture._
import forestry.api.core.{EnumHumidity, EnumTemperature}
import forestry.api.genetics.{AlleleManager, IAllele, IGenome}
import forestry.api.genetics.{AlleleManager, IAllele}
import net.bdew.lib.Misc
import net.minecraft.block.Block
import net.minecraft.item.ItemStack
@@ -29,25 +29,24 @@ class BeeMutation(parent1: IAlleleBeeSpecies, parent2: IAlleleBeeSpecies, result
// === IBeeMutation ===
def getBlockUnderHousing(h: IBeeHousing) =
if (h.getYCoord > 0)
h.getWorld.getBlock(h.getXCoord, h.getYCoord - 1, h.getZCoord)
def getBlockUnderHousing(h: IBeeHousing) = {
val c = h.getCoordinates
if (c.posY > 0)
h.getWorld.getBlock(c.posX, c.posY - 1, c.posZ)
else null
}
def getBlockMetaUnderHousing(h: IBeeHousing) =
if (h.getYCoord > 0)
h.getWorld.getBlockMetadata(h.getXCoord, h.getYCoord - 1, h.getZCoord)
def getBlockMetaUnderHousing(h: IBeeHousing) = {
val c = h.getCoordinates
if (c.posY > 0)
h.getWorld.getBlockMetadata(c.posX, c.posY - 1, c.posZ)
else -1
}
def testReq[T](req: Option[T], v: T) = req.isEmpty || req.get == v
override def getChance(housing: IBeeHousing, allele0: IAllele, allele1: IAllele, genome0: IGenome, genome1: IGenome) =
getChanceImpl(housing, allele0, allele1, genome0, genome1)
override def getChance(housing: IBeeHousing, allele0: IAlleleBeeSpecies, allele1: IAlleleBeeSpecies, genome0: IBeeGenome, genome1: IBeeGenome) =
getChanceImpl(housing, allele0, allele1, genome0, genome1)
def getChanceImpl(housing: IBeeHousing, allele0: IAllele, allele1: IAllele, genome0: IGenome, genome1: IGenome): Float =
if (!((allele0 == parent1 && allele1 == parent2) || (allele0 == parent2 && allele1 == parent1))) 0
else if (!testReq(reqTemperature, housing.getTemperature)) 0
else if (!testReq(reqHumidity, housing.getHumidity)) 0
@@ -83,11 +83,7 @@ class BeeSpecies(cfg: ConfigSection, ident: String) extends IAlleleBeeSpecies {
val specialty = prepareLootList("Specialty")
specialty.foreach(x => Gendustry.logDebug(" [%.1f%%] %s", x._2, x._1))
// Old product/specialty maps - will be removed at some point. Manual boxing because java maps can't hold primitive values.
override val getProducts = products.map(x => x._1 -> Int.box((x._2 * 100).round)).asJava
override val getSpecialty = specialty.map(x => x._1 -> Int.box((x._2 * 100).round)).asJava
// New maps with floats. Ditto about boxing.
// Manual boxing because java maps can't hold primitive values.
override def getProductChances = products.map(x => x._1 -> Float.box(x._2)).asJava
override def getSpecialtyChances = specialty.map(x => x._1 -> Float.box(x._2)).asJava
@@ -80,7 +80,8 @@ object GeneticsHelper {
case (EnumMutationSetting.DISABLED, _) => false
case (EnumMutationSetting.REQUIREMENTS, beeMutation: IBeeMutation) =>
//Have to use the deprecated version because of not-updated other mods
beeMutation.getChance(beeHousing, fromSpecies, toSpecies, fromIndividual.getGenome, toIndividual.getGenome) > 0
beeMutation.getChance(beeHousing, fromSpecies.asInstanceOf[IAlleleBeeSpecies], toSpecies.asInstanceOf[IAlleleBeeSpecies],
fromIndividual.getGenome.asInstanceOf[IBeeGenome], toIndividual.getGenome.asInstanceOf[IBeeGenome]) > 0
case _ => true
}
}
@@ -26,7 +26,7 @@ class ContainerApiary(val te: TileApiary, player: EntityPlayer) extends BaseCont
addSlotToContainer(new SlotValidating(te, 1, 39, 52))
if (!te.getWorld.isRemote && (te.owner :== null)) {
Gendustry.logInfo("Owner information missing on apiary at (%d,%d,%d), assigning: %s".format(te.getXCoord, te.getYCoord, te.getZCoord, player.getGameProfile))
Gendustry.logInfo("Owner information missing on apiary at (%d,%d,%d), assigning: %s".format(te.xCoord, te.yCoord, te.zCoord, player.getGameProfile))
te.owner := player.getGameProfile
}
@@ -10,7 +10,7 @@
package net.bdew.gendustry.machines.apiary
import cpw.mods.fml.relauncher.{Side, SideOnly}
import forestry.api.core.{ErrorStateRegistry, IErrorState}
import forestry.api.core.{ForestryAPI, IErrorState}
import net.minecraft.client.renderer.texture.IIconRegister
import net.minecraft.util.IIcon
@@ -33,13 +33,14 @@ case class GendustryErrorState(name: String, id: Short) extends IErrorState {
object GendustryErrorStates {
val Disabled = GendustryErrorState("disabled", 500)
def init() {
ErrorStateRegistry.registerErrorState(GendustryErrorStates.Disabled)
ForestryAPI.errorStateRegistry.registerErrorState(GendustryErrorStates.Disabled)
}
}
object ForestryErrorStates {
val ok = ErrorStateRegistry.getErrorState("Forestry:ok")
val noPower = ErrorStateRegistry.getErrorState("Forestry:noPower")
val noRedstone = ErrorStateRegistry.getErrorState("Forestry:noRedstone")
val disabledRedstone = ErrorStateRegistry.getErrorState("Forestry:disabledRedstone")
val errorStates = ForestryAPI.errorStateRegistry
val ok = errorStates.getErrorState("Forestry:ok")
val noPower = errorStates.getErrorState("Forestry:noPower")
val noRedstone = errorStates.getErrorState("Forestry:noRedstone")
val disabledRedstone = errorStates.getErrorState("Forestry:disabledRedstone")
}
@@ -23,7 +23,7 @@ class GuiApiary(val te: TileApiary, player: EntityPlayer, cont: ContainerApiary)
super.initGui()
widgets.add(new WidgetError(155, 5, te))
widgets.add(new WidgetPowerCustom(new Rect(8, 19, 16, 58), Textures.powerFill, te.power))
widgets.add(new WidgetApiaryProgress(new Rect(69, 22, 36, 15), te.guiBreeding, te.guiProgress))
widgets.add(new WidgetApiaryProgress(new Rect(69, 22, 36, 15), te.guiProgress))
widgets.add(new WidgetLabel(Misc.toLocal("tile.gendustry.apiary.name"), 8, 6, Color.darkGray))
widgets.add(new WidgetRSModeButton(Point(137, 5), te, cont))
@@ -10,7 +10,7 @@
package net.bdew.gendustry.machines.apiary
import _root_.forestry.api.apiculture.IBeeRoot
import forestry.api.genetics.{AlleleManager, IAllele}
import forestry.api.genetics.AlleleManager
import net.bdew.gendustry.Gendustry
import net.minecraft.util.{ChatComponentTranslation, EnumChatFormatting}
@@ -26,8 +26,7 @@ object Sanity {
val defSpecies = defGenome.getPrimary
var found = false
for (mutation <- bees.getMutations(false)) {
//Have to use the deprecated version because of not-updated other mods
if (mutation.getChance(house, defSpecies.asInstanceOf[IAllele], defSpecies, defGenome, defGenome) > 0) {
if (mutation.getChance(house, defSpecies.asInstanceOf, defSpecies, defGenome, defGenome) > 0) {
found = true
Gendustry.logWarn("Detected probably bugged mutation! %s+%s (class: %s) doesn't check the species. Please report it to the mod author.",
mutation.getAllele0.getName, mutation.getAllele1.getName, mutation.getClass.getCanonicalName)
@@ -10,7 +10,9 @@
package net.bdew.gendustry.machines.apiary
import java.util
import java.util.Collections
import com.mojang.authlib.GameProfile
import forestry.api.apiculture._
import forestry.api.arboriculture.EnumGermlingType
import forestry.api.core._
@@ -33,6 +35,7 @@ import net.bdew.lib.power.DataSlotPower
import net.bdew.lib.tile.TileExtended
import net.bdew.lib.tile.inventory.{PersistentInventoryTile, SidedInventory}
import net.minecraft.item.ItemStack
import net.minecraft.util.ChunkCoordinates
import net.minecraft.world.biome.BiomeGenBase
import net.minecraftforge.common.util.ForgeDirection
@@ -44,7 +47,10 @@ with TileKeepData
with TilePowered
with TileRSControllable
with TileCoverable
with IIndustrialApiary {
with IIndustrialApiary
with IBeeModifier
with IBeeListener
with IBeeHousingInventory {
object slots {
val queen = 0
@@ -64,7 +70,6 @@ with IIndustrialApiary {
val errorConditions = DataSlotErrorStates("errors", this).setUpdate(UpdateKind.GUI, UpdateKind.SAVE, UpdateKind.WORLD)
val owner = DataSlotGameProfile("owner", this).setUpdate(UpdateKind.SAVE)
val guiProgress = DataSlotFloat("progress", this)
val guiBreeding = DataSlotFloat("breeding", this)
val logic = beeRoot.createBeekeepingLogic(this)
@@ -105,8 +110,8 @@ with IIndustrialApiary {
}
clientTick.listen(() =>
if (beeRoot.isMated(queen) && errorConditions.isOk && Config.renderBeeEffects) {
beeRoot.getMember(queen).doFX(logic.getEffectData, this)
if (beeRoot.isMated(queen) && errorConditions.isOk && Config.renderBeeEffects && logic.canDoBeeFX) {
logic.doBeeFX()
}
)
@@ -117,27 +122,20 @@ with IIndustrialApiary {
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)
errorConditions.setCondition((rsmode :== RSMode.RS_OFF) && powered, ForestryErrorStates.disabledRedstone)
errorConditions.setCondition((rsmode :== RSMode.RS_ON) && !powered, ForestryErrorStates.noRedstone)
errorConditions.setCondition(rsmode :== RSMode.NEVER, GendustryErrorStates.Disabled)
errorConditions.setCondition(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)
}
power.extract(cfg.baseMjPerTick * mods.energy, false)
}
}
if (movePrincess && getStackInSlot(slots.queen) == null)
doMovePrincess()
if (logic.getQueen != null)
guiProgress := 1 - (logic.getQueen.getHealth.toFloat / logic.getQueen.getMaxHealth)
else
guiProgress := -1
guiBreeding := logic.getBreedingTime.toFloat / logic.getTotalBreedingTime
guiProgress := logic.getBeeProgressPercent
})
def getUpgrade(stack: ItemStack) = stack.getItem.asInstanceOf[IApiaryUpgrade]
@@ -191,11 +189,16 @@ with IIndustrialApiary {
// Misc
def getBiome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord)
override def getSizeInventory = 15
def getModifiedBiome = if (mods.biomeOverride == null) getBiome else mods.biomeOverride
// SidedInventory
override def canInsertItem(slot: Int, stack: ItemStack, side: Int) = slots.bees.contains(slot) && isItemValidForSlot(slot, stack)
override def canExtractItem(slot: Int, stack: ItemStack, side: Int) = slots.output.contains(slot)
//IIndustrialApiary
// IIndustrialApiary
override def getUpgrades = {
import scala.collection.JavaConversions._
slots.upgrades map inv filterNot (_ == null)
@@ -203,17 +206,23 @@ with IIndustrialApiary {
override def getModifiers = mods
// IErrorLogicSource
override def getErrorLogic: IErrorLogic = errorConditions
// IForestryMultiErrorSource
override def getErrorStates: util.Set[IErrorState] = {
import scala.collection.JavaConversions._
errorConditions.value
}
// IBeeListener
override def onPostQueenDeath(queen: IBee) {
override def onQueenDeath() {
if (mods.isAutomated) movePrincess = true
}
override def onQueenDeath(queen: IBee) {}
override def wearOutEquipment(amount: Int) {}
override def onQueenChange(stack: ItemStack) {}
override def onEggLaid(queen: IBee) = false
override def onPollenRetrieved(queen: IBee, pollen: IIndividual, isHandled: Boolean): Boolean = {
if (isHandled) return true
override def onPollenRetrieved(pollen: IIndividual): Boolean = {
if (!mods.isCollectingPollen) return false
val spRoot = pollen.getGenome.getSpeciesRoot
val stack = spRoot.getMemberStack(pollen, EnumGermlingType.POLLEN.ordinal())
@@ -233,49 +242,34 @@ with IIndustrialApiary {
override def isSunlightSimulated = mods.isSunlightSimulated
override def isHellish = getModifiedBiome == BiomeGenBase.hell
// IBeeHousing
override def setQueen(stack: ItemStack) = setInventorySlotContents(0, stack)
override def setDrone(stack: ItemStack) = setInventorySlotContents(1, stack)
override def getQueen = getStackInSlot(slots.queen)
override def getDrone = getStackInSlot(slots.drone)
override def canBreed = true
def getModifiedBiome = if (mods.biomeOverride == null) getBiome else mods.biomeOverride
// IHousing
override def getWorld = worldObj
override def getCoordinates = new ChunkCoordinates(xCoord, yCoord, zCoord)
@deprecated("use getErrorStates instead", "forestry 3.6.x")
override def getErrorState = errorConditions.headOption.getOrElse(ForestryErrorStates.ok)
// IBeeHousing
override def getBeeInventory: IBeeHousingInventory = this
override def getBeeListeners = Collections.singletonList(this)
override def getBeeModifiers = Collections.singletonList(this)
override def getBeekeepingLogic: IBeekeepingLogic = beeRoot.createBeekeepingLogic(this)
@deprecated("use setErrorCondition instead", "forestry 3.6.x")
override def setErrorState(state: IErrorState) =
if (state == ForestryErrorStates.ok)
errorConditions.clearAll()
else
errorConditions.set(state)
override def getBlockLightValue: Int = worldObj.getBlockLightValue(xCoord, yCoord, zCoord)
override def canBlockSeeTheSky: Boolean = worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)
override def getOwner: GameProfile = owner
override def getErrorStates: util.Set[IErrorState] = {
import scala.collection.JavaConversions._
errorConditions.value
}
override def setErrorCondition(condition: Boolean, errorState: IErrorState): Boolean = {
errorConditions.toggle(errorState, condition)
condition
}
override def getOwnerName = owner
override def getXCoord = xCoord
override def getYCoord = yCoord
override def getZCoord = zCoord
override def getTemperature =
if (BiomeHelper.isBiomeHellish(getModifiedBiome))
EnumTemperature.HELLISH
else
EnumTemperature.getFromValue(getModifiedBiome.temperature + mods.temperature)
override def getHumidity = EnumHumidity.getFromValue(getModifiedBiome.rainfall + mods.humidity)
// IBeeHousingInventory
override def setQueen(stack: ItemStack) = setInventorySlotContents(0, stack)
override def setDrone(stack: ItemStack) = setInventorySlotContents(1, stack)
override def getQueen = getStackInSlot(slots.queen)
override def getDrone = getStackInSlot(slots.drone)
override def addProduct(product: ItemStack, all: Boolean): Boolean = {
if (product == null || product.getItem == null) {
Gendustry.logError("Industrial Apiary at %d,%d,%d received an invalid bee product, one of your bee-adding mods is borked.", xCoord, yCoord, zCoord)
@@ -9,30 +9,22 @@
package net.bdew.gendustry.machines.apiary
import net.bdew.gendustry.Gendustry
import net.bdew.gendustry.gui.Textures
import net.bdew.lib.Misc
import net.bdew.lib.data.DataSlotFloat
import net.bdew.lib.gui.widgets.Widget
import net.bdew.lib.gui.{Point, Rect}
import scala.collection.mutable
class WidgetApiaryProgress(val rect: Rect, breeding: DataSlotFloat, progress: DataSlotFloat) extends Widget {
class WidgetApiaryProgress(val rect: Rect, progress: DataSlotFloat) extends Widget {
val texture = Textures.whiteProgress(rect.w)
override def handleTooltip(p: Point, tip: mutable.MutableList[String]) {
if (breeding.value > 0) {
tip += "%s - %.0f%%".format(Misc.toLocal(Gendustry.modId + ".label.breeding"), breeding.value * 100)
} else if (progress.value > 0) {
tip += "%s - %.0f%%".format(Misc.toLocal(Gendustry.modId + ".label.working"), progress.value * 100)
}
tip += "%.0f%%".format(progress.value * 100)
}
override def draw(mouse: Point) {
if (breeding.value > 0) {
parent.drawTextureInterpolate(rect, texture, 0, 0, breeding.value, 1)
} else if (progress.value > 0) {
if (progress.value > 0) {
parent.drawTextureInterpolate(rect, texture, 0, 0, progress.value, 1)
}
}
@@ -9,17 +9,51 @@
package net.bdew.gendustry.misc
import forestry.api.core.{ErrorStateRegistry, IErrorState}
import java.io.{DataInputStream, DataOutputStream}
import com.google.common.collect.ImmutableSet
import forestry.api.core.{IErrorLogic, IErrorState}
import net.bdew.gendustry.machines.apiary.ForestryErrorStates
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]] {
case class DataSlotErrorStates(name: String, parent: DataSlotContainer) extends DataSlotVal[Set[IErrorState]] with IErrorLogic {
override var value: Set[IErrorState] = Set.empty
val suspendUpdates = new DynamicVariable(false)
// ==== IErrorLogic
override def getErrorStates: ImmutableSet[IErrorState] = ImmutableSet.copyOf(value.toArray)
override def setCondition(condition: Boolean, errorState: IErrorState): Boolean = {
if (condition)
set(errorState)
else
clear(errorState)
condition
}
override def hasErrors: Boolean = !isOk
override def clearErrors(): Unit = clearAll()
override def contains(state: IErrorState): Boolean = value.contains(state)
override def writeData(data: DataOutputStream): Unit = {
data.writeInt(value.size)
for (x <- value)
data.writeUTF(x.getUniqueName)
}
override def readData(data: DataInputStream): Unit = {
val errNum = data.readInt()
val errors = for (i <- 0 until errNum)
yield Option(ForestryErrorStates.errorStates.getErrorState(data.readUTF()))
value = errors.flatten.toSet
}
// ================
def set(v: IErrorState): Unit = {
value += v
if (!suspendUpdates.value)
@@ -59,7 +93,7 @@ case class DataSlotErrorStates(name: String, parent: DataSlotContainer) extends
import net.bdew.lib.nbt._
override def load(t: NBTTagCompound, kind: UpdateKind.Value): Unit = {
value = (t.getList[String](name) flatMap { x => Option(ErrorStateRegistry.getErrorState(x)) }).toSet
value = (t.getList[String](name) flatMap { x => Option(ForestryErrorStates.errorStates.getErrorState(x)) }).toSet
}
override def save(t: NBTTagCompound, kind: UpdateKind.Value): Unit = {