mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-25 22:44:25 +00:00
Updated to forestry 3.6.0. Added multiple error states support for the apiary. Merged changes from FU branch.
This commit is contained in:
1 parent
2fc3454003
commit
dc551be6ab
16 files changed
+201
-70
No files matched your search
@@ -5,3 +5,7 @@
|
||||
* Added **registries.IMutatronOverrides** and **EnumMutationSetting** - allows overriding what mutations are available
|
||||
|
||||
Older changes were not recorded, you can see the commits [here](https://github.com/bdew/gendustry/commits/mc1710/src/net/bdew/gendustry/api).
|
||||
|
||||
### 2.1.0
|
||||
* Added blocks.IForestryMultiErrorSource - access to multiple forestry error states (used in industrial apiary)
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
gendustry.version=1.5.0
|
||||
gendustry.api.version=2.0.0
|
||||
gendustry.api.version=2.1.0
|
||||
curseforge.id=70492
|
||||
|
||||
bdlib.version=1.9.0.93
|
||||
@@ -13,7 +13,7 @@ ccc.version=1.0.4.35
|
||||
|
||||
buildcraft.version=7.0.7
|
||||
ic2.version=2.2.719-experimental
|
||||
forestry.version=3.5.7.16
|
||||
forestry.version=3.6.0.17
|
||||
waila.version=1.5.10
|
||||
|
||||
cofhlib.cf=2236/777
|
||||
|
||||
@@ -26,7 +26,7 @@ import net.bdew.gendustry.config.loader.TuningLoader
|
||||
import net.bdew.gendustry.custom.CustomContent
|
||||
import net.bdew.gendustry.forestry.GeneRecipe
|
||||
import net.bdew.gendustry.gui.HintIcons
|
||||
import net.bdew.gendustry.machines.apiary.ErrorCodes
|
||||
import net.bdew.gendustry.machines.apiary.GendustryErrorStates
|
||||
import net.bdew.gendustry.machines.apiary.upgrades.Upgrades
|
||||
import net.bdew.gendustry.misc._
|
||||
import net.bdew.lib.Misc
|
||||
@@ -67,7 +67,7 @@ object Gendustry {
|
||||
configDir = new File(event.getModConfigurationDirectory, "gendustry")
|
||||
TuningLoader.loadConfigFiles()
|
||||
|
||||
ErrorCodes.init()
|
||||
GendustryErrorStates.init()
|
||||
|
||||
if (Misc.haveModVersion("BuildCraftAPI|statements"))
|
||||
TriggerProvider.registerTriggers()
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2015
|
||||
* https://github.com/bdew/gendustry
|
||||
*
|
||||
* This mod is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://bdew.net/minecraft-mod-public-license/
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.api.blocks;
|
||||
|
||||
import forestry.api.core.IErrorState;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface IForestryMultiErrorSource {
|
||||
Set<IErrorState> getErrorStates();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
* Public interface to Industrial Apiary TileEntity
|
||||
* Extends forestry IBeeHousing, IBeeModifier, IBeeListener, IHousing so all of those are usable as well
|
||||
*/
|
||||
public interface IIndustrialApiary extends IBeeHousing {
|
||||
public interface IIndustrialApiary extends IBeeHousing, IForestryMultiErrorSource {
|
||||
/**
|
||||
* Do not cache, stored copies will not be updated
|
||||
*
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
package net.bdew.gendustry.compat
|
||||
|
||||
import java.util
|
||||
|
||||
import com.mojang.authlib.GameProfile
|
||||
import forestry.api.apiculture.{IBee, IBeeGenome, IBeeHousing}
|
||||
import forestry.api.core.{EnumHumidity, EnumTemperature, ErrorStateRegistry, IErrorState}
|
||||
@@ -52,13 +54,12 @@ 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 getErrorOrdinal: Int = 0
|
||||
override def setErrorState(state: Int): Unit = {}
|
||||
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 getBiome = tile.getWorldObj.getBiomeGenForCoordsBody(tile.xCoord, tile.zCoord)
|
||||
override def getBiomeId: Int = getBiome.biomeID
|
||||
override def getHumidity: EnumHumidity = EnumHumidity.getFromValue(getBiome.rainfall)
|
||||
override def getTemperature: EnumTemperature = EnumTemperature.getFromValue(getBiome.temperature)
|
||||
}
|
||||
@@ -10,25 +10,25 @@
|
||||
package net.bdew.gendustry.compat.triggers
|
||||
|
||||
import buildcraft.api.statements.StatementManager
|
||||
import forestry.api.core.IErrorState
|
||||
import forestry.api.core.{ErrorStateRegistry, IErrorState}
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.machines.apiary.ErrorCodes
|
||||
import net.bdew.gendustry.api.blocks.IForestryMultiErrorSource
|
||||
import net.bdew.lib.Misc
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
trait ForestryErrorSource extends TileEntity {
|
||||
def getErrorOrdinal: Int
|
||||
def getErrorState: IErrorState
|
||||
}
|
||||
trait TileEntityErrorSource extends TileEntity with IForestryMultiErrorSource
|
||||
|
||||
case class ForestryErrorTrigger(state: IErrorState) extends BaseTrigger("forestry.error." + state.getID, "y%03d".format(state.getID), classOf[ForestryErrorSource]) {
|
||||
case class ForestryErrorTrigger(state: IErrorState) extends BaseTrigger("forestry.error." + state.getID, "y%03d".format(state.getID), classOf[TileEntityErrorSource]) {
|
||||
override def getIcon = state.getIcon
|
||||
override def getDescription = Misc.toLocal("for." + state.getDescription)
|
||||
override def registerIcons(ir: IIconRegister) {}
|
||||
override def getState(side: ForgeDirection, tile: ForestryErrorSource) =
|
||||
tile.getErrorState == state
|
||||
override def getState(side: ForgeDirection, tile: TileEntityErrorSource) =
|
||||
if (state.getUniqueName == "Forestry:ok")
|
||||
tile.getErrorStates.isEmpty
|
||||
else
|
||||
tile.getErrorStates.contains(state)
|
||||
}
|
||||
|
||||
object ForestryErrorTriggers {
|
||||
@@ -46,8 +46,10 @@ object ForestryErrorTriggers {
|
||||
"Forestry:noDrone",
|
||||
"Forestry:noSky",
|
||||
"Forestry:noSpace",
|
||||
"Forestry:noPower"
|
||||
) map ErrorCodes.getErrorByName
|
||||
"Forestry:noPower",
|
||||
"Forestry:noRedstone",
|
||||
"Forestry:disabledRedstone"
|
||||
) map ErrorStateRegistry.getErrorState
|
||||
|
||||
val validTriggerStates = apiaryTriggerStates.toSet
|
||||
val validTriggers = validTriggerStates.map(x => x -> ForestryErrorTrigger(x)).toMap
|
||||
|
||||
@@ -83,8 +83,8 @@ class Loader extends RecipeLoader with GenericConfigLoader with LootListLoader {
|
||||
Gendustry.logDebug("Adding centrifuge recipe: %s => %s", stack, out)
|
||||
|
||||
// forestry API is stupid and requires a hashmap, build one for it
|
||||
val outStacks = new java.util.HashMap[ItemStack, Integer]
|
||||
resolveLootList(out).foreach(x => outStacks.put(x._2, x._1.round.toInt))
|
||||
val outStacks = new java.util.HashMap[ItemStack, java.lang.Float]
|
||||
resolveLootList(out).foreach(x => outStacks.put(x._2, x._1.toFloat / 100F))
|
||||
|
||||
val inStack = getConcreteStackNoWildcard(stack)
|
||||
|
||||
|
||||
@@ -42,6 +42,12 @@ class BeeMutation(parent1: IAlleleBeeSpecies, parent2: IAlleleBeeSpecies, result
|
||||
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,9 +83,14 @@ 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.
|
||||
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
|
||||
|
||||
override val isNocturnal = cfg.getBoolean("Nocturnal")
|
||||
override val getRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees").asInstanceOf[IBeeRoot]
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ object GeneticsHelper {
|
||||
case (EnumMutationSetting.ENABLED, _) => true
|
||||
case (EnumMutationSetting.DISABLED, _) => false
|
||||
case (EnumMutationSetting.REQUIREMENTS, beeMutation: IBeeMutation) =>
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
+10
-18
@@ -11,27 +11,9 @@ package net.bdew.gendustry.machines.apiary
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import forestry.api.core.{ErrorStateRegistry, IErrorState}
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.gui.Texture
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
import net.minecraft.util.IIcon
|
||||
|
||||
object ErrorCodes {
|
||||
val UNKNOWN = ErrorStateRegistry.getErrorState("Forestry:unknown")
|
||||
|
||||
def getErrorById(i: Int) = Option(ErrorStateRegistry.getErrorState(i.toShort)).getOrElse(UNKNOWN)
|
||||
def getErrorByName(n: String) = Option(ErrorStateRegistry.getErrorState(n)).getOrElse(UNKNOWN)
|
||||
|
||||
def isValid(i: Int) = ErrorStateRegistry.getErrorState(i.toShort) != null
|
||||
def getIcon(i: Int) = Texture(Texture.ITEMS, getErrorById(i).getIcon)
|
||||
def getDescription(i: Int) = Misc.toLocal("for." + getErrorById(i).getDescription)
|
||||
def getHelp(i: Int) = Misc.toLocal("for." + getErrorById(i).getHelp)
|
||||
|
||||
def init() {
|
||||
ErrorStateRegistry.registerErrorState(GendustryErrorStates.Disabled)
|
||||
}
|
||||
}
|
||||
|
||||
case class GendustryErrorState(name: String, id: Short) extends IErrorState {
|
||||
var icon: IIcon = null
|
||||
override def getID = id
|
||||
@@ -50,4 +32,14 @@ case class GendustryErrorState(name: String, id: Short) extends IErrorState {
|
||||
|
||||
object GendustryErrorStates {
|
||||
val Disabled = GendustryErrorState("disabled", 500)
|
||||
def init() {
|
||||
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")
|
||||
}
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
package net.bdew.gendustry.machines.apiary
|
||||
|
||||
import java.util
|
||||
|
||||
import forestry.api.apiculture._
|
||||
import forestry.api.arboriculture.EnumGermlingType
|
||||
import forestry.api.core._
|
||||
@@ -17,9 +19,9 @@ import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.api.ApiaryModifiers
|
||||
import net.bdew.gendustry.api.blocks.IIndustrialApiary
|
||||
import net.bdew.gendustry.api.items.IApiaryUpgrade
|
||||
import net.bdew.gendustry.compat.triggers.ForestryErrorSource
|
||||
import net.bdew.gendustry.config.Config
|
||||
import net.bdew.gendustry.gui.rscontrol.TileRSControllable
|
||||
import net.bdew.gendustry.gui.rscontrol.{RSMode, TileRSControllable}
|
||||
import net.bdew.gendustry.misc.DataSlotErrorStates
|
||||
import net.bdew.gendustry.power.TilePowered
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.block.TileKeepData
|
||||
@@ -40,7 +42,6 @@ with PersistentInventoryTile
|
||||
with SidedInventory
|
||||
with TileKeepData
|
||||
with TilePowered
|
||||
with ForestryErrorSource
|
||||
with TileRSControllable
|
||||
with TileCoverable
|
||||
with IIndustrialApiary {
|
||||
@@ -57,15 +58,16 @@ with IIndustrialApiary {
|
||||
var movePrincess = false
|
||||
|
||||
val beeRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees").asInstanceOf[IBeeRoot]
|
||||
val logic = beeRoot.createBeekeepingLogic(this)
|
||||
lazy val cfg = MachineApiary
|
||||
|
||||
val power = DataSlotPower("power", this)
|
||||
val errorState = DataSlotInt("error", this).setUpdate(UpdateKind.GUI, UpdateKind.SAVE, UpdateKind.WORLD)
|
||||
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)
|
||||
|
||||
configurePower(cfg)
|
||||
|
||||
// for client rendering and fx
|
||||
@@ -103,22 +105,32 @@ with IIndustrialApiary {
|
||||
}
|
||||
|
||||
clientTick.listen(() =>
|
||||
if (beeRoot.isMated(queen) && (errorState :== 1) && Config.renderBeeEffects) {
|
||||
if (beeRoot.isMated(queen) && errorConditions.isOk && Config.renderBeeEffects) {
|
||||
beeRoot.getMember(queen).doFX(logic.getEffectData, this)
|
||||
}
|
||||
)
|
||||
|
||||
// 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
|
||||
|
||||
if (!canWork) {
|
||||
setErrorState(GendustryErrorStates.Disabled)
|
||||
} else if (power.stored >= cfg.baseMjPerTick * mods.energy) {
|
||||
logic.update()
|
||||
if ((logic.getQueen != null || logic.getBreedingTime > 0) && (errorState :== 1))
|
||||
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)
|
||||
} else {
|
||||
setErrorState(ErrorCodes.getErrorByName("Forestry:noPower"))
|
||||
}
|
||||
}
|
||||
|
||||
if (movePrincess && getStackInSlot(slots.queen) == null)
|
||||
@@ -237,21 +249,37 @@ with IIndustrialApiary {
|
||||
// IHousing
|
||||
|
||||
override def getWorld = worldObj
|
||||
override def setErrorState(state: Int) = errorState := state
|
||||
override def getErrorState = ErrorCodes.getErrorById(errorState)
|
||||
override def setErrorState(state: IErrorState) = errorState := state.getID
|
||||
|
||||
@deprecated("use getErrorStates instead", "forestry 3.6.x")
|
||||
override def getErrorState = errorConditions.headOption.getOrElse(ForestryErrorStates.ok)
|
||||
|
||||
@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 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 getBiomeId = getModifiedBiome.biomeID
|
||||
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)
|
||||
override def getErrorOrdinal = errorState
|
||||
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)
|
||||
|
||||
@@ -10,18 +10,34 @@
|
||||
package net.bdew.gendustry.machines.apiary
|
||||
|
||||
import net.bdew.lib.gui.widgets.Widget
|
||||
import net.bdew.lib.gui.{Point, Rect}
|
||||
import net.bdew.lib.gui.{Point, Rect, Texture}
|
||||
import net.bdew.lib.{Client, Misc}
|
||||
import net.minecraft.util.EnumChatFormatting
|
||||
|
||||
import scala.collection.mutable
|
||||
|
||||
class WidgetError(x: Int, y: Int, apiary: TileApiary) extends Widget {
|
||||
val rect: Rect = new Rect(x, y, 16, 16)
|
||||
|
||||
def getDisplayedError = {
|
||||
import scala.collection.JavaConversions._
|
||||
val errors = apiary.getErrorStates
|
||||
if (errors.isEmpty) {
|
||||
ForestryErrorStates.ok
|
||||
} else {
|
||||
val pos = ((Client.world.getTotalWorldTime / 40) % errors.size()).toInt
|
||||
errors.toList.sortBy(_.getID).apply(pos)
|
||||
}
|
||||
}
|
||||
|
||||
override def draw(mouse: Point) {
|
||||
parent.drawTexture(rect, ErrorCodes.getIcon(apiary.errorState.value))
|
||||
parent.drawTexture(rect, Texture(Texture.ITEMS, getDisplayedError.getIcon))
|
||||
}
|
||||
|
||||
override def handleTooltip(p: Point, tip: mutable.MutableList[String]) {
|
||||
tip += ErrorCodes.getDescription(apiary.errorState.value)
|
||||
tip ++= apiary.errorConditions.toList.sortBy(_.getID) map { err =>
|
||||
EnumChatFormatting.RED + Misc.toLocal("for." + err.getDescription)
|
||||
}
|
||||
tip ++= apiary.getStats
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2015
|
||||
* https://github.com/bdew/gendustry
|
||||
*
|
||||
* This mod is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://bdew.net/minecraft-mod-public-license/
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.misc
|
||||
|
||||
import forestry.api.core.{ErrorStateRegistry, IErrorState}
|
||||
import net.bdew.lib.data.base.{DataSlotContainer, DataSlotVal, UpdateKind}
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
case class DataSlotErrorStates(name: String, parent: DataSlotContainer) extends DataSlotVal[Set[IErrorState]] {
|
||||
override var value: Set[IErrorState] = Set.empty
|
||||
|
||||
def set(v: IErrorState): Unit = {
|
||||
value += v
|
||||
parent.dataSlotChanged(this)
|
||||
}
|
||||
|
||||
def clear(v: IErrorState): Unit = {
|
||||
value -= v
|
||||
parent.dataSlotChanged(this)
|
||||
}
|
||||
|
||||
def clearAll(): Unit = {
|
||||
value = Set.empty
|
||||
parent.dataSlotChanged(this)
|
||||
}
|
||||
|
||||
def toggle(v: IErrorState, on: Boolean): Unit = {
|
||||
if (on)
|
||||
set(v)
|
||||
else
|
||||
clear(v)
|
||||
}
|
||||
|
||||
def isOk = value.isEmpty
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
override def save(t: NBTTagCompound, kind: UpdateKind.Value): Unit = {
|
||||
t.setList(name, value map (_.getUniqueName))
|
||||
}
|
||||
}
|
||||
@@ -13,17 +13,23 @@ import mcp.mobius.waila.api.{IWailaConfigHandler, IWailaDataAccessor}
|
||||
import net.bdew.gendustry.machines.apiary.TileApiary
|
||||
import net.bdew.lib.Misc
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.EnumChatFormatting
|
||||
|
||||
object WailaApiaryDataProvider extends BaseDataProvider(classOf[TileApiary]) {
|
||||
override def getBodyStrings(target: TileApiary, stack: ItemStack, acc: IWailaDataAccessor, cfg: IWailaConfigHandler) = {
|
||||
List(
|
||||
Misc.toLocalF("gendustry.label.status", Misc.toLocal("for." + target.getErrorState.getDescription)),
|
||||
Misc.toLocalF("gendustry.label.control", Misc.toLocal("gendustry.rsmode." + target.rsmode.value.toString.toLowerCase))
|
||||
) ++ (Option(target.queen.value) map (_.getDisplayName)) ++ (
|
||||
if (acc.getPlayer.isSneaking)
|
||||
target.getStats
|
||||
else
|
||||
Some(Misc.toLocal("gendustry.label.shift"))
|
||||
)
|
||||
var strings = target.errorConditions.toList.sortBy(_.getID) map { err =>
|
||||
EnumChatFormatting.RED + Misc.toLocal("for." + err.getDescription)
|
||||
}
|
||||
strings :+= Misc.toLocalF("gendustry.label.control", Misc.toLocal("gendustry.rsmode." + target.rsmode.value.toString.toLowerCase))
|
||||
|
||||
if (target.queen :!= null)
|
||||
strings :+= target.queen.getDisplayName
|
||||
|
||||
if (acc.getPlayer.isSneaking)
|
||||
strings ++= target.getStats
|
||||
else
|
||||
strings :+= Misc.toLocal("gendustry.label.shift")
|
||||
|
||||
strings
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user