mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-10-25 20:32:38 +00:00
Merge branch 'forestry_unstable' into mc1710
This commit is contained in:
commit
9c66c02dbc
25 files changed
+271
-233
No files matched your search
+3
-1
@@ -1,3 +1,6 @@
|
||||
### 2.3.0
|
||||
* Deprecated IForestryMultiErrorSource - Use IErrorLogicSource from forestry API instead
|
||||
|
||||
### 2.2.0
|
||||
* Added IConfigLoader - allows other mods to submit configs to be loaded Gendustry
|
||||
|
||||
@@ -11,4 +14,3 @@
|
||||
* 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).
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
gendustry.version=1.6.1
|
||||
gendustry.api.version=2.2.0
|
||||
gendustry.version=1.6.2
|
||||
gendustry.api.version=2.3.0
|
||||
curseforge.id=70492
|
||||
|
||||
bdlib.version=1.9.2.104
|
||||
@@ -13,7 +13,7 @@ ccc.version=1.0.4.35
|
||||
|
||||
buildcraft.version=7.0.17
|
||||
ic2.version=2.2.757-experimental
|
||||
forestry.version=3.6.3.20
|
||||
forestry.version=4.0.8.36
|
||||
waila.version=1.5.10
|
||||
|
||||
cofhlib.cf=2246/918
|
||||
|
||||
@@ -276,6 +276,8 @@ itemGroup.bdew.templates=Genetic Templates
|
||||
itemGroup.bdew.samples=Genetic Samples
|
||||
itemGroup.bdew.hives=Custom Beehives
|
||||
|
||||
gendustry.errorstate.ok=No error
|
||||
|
||||
for.gendustry.errorstate.disabled.description=Disabled
|
||||
for.gendustry.errorstate.disabled.help=The machine is disabled by it's configuration
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 130 B |
@@ -35,7 +35,7 @@ import net.minecraft.command.CommandHandler
|
||||
import net.minecraftforge.oredict.RecipeSorter
|
||||
import org.apache.logging.log4j.Logger
|
||||
|
||||
@Mod(modid = Gendustry.modId, version = "GENDUSTRY_VER", name = "Gendustry", dependencies = "required-after:Forestry@[3.6.0.0,);after:BuildCraft|energy;after:BuildCraft|Silicon;after:IC2;after:CoFHCore;after:BinnieCore;after:ExtraBees;after:ExtraTrees;after:MineFactoryReloaded;after:MagicBees;required-after:bdlib@[BDLIB_VER,)", modLanguage = "scala")
|
||||
@Mod(modid = Gendustry.modId, version = "GENDUSTRY_VER", name = "Gendustry", dependencies = "required-after:Forestry@[4.0.0.0,);after:BuildCraft|energy;after:BuildCraft|Silicon;after:IC2;after:CoFHCore;after:BinnieCore;after:ExtraBees;after:ExtraTrees;after:MineFactoryReloaded;after:MagicBees;required-after:bdlib@[BDLIB_VER,)", modLanguage = "scala")
|
||||
object Gendustry {
|
||||
var log: Logger = null
|
||||
var instance = this
|
||||
|
||||
@@ -13,6 +13,10 @@ import forestry.api.core.IErrorState;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated use IErrorLogicSource from forestry API instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IForestryMultiErrorSource {
|
||||
Set<IErrorState> getErrorStates();
|
||||
}
|
||||
@@ -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,6 +10,7 @@
|
||||
package net.bdew.gendustry.compat.triggers
|
||||
|
||||
import buildcraft.api.statements.{IStatementContainer, IStatementParameter, ITriggerExternal}
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.lib.Misc
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
@@ -20,9 +21,14 @@ import net.minecraftforge.common.util.ForgeDirection
|
||||
abstract class BaseTrigger[T](val id: String, ordering: String, tileClass: Class[T]) extends ITriggerExternal {
|
||||
var icon: IIcon = null
|
||||
override def getUniqueTag = "gendustry." + ordering + "." + id
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def getIcon = icon
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def registerIcons(ir: IIconRegister) =
|
||||
icon = ir.registerIcon(Misc.iconName(Gendustry.modId, "trigger", id))
|
||||
|
||||
override def getDescription = Misc.toLocal("gendustry.trigger." + id)
|
||||
override def rotateLeft() = this
|
||||
|
||||
|
||||
@@ -10,51 +10,44 @@
|
||||
package net.bdew.gendustry.compat.triggers
|
||||
|
||||
import buildcraft.api.statements.StatementManager
|
||||
import forestry.api.core.{ErrorStateRegistry, IErrorState}
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import forestry.api.core.{ForestryAPI, IErrorLogicSource, IErrorState}
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.api.blocks.IForestryMultiErrorSource
|
||||
import net.bdew.lib.Misc
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
case class ForestryErrorTrigger(state: IErrorState) extends BaseTrigger("forestry.error." + state.getID, "y%03d".format(state.getID), classOf[IForestryMultiErrorSource]) {
|
||||
case class ForestryErrorTrigger(state: IErrorState) extends BaseTrigger("forestry.error." + state.getID, "y%03d".format(state.getID), classOf[IErrorLogicSource]) {
|
||||
override def getIcon = state.getIcon
|
||||
override def getDescription = Misc.toLocal("for." + state.getDescription)
|
||||
override def registerIcons(ir: IIconRegister) {}
|
||||
override def getState(side: ForgeDirection, tile: IForestryMultiErrorSource) =
|
||||
if (state.getUniqueName == "Forestry:ok")
|
||||
tile.getErrorStates.isEmpty
|
||||
else
|
||||
tile.getErrorStates.contains(state)
|
||||
override def getState(side: ForgeDirection, tile: IErrorLogicSource) =
|
||||
tile.getErrorLogic.contains(state)
|
||||
}
|
||||
|
||||
object ForestryNoErrorTrigger extends BaseTrigger("forestry.noerror", "_", classOf[IErrorLogicSource]) {
|
||||
override def getDescription = Misc.toLocal("gendustry.errorstate.ok")
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def registerIcons(ir: IIconRegister): Unit = {
|
||||
icon = ir.registerIcon("gendustry:error/ok")
|
||||
}
|
||||
|
||||
override def getState(side: ForgeDirection, tile: IErrorLogicSource) =
|
||||
!tile.getErrorLogic.hasErrors
|
||||
}
|
||||
|
||||
object ForestryErrorTriggers {
|
||||
|
||||
val apiaryTriggerStates = List(
|
||||
"Forestry:ok",
|
||||
"Forestry:invalidBiome",
|
||||
"Forestry:isRaining",
|
||||
"Forestry:notGloomy",
|
||||
"Forestry:notLucid",
|
||||
"Forestry:notDay",
|
||||
"Forestry:notNight",
|
||||
"Forestry:noFlower",
|
||||
"Forestry:noQueen",
|
||||
"Forestry:noDrone",
|
||||
"Forestry:noSky",
|
||||
"Forestry:noSpace",
|
||||
"Forestry:noPower",
|
||||
"Forestry:noRedstone",
|
||||
"Forestry:disabledRedstone"
|
||||
) map ErrorStateRegistry.getErrorState
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
val validTriggerStates = apiaryTriggerStates.toSet
|
||||
val validTriggers = validTriggerStates.map(x => x -> ForestryErrorTrigger(x)).toMap
|
||||
val errorStateRegistry = ForestryAPI.errorStateRegistry
|
||||
|
||||
val apiaryTriggers = apiaryTriggerStates.map(validTriggers)
|
||||
val triggers = errorStateRegistry.getErrorStates.map(ForestryErrorTrigger) ++ List(ForestryNoErrorTrigger)
|
||||
|
||||
def register() {
|
||||
validTriggers.values.foreach(StatementManager.registerStatement)
|
||||
Gendustry.logInfo("Created %d BC triggers for Forestry error codes", validTriggers.size)
|
||||
triggers.foreach(StatementManager.registerStatement)
|
||||
StatementManager.registerStatement(ForestryNoErrorTrigger)
|
||||
Gendustry.logInfo("Created %d BC triggers for Forestry error codes", triggers.size)
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ package net.bdew.gendustry.compat.triggers
|
||||
import java.util
|
||||
|
||||
import buildcraft.api.statements._
|
||||
import net.bdew.gendustry.machines.apiary.TileApiary
|
||||
import forestry.api.core.IErrorLogicSource
|
||||
import net.bdew.gendustry.power.TilePowered
|
||||
import net.bdew.lib.power.TileBaseProcessor
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
@@ -25,8 +25,8 @@ object TriggerProvider extends ITriggerProvider {
|
||||
import scala.collection.JavaConversions._
|
||||
val triggers = new util.LinkedList[ITriggerExternal]()
|
||||
|
||||
if (tile.isInstanceOf[TileApiary])
|
||||
triggers.addAll(ForestryErrorTriggers.apiaryTriggers)
|
||||
if (tile.isInstanceOf[IErrorLogicSource])
|
||||
triggers.addAll(ForestryErrorTriggers.triggers)
|
||||
|
||||
if (tile.isInstanceOf[TilePowered])
|
||||
triggers.addAll(PowerTriggers.triggers)
|
||||
|
||||
@@ -11,7 +11,8 @@ 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.gendustry.forestry.BeeModifiers
|
||||
import net.bdew.lib.Misc
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.item.ItemStack
|
||||
@@ -29,25 +30,23 @@ 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.asInstanceOf[IAlleleBeeSpecies], allele1.asInstanceOf[IAlleleBeeSpecies], genome0.asInstanceOf[IBeeGenome], genome1.asInstanceOf[IBeeGenome])
|
||||
|
||||
override def getChance(housing: IBeeHousing, allele0: IAlleleBeeSpecies, allele1: IAlleleBeeSpecies, genome0: IBeeGenome, genome1: IBeeGenome) =
|
||||
getChanceImpl(housing, allele0, allele1, genome0, genome1)
|
||||
|
||||
def getChanceImpl(housing: IBeeHousing, allele0: IAlleleBeeSpecies, allele1: IAlleleBeeSpecies, genome0: IBeeGenome, genome1: IBeeGenome): 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
|
||||
@@ -57,8 +56,8 @@ class BeeMutation(parent1: IAlleleBeeSpecies, parent2: IAlleleBeeSpecies, result
|
||||
else {
|
||||
val bkm = getRoot.getBeekeepingMode(housing.getWorld)
|
||||
var processedChance = chance
|
||||
processedChance *= housing.getMutationModifier(genome0, genome1, processedChance)
|
||||
processedChance *= bkm.getMutationModifier(genome0, genome1, processedChance)
|
||||
processedChance *= BeeModifiers.from(housing).getMutationModifier(genome0, genome1, processedChance)
|
||||
processedChance *= bkm.getBeeModifier.getMutationModifier(genome0, genome1, processedChance)
|
||||
processedChance
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.mojang.authlib.GameProfile
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import forestry.api.apiculture._
|
||||
import forestry.api.core.{EnumHumidity, EnumTemperature}
|
||||
import forestry.api.genetics.{AlleleManager, IAllele, IIndividual}
|
||||
import forestry.api.genetics.{AlleleManager, IAlleleSpecies, IIndividual}
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.config.loader.TuningLoader
|
||||
import net.bdew.gendustry.forestry.ForestryItems
|
||||
@@ -85,11 +85,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
|
||||
|
||||
@@ -98,9 +94,9 @@ class BeeSpecies(cfg: ConfigSection, ident: String) extends IAlleleBeeSpecies {
|
||||
|
||||
// ==== RESEARCH SYSTEM
|
||||
|
||||
override lazy val getComplexity: Int = 1 + getMutationPathLength(this, mutable.Set.empty[IAllele])
|
||||
override lazy val getComplexity: Int = 1 + getMutationPathLength(this, mutable.Set.empty)
|
||||
|
||||
private def getMutationPathLength(species: IAllele, excludeSpecies: mutable.Set[IAllele]): Int = {
|
||||
private def getMutationPathLength(species: IAlleleSpecies, excludeSpecies: mutable.Set[IAlleleSpecies]): Int = {
|
||||
var highest = 0
|
||||
excludeSpecies += species
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.forestry
|
||||
|
||||
import forestry.api.apiculture.{IBeeGenome, IBeeHousing, IBeeModifier}
|
||||
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
/**
|
||||
* Combines multiple IBeeModifier together
|
||||
* Conceptually based on BeeHousingModifier from Forestry
|
||||
* @param modifiers collection of modifiers
|
||||
*/
|
||||
case class BeeModifiers(modifiers: Traversable[IBeeModifier]) extends IBeeModifier {
|
||||
override def getTerritoryModifier(genome: IBeeGenome, currentModifier: Float): Float =
|
||||
modifiers.foldLeft(1F)((v, m) => m.getTerritoryModifier(genome, v * currentModifier))
|
||||
|
||||
override def getMutationModifier(genome: IBeeGenome, mate: IBeeGenome, currentModifier: Float): Float =
|
||||
modifiers.foldLeft(1F)((v, m) => m.getMutationModifier(genome, mate, v * currentModifier))
|
||||
|
||||
override def getLifespanModifier(genome: IBeeGenome, mate: IBeeGenome, currentModifier: Float): Float =
|
||||
modifiers.foldLeft(1F)((v, m) => m.getLifespanModifier(genome, mate, v * currentModifier))
|
||||
|
||||
override def getProductionModifier(genome: IBeeGenome, currentModifier: Float): Float =
|
||||
modifiers.foldLeft(1F)((v, m) => m.getProductionModifier(genome, v * currentModifier))
|
||||
|
||||
override def getFloweringModifier(genome: IBeeGenome, currentModifier: Float): Float =
|
||||
modifiers.foldLeft(1F)((v, m) => m.getFloweringModifier(genome, v * currentModifier))
|
||||
|
||||
override def getGeneticDecay(genome: IBeeGenome, currentModifier: Float): Float =
|
||||
modifiers.foldLeft(1F)((v, m) => m.getGeneticDecay(genome, v * currentModifier))
|
||||
|
||||
override def isSealed: Boolean = modifiers.exists(_.isSealed)
|
||||
override def isSelfLighted: Boolean = modifiers.exists(_.isSelfLighted)
|
||||
override def isSunlightSimulated: Boolean = modifiers.exists(_.isSunlightSimulated)
|
||||
override def isHellish: Boolean = modifiers.exists(_.isHellish)
|
||||
}
|
||||
|
||||
object BeeModifiers {
|
||||
def from(beeHousing: IBeeHousing) = BeeModifiers(beeHousing.getBeeModifiers)
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ object Textures {
|
||||
object errors {
|
||||
val noPower = Texture(texture, 32, 0, 16, 16)
|
||||
val disabled = Texture(texture, 48, 0, 16, 16)
|
||||
val ok = Texture(texture, 65, 35, 14, 14)
|
||||
}
|
||||
|
||||
object button16 {
|
||||
|
||||
@@ -10,9 +10,8 @@
|
||||
package net.bdew.gendustry.items.covers
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import forestry.api.core.{ErrorStateRegistry, IErrorState}
|
||||
import forestry.api.core.{ForestryAPI, IErrorLogicSource, IErrorState}
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.api.blocks.IForestryMultiErrorSource
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.covers.{ItemCover, TileCoverable}
|
||||
import net.bdew.lib.helpers.ChatHelper._
|
||||
@@ -27,28 +26,30 @@ import net.minecraftforge.common.util.ForgeDirection
|
||||
trait ErrorSensor {
|
||||
def id: String
|
||||
def getUnLocalizedName: String
|
||||
def isActive(te: IForestryMultiErrorSource): Boolean
|
||||
def isActive(te: IErrorLogicSource): Boolean
|
||||
}
|
||||
|
||||
object ErrorSensorNoError extends ErrorSensor {
|
||||
override def id: String = "noError"
|
||||
override def isActive(te: IForestryMultiErrorSource): Boolean = te.getErrorStates.isEmpty
|
||||
override def isActive(te: IErrorLogicSource): Boolean = !te.getErrorLogic.hasErrors
|
||||
override def getUnLocalizedName: String = "gendustry.cover.error.none"
|
||||
}
|
||||
|
||||
object ErrorSensorAnyError extends ErrorSensor {
|
||||
override def id: String = "anyError"
|
||||
override def isActive(te: IForestryMultiErrorSource): Boolean = !te.getErrorStates.isEmpty
|
||||
override def isActive(te: IErrorLogicSource): Boolean = te.getErrorLogic.hasErrors
|
||||
override def getUnLocalizedName: String = "gendustry.cover.error.any"
|
||||
}
|
||||
|
||||
case class ErrorSensorForestry(state: IErrorState) extends ErrorSensor {
|
||||
override def id: String = state.getUniqueName
|
||||
override def isActive(te: IForestryMultiErrorSource): Boolean = te.getErrorStates.contains(state)
|
||||
override def isActive(te: IErrorLogicSource): Boolean = te.getErrorLogic.contains(state)
|
||||
override def getUnLocalizedName: String = "for." + state.getDescription
|
||||
}
|
||||
|
||||
object ErrorSensors {
|
||||
val errorStateRegistry = ForestryAPI.errorStateRegistry
|
||||
|
||||
val sensors = List(ErrorSensorAnyError, ErrorSensorNoError) ++ (List(
|
||||
"Forestry:invalidBiome",
|
||||
"Forestry:isRaining",
|
||||
@@ -62,7 +63,7 @@ object ErrorSensors {
|
||||
"Forestry:noSky",
|
||||
"Forestry:noSpace",
|
||||
"Forestry:noPower"
|
||||
) map (name => ErrorSensorForestry(ErrorStateRegistry.getErrorState(name))))
|
||||
) map (name => ErrorSensorForestry(errorStateRegistry.getErrorState(name))))
|
||||
|
||||
val idMap = sensors.map(x => x.id -> x).toMap
|
||||
}
|
||||
@@ -75,7 +76,7 @@ object ErrorSensorCover extends SimpleItem("ErrorSensorCover") with ItemCover {
|
||||
|
||||
override def getSpriteNumber = 0
|
||||
|
||||
override def isValidTile(te: TileCoverable, stack: ItemStack) = te.isInstanceOf[IForestryMultiErrorSource]
|
||||
override def isValidTile(te: TileCoverable, stack: ItemStack) = te.isInstanceOf[IErrorLogicSource]
|
||||
|
||||
def getErrorSensor(stack: ItemStack): Option[ErrorSensor] = {
|
||||
if (stack.hasTagCompound) {
|
||||
@@ -98,7 +99,7 @@ object ErrorSensorCover extends SimpleItem("ErrorSensorCover") with ItemCover {
|
||||
|
||||
override def isEmittingSignal(te: TileCoverable, side: ForgeDirection, cover: ItemStack): Boolean = {
|
||||
for {
|
||||
tile <- Misc.asInstanceOpt(te, classOf[IForestryMultiErrorSource])
|
||||
tile <- Misc.asInstanceOpt(te, classOf[IErrorLogicSource])
|
||||
sensor <- getErrorSensor(cover)
|
||||
} {
|
||||
if (sensor.isActive(tile)) return 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.bdew.gendustry.Gendustry
|
||||
import net.bdew.lib.Misc
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
@@ -35,13 +35,13 @@ 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 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))
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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.machines.apiary
|
||||
|
||||
import _root_.forestry.api.apiculture.IBeeRoot
|
||||
import forestry.api.genetics.{AlleleManager, IAllele}
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.minecraft.util.{ChatComponentTranslation, EnumChatFormatting}
|
||||
|
||||
object Sanity {
|
||||
var checkDone = false
|
||||
def check(house: TileApiary): Unit = {
|
||||
if (checkDone) return
|
||||
checkDone = true
|
||||
import scala.collection.JavaConversions._
|
||||
try {
|
||||
val bees = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees").asInstanceOf[IBeeRoot]
|
||||
val defGenome = bees.templateAsGenome(bees.getDefaultTemplate)
|
||||
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) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
val player = house.getWorld.getClosestPlayer(house.xCoord, house.yCoord, house.zCoord, 20)
|
||||
if (player != null) {
|
||||
player.addChatMessage(new ChatComponentTranslation(
|
||||
EnumChatFormatting.RED + "[Gendustry] WARNING! Possibly bugged mutations detected, check the log for details."))
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
case t: Throwable => Gendustry.logWarnException("Error in mutations sanity check", t)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,9 @@
|
||||
package net.bdew.gendustry.machines.apiary
|
||||
|
||||
import java.util
|
||||
import java.util.Locale
|
||||
import java.util.{Collections, Locale}
|
||||
|
||||
import com.mojang.authlib.GameProfile
|
||||
import forestry.api.apiculture._
|
||||
import forestry.api.arboriculture.EnumGermlingType
|
||||
import forestry.api.core._
|
||||
@@ -35,6 +36,7 @@ import net.bdew.lib.tile.TileExtended
|
||||
import net.bdew.lib.tile.inventory.{PersistentInventoryTile, SidedInventory}
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.ChunkCoordinates
|
||||
import net.minecraft.world.biome.BiomeGenBase
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
@@ -46,7 +48,10 @@ with TileKeepData
|
||||
with TilePowered
|
||||
with TileRSControllable
|
||||
with TileCoverable
|
||||
with IIndustrialApiary {
|
||||
with IIndustrialApiary
|
||||
with IBeeModifier
|
||||
with IBeeListener
|
||||
with IBeeHousingInventory {
|
||||
|
||||
object slots {
|
||||
val queen = 0
|
||||
@@ -66,7 +71,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)
|
||||
|
||||
@@ -107,11 +111,13 @@ 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()
|
||||
}
|
||||
)
|
||||
|
||||
sendClientUpdate.listen(tag => logic.syncToClient())
|
||||
|
||||
serverTick.listen(() => {
|
||||
|
||||
movePrincess = false
|
||||
@@ -119,27 +125,27 @@ 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
|
||||
if (getQueen == null) {
|
||||
guiProgress := 0
|
||||
} else {
|
||||
if (beeRoot.getType(getQueen) == EnumBeeType.PRINCESS)
|
||||
guiProgress := logic.getBeeProgressPercent / 100F
|
||||
else
|
||||
guiProgress := 1 - (logic.getBeeProgressPercent / 100F)
|
||||
}
|
||||
})
|
||||
|
||||
errorConditions.onChange.listen(() => {
|
||||
@@ -197,11 +203,15 @@ 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)
|
||||
@@ -209,17 +219,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())
|
||||
@@ -239,49 +255,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 = logic
|
||||
|
||||
@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 + 1, zCoord)
|
||||
override def canBlockSeeTheSky: Boolean = worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, 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)
|
||||
@@ -298,12 +299,6 @@ with IIndustrialApiary {
|
||||
return p == null
|
||||
}
|
||||
|
||||
override def validate() {
|
||||
super.validate()
|
||||
if (worldObj != null && !worldObj.isRemote)
|
||||
Sanity.check(this)
|
||||
}
|
||||
|
||||
override def isValidCover(side: ForgeDirection, cover: ItemStack) = true
|
||||
|
||||
override def afterTileBreakSave(t: NBTTagCompound): NBTTagCompound = {
|
||||
|
||||
@@ -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,6 +9,7 @@
|
||||
|
||||
package net.bdew.gendustry.machines.apiary
|
||||
|
||||
import net.bdew.gendustry.gui.Textures
|
||||
import net.bdew.lib.gui.widgets.Widget
|
||||
import net.bdew.lib.gui.{Point, Rect, Texture}
|
||||
import net.bdew.lib.{Client, Misc}
|
||||
@@ -22,16 +23,15 @@ class WidgetError(x: Int, y: Int, apiary: TileApiary) extends Widget {
|
||||
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)
|
||||
}
|
||||
val pos = ((Client.world.getTotalWorldTime / 40) % errors.size()).toInt
|
||||
errors.toList.sortBy(_.getID).apply(pos)
|
||||
}
|
||||
|
||||
override def draw(mouse: Point) {
|
||||
parent.drawTexture(rect, Texture(Texture.ITEMS, getDisplayedError.getIcon))
|
||||
if (apiary.errorConditions.isOk)
|
||||
parent.drawTexture(rect, Textures.errors.ok)
|
||||
else
|
||||
parent.drawTexture(rect, Texture(Texture.ITEMS, getDisplayedError.getIcon))
|
||||
}
|
||||
|
||||
override def handleTooltip(p: Point, tip: mutable.MutableList[String]) {
|
||||
|
||||
@@ -9,18 +9,52 @@
|
||||
|
||||
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.Event
|
||||
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
|
||||
changed()
|
||||
@@ -65,7 +99,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 = {
|
||||
|
||||
@@ -58,8 +58,8 @@ object GeneticsCache {
|
||||
|
||||
for ((_, root) <- AlleleManager.alleleRegistry.getSpeciesRoot; mutation <- root.getMutations(false)) {
|
||||
speciesResultMutations(mutation.getTemplate.apply(0).asInstanceOf[IAlleleSpecies]) += mutation
|
||||
speciesUsedMutations(mutation.getAllele0.asInstanceOf[IAlleleSpecies]) += mutation
|
||||
speciesUsedMutations(mutation.getAllele1.asInstanceOf[IAlleleSpecies]) += mutation
|
||||
speciesUsedMutations(mutation.getAllele0) += mutation
|
||||
speciesUsedMutations(mutation.getAllele1) += mutation
|
||||
}
|
||||
|
||||
Gendustry.logDebug("Mutations with multiple results from a single combination:")
|
||||
|
||||
Reference in new issue
Block a user