mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-19 03:49:18 +00:00
Added config option to disable mutations in the mutatron or force them to check requirements (closes #100)
This commit is contained in:
1 parent
cb5dc09cb2
commit
e2f2cd0c75
13 files changed
+213
-24
No files matched your search
@@ -143,6 +143,22 @@ cfg Items {
|
||||
}
|
||||
}
|
||||
|
||||
cfg Genetics {
|
||||
cfg MutatronOverrides {
|
||||
|
||||
// Keys are species UID
|
||||
// Values are: ENABLED/DISABLED/REQUIREMENTS
|
||||
// ENABLED will allow that mutation without checking requirements (this is the default)
|
||||
// DISABLED will disallow that mutation in the mutatron
|
||||
// REQUIREMENTS will check normal breeding requirements (only valid for bee species)
|
||||
|
||||
"forestry.speciesLeporine" = REQUIREMENTS
|
||||
"forestry.speciesMerry" = REQUIREMENTS
|
||||
"forestry.speciesTipsy" = REQUIREMENTS
|
||||
"forestry.speciesTricky" = REQUIREMENTS
|
||||
}
|
||||
}
|
||||
|
||||
cfg Power {
|
||||
RF_MJ_Ratio = 10 // 10 RF = 1 MJ
|
||||
EU_MJ_Ratio = 2.5 // 5 EU = 2 MJ
|
||||
|
||||
@@ -199,6 +199,8 @@ gendustry.req.humidity=Requires humidity: %s
|
||||
gendustry.req.biome=Requires biome: %s
|
||||
gendustry.req.block=Requires block: %s
|
||||
|
||||
gendustry.req.message=Special Requirements
|
||||
|
||||
# ==== BEE SPECIES ====
|
||||
gendustry.bees.species.black=Black
|
||||
gendustry.bees.species.red=Red
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IAdvancedMutatron extends IWorkerMachine {
|
||||
public interface IAdvancedMutatron extends IMutatron {
|
||||
/**
|
||||
* @return List of possible mutations for current inventory
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,16 @@ public interface IBlockAPI {
|
||||
*/
|
||||
IIndustrialApiary getIndustrialApiary(World w, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @return True if a valid mutatron
|
||||
*/
|
||||
boolean isMutatron(World w, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @return Mutatron interface
|
||||
*/
|
||||
IMutatron getMutatron(World w, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @return True if a valid Advanced mutatron
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IMutatron extends IWorkerMachine {
|
||||
/**
|
||||
* @return First input slot contents
|
||||
*/
|
||||
ItemStack getParent1();
|
||||
|
||||
/**
|
||||
* @return Second input slot contents
|
||||
*/
|
||||
ItemStack getParent2();
|
||||
|
||||
/**
|
||||
* @return Game profile of owner (or last user)
|
||||
*/
|
||||
GameProfile getOwner();
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package net.bdew.gendustry.apiimpl
|
||||
import net.bdew.gendustry.api.blocks.IBlockAPI
|
||||
import net.bdew.gendustry.machines.advmutatron.TileMutatronAdv
|
||||
import net.bdew.gendustry.machines.apiary.TileApiary
|
||||
import net.bdew.gendustry.machines.mutatron.TileMutatron
|
||||
import net.minecraft.world.World
|
||||
|
||||
object BlockApiImpl extends IBlockAPI {
|
||||
@@ -24,6 +25,12 @@ object BlockApiImpl extends IBlockAPI {
|
||||
override def getWorkerMachine(w: World, x: Int, y: Int, z: Int) =
|
||||
getTypedTileEntity(w, x, y, z, classOf[TileWorker]).orNull
|
||||
|
||||
override def isMutatron(w: World, x: Int, y: Int, z: Int) =
|
||||
getTypedTileEntity(w, x, y, z, classOf[TileMutatron]).isDefined
|
||||
|
||||
override def getMutatron(w: World, x: Int, y: Int, z: Int) =
|
||||
getTypedTileEntity(w, x, y, z, classOf[TileMutatron]).orNull
|
||||
|
||||
override def isAdvancedMutatron(w: World, x: Int, y: Int, z: Int) =
|
||||
getTypedTileEntity(w, x, y, z, classOf[TileMutatronAdv]).isDefined
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.compat
|
||||
|
||||
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 net.bdew.gendustry.api.blocks.IMutatron
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
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
|
||||
|
||||
override def getOwnerName: 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 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 addProduct(product: ItemStack, all: Boolean): Boolean = false
|
||||
|
||||
override def isSunlightSimulated: Boolean = false
|
||||
override def isSelfLighted: Boolean = false
|
||||
override def isHellish: Boolean = false
|
||||
override def isSealed: Boolean = false
|
||||
override def getProductionModifier(iBeeGenome: IBeeGenome, v: Float): Float = v
|
||||
override def getMutationModifier(iBeeGenome: IBeeGenome, iBeeGenome1: IBeeGenome, v: Float): Float = v
|
||||
override def getLifespanModifier(iBeeGenome: IBeeGenome, iBeeGenome1: IBeeGenome, v: Float): Float = v
|
||||
override def getGeneticDecay(iBeeGenome: IBeeGenome, v: Float): Float = v
|
||||
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 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)
|
||||
}
|
||||
@@ -13,14 +13,14 @@ import java.util.Random
|
||||
|
||||
import com.mojang.authlib.GameProfile
|
||||
import cpw.mods.fml.common.registry.GameRegistry
|
||||
import forestry.api.apiculture.{EnumBeeType, IBee, IBeeRoot}
|
||||
import forestry.api.apiculture._
|
||||
import forestry.api.arboriculture.{EnumGermlingType, ITree, ITreeRoot}
|
||||
import forestry.api.genetics._
|
||||
import forestry.api.lepidopterology.{EnumFlutterType, IButterflyRoot}
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.config.Items
|
||||
import net.bdew.gendustry.items.GeneTemplate
|
||||
import net.bdew.gendustry.machines.mutatron.MachineMutatron
|
||||
import net.bdew.gendustry.machines.mutatron.{MachineMutatron, MutationSetting}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.World
|
||||
@@ -51,7 +51,7 @@ object GeneticsHelper {
|
||||
return false
|
||||
}
|
||||
|
||||
def getValidMutations(fromStack: ItemStack, toStack: ItemStack): Seq[IMutation] = {
|
||||
def getValidMutations(fromStack: ItemStack, toStack: ItemStack, beeHousing: IBeeHousing): Seq[IMutation] = {
|
||||
val emptyMutations = Seq.empty[IMutation]
|
||||
|
||||
if (fromStack == null || toStack == null) return emptyMutations
|
||||
@@ -73,18 +73,26 @@ object GeneticsHelper {
|
||||
|
||||
val mutations = root.getCombinations(fromSpecies).asScala
|
||||
|
||||
return mutations.filter(checkMutation(_, fromSpecies, toSpecies)).toSeq
|
||||
return mutations.filter(checkMutation(_, fromSpecies, toSpecies)).toSeq filter { mutation =>
|
||||
(MachineMutatron.mutatronOverrides(getMutationSpecies(mutation).getUID), mutation) match {
|
||||
case (MutationSetting.ENABLED, _) => true
|
||||
case (MutationSetting.DISABLED, _) => false
|
||||
case (MutationSetting.REQUIREMENTS, beeMutation: IBeeMutation) =>
|
||||
beeMutation.getChance(beeHousing, fromSpecies, toSpecies, fromIndividual.getGenome, toIndividual.getGenome) > 0
|
||||
case _ => true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def isPotentialMutationPair(fromStack: ItemStack, toStack: ItemStack): Boolean = {
|
||||
def isPotentialMutationPair(fromStack: ItemStack, toStack: ItemStack, beeHousing: IBeeHousing): Boolean = {
|
||||
if (fromStack == null && toStack == null) return false
|
||||
if (toStack == null) return isValidItemForSlot(fromStack, 0)
|
||||
if (fromStack == null) return isValidItemForSlot(toStack, 1)
|
||||
return getValidMutations(fromStack, toStack).nonEmpty
|
||||
return getValidMutations(fromStack, toStack, beeHousing).nonEmpty
|
||||
}
|
||||
|
||||
def getMutationResult(fromStack: ItemStack, toStack: ItemStack): ItemStack = {
|
||||
val valid = getValidMutations(fromStack, toStack)
|
||||
def getMutationResult(fromStack: ItemStack, toStack: ItemStack, beeHousing: IBeeHousing): ItemStack = {
|
||||
val valid = getValidMutations(fromStack, toStack, beeHousing)
|
||||
if (valid.isEmpty) return null
|
||||
|
||||
val selected = if (valid.size > 1) {
|
||||
@@ -169,7 +177,7 @@ object GeneticsHelper {
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
root.getCombinations(sp1).asScala.filter(x => {
|
||||
checkMutation(x, sp1, sp2) && x.getTemplate()(0) == spR
|
||||
checkMutation(x, sp1, sp2) && getMutationSpecies(x) == spR
|
||||
}).foreach(tracker.registerMutation)
|
||||
}
|
||||
|
||||
@@ -215,6 +223,9 @@ object GeneticsHelper {
|
||||
map { x => x.ordinal() -> x }
|
||||
).toMap
|
||||
|
||||
def getMutationSpecies(m: IMutation) =
|
||||
m.getTemplate()(m.getRoot.getKaryotypeKey.ordinal()).asInstanceOf[IAlleleSpecies]
|
||||
|
||||
lazy val leafBlocks = Set(GameRegistry.findBlock("minecraft", "leaves"), GameRegistry.findBlock("minecraft", "leaves2"))
|
||||
|
||||
def getErsatzPollen(bl: Block, meta: Int): Option[IIndividual] = {
|
||||
@@ -232,7 +243,7 @@ object GeneticsHelper {
|
||||
Option(m.getSpecialConditions) map (_.toList) getOrElse List.empty
|
||||
} catch {
|
||||
case t: Throwable =>
|
||||
Gendustry.logWarnException("Error getting conditions of mutation %s + %s => %s", t, m.getAllele0.getUID, m.getAllele1.getUID, m.getTemplate.head.getUID)
|
||||
Gendustry.logWarnException("Error getting conditions of mutation %s + %s => %s", t, m.getAllele0.getUID, m.getAllele1.getUID, getMutationSpecies(m).getUID)
|
||||
List.empty
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ package net.bdew.gendustry.machines.advmutatron
|
||||
|
||||
import net.bdew.gendustry.api.blocks.IAdvancedMutatron
|
||||
import net.bdew.gendustry.apiimpl.TileWorker
|
||||
import net.bdew.gendustry.compat.FakeMutatronBeeHousing
|
||||
import net.bdew.gendustry.config.{Fluids, Items}
|
||||
import net.bdew.gendustry.forestry.GeneticsHelper
|
||||
import net.bdew.gendustry.power.TilePowered
|
||||
@@ -43,6 +44,12 @@ class TileMutatronAdv extends TileItemProcessor with TileWorker with TilePowered
|
||||
|
||||
def getTankFromDirection(dir: ForgeDirection): IFluidTank = tank
|
||||
|
||||
override def getParent1 = getStackInSlot(slots.inIndividual1)
|
||||
override def getParent2 = getStackInSlot(slots.inIndividual2)
|
||||
override def getOwner = lastPlayer.value
|
||||
|
||||
lazy val fakeBeeHousing = new FakeMutatronBeeHousing(this)
|
||||
|
||||
override def markDirty() {
|
||||
updateSelectors()
|
||||
super.markDirty()
|
||||
@@ -53,7 +60,7 @@ class TileMutatronAdv extends TileItemProcessor with TileWorker with TilePowered
|
||||
for (slot <- slots.selectors)
|
||||
inv(slot) = null
|
||||
selectedMutation := -1
|
||||
val valid = GeneticsHelper.getValidMutations(getStackInSlot(slots.inIndividual1), getStackInSlot(slots.inIndividual2))
|
||||
val valid = GeneticsHelper.getValidMutations(getStackInSlot(slots.inIndividual1), getStackInSlot(slots.inIndividual2), fakeBeeHousing)
|
||||
if (valid.nonEmpty) {
|
||||
for ((slot, mp) <- slots.selectors.zipWithIndex if valid.isDefinedAt(mp)) {
|
||||
inv(slot) = GeneticsHelper.getFinalMutationResult(valid(mp), getStackInSlot(slots.inIndividual1), false)
|
||||
@@ -103,9 +110,9 @@ class TileMutatronAdv extends TileItemProcessor with TileWorker with TilePowered
|
||||
override def isItemValidForSlot(slot: Int, stack: ItemStack): Boolean = {
|
||||
slot match {
|
||||
case 0 =>
|
||||
return GeneticsHelper.isPotentialMutationPair(stack, getStackInSlot(1))
|
||||
return GeneticsHelper.isPotentialMutationPair(stack, getStackInSlot(1), fakeBeeHousing)
|
||||
case 1 =>
|
||||
return GeneticsHelper.isPotentialMutationPair(getStackInSlot(0), stack)
|
||||
return GeneticsHelper.isPotentialMutationPair(getStackInSlot(0), stack, fakeBeeHousing)
|
||||
case 3 =>
|
||||
return stack.getItem == Items.labware
|
||||
case _ =>
|
||||
|
||||
@@ -61,7 +61,7 @@ with IIndustrialApiary {
|
||||
|
||||
val power = DataSlotPower("power", this)
|
||||
val errorState = DataSlotInt("error", this).setUpdate(UpdateKind.GUI, UpdateKind.SAVE, UpdateKind.WORLD)
|
||||
val owner = DataSlotGameProfile("owner", this).setUpdate(UpdateKind.SAVE)
|
||||
val owner = DataSlotGameProfile("getOwner", this).setUpdate(UpdateKind.SAVE)
|
||||
val guiProgress = DataSlotFloat("progress", this)
|
||||
val guiBreeding = DataSlotFloat("breeding", this)
|
||||
|
||||
|
||||
@@ -10,10 +10,16 @@
|
||||
package net.bdew.gendustry.machines.mutatron
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.bdew.gendustry.config.Tuning
|
||||
import net.bdew.lib.gui.GuiProvider
|
||||
import net.bdew.lib.machine.{Machine, ProcessorMachine}
|
||||
import net.bdew.lib.recipes.gencfg.EntryStr
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
|
||||
object MutationSetting extends Enumeration {
|
||||
val ENABLED, DISABLED, REQUIREMENTS = Value
|
||||
}
|
||||
|
||||
object MachineMutatron extends Machine("Mutatron", BlockMutatron) with GuiProvider with ProcessorMachine {
|
||||
def guiId = 2
|
||||
type TEClass = TileMutatron
|
||||
@@ -25,6 +31,15 @@ object MachineMutatron extends Machine("Mutatron", BlockMutatron) with GuiProvid
|
||||
lazy val deathChanceArtificial = tuning.getFloat("DeathChanceArtificial")
|
||||
lazy val secretChance = tuning.getFloat("SecretMutationChance")
|
||||
|
||||
lazy val mutatronOverrides =
|
||||
(for ((key, value) <- Tuning.getSection("Genetics").getSection("MutatronOverrides").filterType(classOf[EntryStr]))
|
||||
yield key -> (value.v.toUpperCase match {
|
||||
case "ENABLED" => MutationSetting.ENABLED
|
||||
case "DISABLED" => MutationSetting.DISABLED
|
||||
case "REQUIREMENTS" => MutationSetting.REQUIREMENTS
|
||||
case _ => MutationSetting.ENABLED
|
||||
})).toMap.withDefaultValue(MutationSetting.ENABLED)
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
def getGui(te: TileMutatron, player: EntityPlayer) = new GuiMutatron(te, player)
|
||||
def getContainer(te: TileMutatron, player: EntityPlayer) = new ContainerMutatron(te, player)
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
package net.bdew.gendustry.machines.mutatron
|
||||
|
||||
import net.bdew.gendustry.api.blocks.IMutatron
|
||||
import net.bdew.gendustry.apiimpl.TileWorker
|
||||
import net.bdew.gendustry.compat.FakeMutatronBeeHousing
|
||||
import net.bdew.gendustry.config.{Fluids, Items}
|
||||
import net.bdew.gendustry.forestry.GeneticsHelper
|
||||
import net.bdew.gendustry.power.TilePowered
|
||||
@@ -22,7 +24,7 @@ import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids._
|
||||
|
||||
class TileMutatron extends TileItemProcessor with TileWorker with TilePowered with ExposeTank with TileCoverable {
|
||||
class TileMutatron extends TileItemProcessor with TileWorker with TilePowered with ExposeTank with TileCoverable with IMutatron {
|
||||
lazy val cfg = MachineMutatron
|
||||
val outputSlots = Seq(slots.outIndividual)
|
||||
|
||||
@@ -40,6 +42,12 @@ class TileMutatron extends TileItemProcessor with TileWorker with TilePowered wi
|
||||
|
||||
def getTankFromDirection(dir: ForgeDirection): IFluidTank = tank
|
||||
|
||||
override def getParent1 = getStackInSlot(slots.inIndividual1)
|
||||
override def getParent2 = getStackInSlot(slots.inIndividual2)
|
||||
override def getOwner = lastPlayer.value
|
||||
|
||||
lazy val fakeBeeHousing = new FakeMutatronBeeHousing(this)
|
||||
|
||||
def canStart =
|
||||
getStackInSlot(slots.inIndividual1) != null &&
|
||||
getStackInSlot(slots.inIndividual2) != null &&
|
||||
@@ -48,7 +56,7 @@ class TileMutatron extends TileItemProcessor with TileWorker with TilePowered wi
|
||||
|
||||
def tryStart(): Boolean = {
|
||||
if (canStart) {
|
||||
output := GeneticsHelper.getMutationResult(getStackInSlot(slots.inIndividual1), getStackInSlot(slots.inIndividual2))
|
||||
output := GeneticsHelper.getMutationResult(getStackInSlot(slots.inIndividual1), getStackInSlot(slots.inIndividual2), fakeBeeHousing)
|
||||
tank.drain(cfg.mutagenPerItem, true)
|
||||
if (lastPlayer.value != null)
|
||||
GeneticsHelper.addMutationToTracker(inv(slots.inIndividual1), inv(slots.inIndividual2), output, lastPlayer, worldObj)
|
||||
@@ -63,9 +71,9 @@ class TileMutatron extends TileItemProcessor with TileWorker with TilePowered wi
|
||||
override def isItemValidForSlot(slot: Int, stack: ItemStack): Boolean = {
|
||||
slot match {
|
||||
case slots.inIndividual1 =>
|
||||
return GeneticsHelper.isPotentialMutationPair(stack, getStackInSlot(slots.inIndividual2))
|
||||
return GeneticsHelper.isPotentialMutationPair(stack, getStackInSlot(slots.inIndividual2), fakeBeeHousing)
|
||||
case slots.inIndividual2 =>
|
||||
return GeneticsHelper.isPotentialMutationPair(getStackInSlot(slots.inIndividual1), stack)
|
||||
return GeneticsHelper.isPotentialMutationPair(getStackInSlot(slots.inIndividual1), stack, fakeBeeHousing)
|
||||
case slots.inLabware =>
|
||||
return stack.getItem == Items.labware
|
||||
case _ =>
|
||||
|
||||
@@ -17,13 +17,15 @@ import forestry.api.arboriculture.{EnumGermlingType, ITreeRoot}
|
||||
import forestry.api.genetics.{AlleleManager, IMutation, ISpeciesRoot}
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.config.{Fluids, Items}
|
||||
import net.bdew.gendustry.machines.mutatron.MachineMutatron
|
||||
import net.bdew.gendustry.forestry.GeneticsHelper
|
||||
import net.bdew.gendustry.machines.mutatron.{MachineMutatron, MutationSetting}
|
||||
import net.bdew.gendustry.misc.GeneticsCache
|
||||
import net.bdew.gendustry.nei.helpers.{FluidComponent, PowerComponent}
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.gui.Rect
|
||||
import net.bdew.lib.items.{IStack, IStackBlock}
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.EnumChatFormatting
|
||||
import net.minecraftforge.fluids.FluidStack
|
||||
|
||||
class MutatronHandler extends BaseRecipeHandler(5, 13) {
|
||||
@@ -32,7 +34,7 @@ class MutatronHandler extends BaseRecipeHandler(5, 13) {
|
||||
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
class MutatronRecipe(mutation: IMutation) extends CachedRecipeWithComponents {
|
||||
class MutatronRecipe(val mutation: IMutation) extends CachedRecipeWithComponents {
|
||||
val getResult = position(getRecipeStack(2, mutation), 142, 41)
|
||||
val in1 = position(getRecipeStack(0, mutation), 60, 30)
|
||||
val in2 = position(getRecipeStack(1, mutation), 60, 53)
|
||||
@@ -63,6 +65,22 @@ class MutatronHandler extends BaseRecipeHandler(5, 13) {
|
||||
}
|
||||
}
|
||||
|
||||
def canShowMutation(mutation: IMutation) = {
|
||||
MachineMutatron.mutatronOverrides(GeneticsHelper.getMutationSpecies(mutation).getUID) match {
|
||||
case MutationSetting.ENABLED => true
|
||||
case MutationSetting.DISABLED => false
|
||||
case MutationSetting.REQUIREMENTS => true
|
||||
}
|
||||
}
|
||||
|
||||
def getMutationRequirementsDisplay(mutation: IMutation) = {
|
||||
if (MachineMutatron.mutatronOverrides(GeneticsHelper.getMutationSpecies(mutation).getUID) == MutationSetting.REQUIREMENTS)
|
||||
List(EnumChatFormatting.RED.toString + EnumChatFormatting.UNDERLINE + Misc.toLocal("gendustry.req.message")) ++
|
||||
(GeneticsHelper.safeMutationConditions(mutation) map (EnumChatFormatting.RED + _))
|
||||
else
|
||||
List()
|
||||
}
|
||||
|
||||
def getRecipe(i: Int) = arecipes.get(i).asInstanceOf[MutatronRecipe]
|
||||
|
||||
override def loadTransferRects() {
|
||||
@@ -70,7 +88,7 @@ class MutatronHandler extends BaseRecipeHandler(5, 13) {
|
||||
}
|
||||
|
||||
def addAllRecipes() {
|
||||
for ((_, root) <- AlleleManager.alleleRegistry.getSpeciesRoot; mutation <- root.getMutations(false)) {
|
||||
for ((_, root) <- AlleleManager.alleleRegistry.getSpeciesRoot; mutation <- root.getMutations(false) if canShowMutation(mutation)) {
|
||||
arecipes.add(new MutatronRecipe(mutation))
|
||||
}
|
||||
}
|
||||
@@ -83,7 +101,7 @@ class MutatronHandler extends BaseRecipeHandler(5, 13) {
|
||||
case ("item", Seq(x: ItemStack)) =>
|
||||
val individual = AlleleManager.alleleRegistry.getIndividual(x)
|
||||
if (individual != null) {
|
||||
for (mutation <- GeneticsCache.speciesUsedMutations(individual.getGenome.getPrimary))
|
||||
for (mutation <- GeneticsCache.speciesUsedMutations(individual.getGenome.getPrimary) if canShowMutation(mutation))
|
||||
arecipes.add(new MutatronRecipe(mutation))
|
||||
}
|
||||
case ("Mutatron", _) => addAllRecipes()
|
||||
@@ -95,7 +113,7 @@ class MutatronHandler extends BaseRecipeHandler(5, 13) {
|
||||
case ("item", Seq(x: ItemStack)) =>
|
||||
val individual = AlleleManager.alleleRegistry.getIndividual(x)
|
||||
if (individual != null) {
|
||||
for (mutation <- GeneticsCache.speciesResultMutations(individual.getGenome.getPrimary))
|
||||
for (mutation <- GeneticsCache.speciesResultMutations(individual.getGenome.getPrimary) if canShowMutation(mutation))
|
||||
arecipes.add(new MutatronRecipe(mutation))
|
||||
}
|
||||
case ("Mutatron", _) => addAllRecipes()
|
||||
@@ -108,6 +126,7 @@ class MutatronHandler extends BaseRecipeHandler(5, 13) {
|
||||
if (stack == getRecipe(recipe).getResult.item) {
|
||||
tip += Misc.toLocalF("gendustry.label.mutatron.degrade", MachineMutatron.degradeChanceNatural.toInt)
|
||||
tip += Misc.toLocalF("gendustry.label.mutatron.death", MachineMutatron.deathChanceArtificial.toInt)
|
||||
tip ++= getMutationRequirementsDisplay(getRecipe(recipe).mutation)
|
||||
}
|
||||
super.handleItemTooltip(gui, stack, tip, recipe)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user