diff --git a/src/net/bdew/gendustry/nei/BaseRecipeHandler.scala b/src/net/bdew/gendustry/nei/BaseRecipeHandler.scala deleted file mode 100644 index 6f79268..0000000 --- a/src/net/bdew/gendustry/nei/BaseRecipeHandler.scala +++ /dev/null @@ -1,61 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import codechicken.nei.recipe.{GuiRecipe, TemplateRecipeHandler} -import net.bdew.lib.gui._ -import codechicken.core.gui.GuiDraw -import org.lwjgl.opengl.GL11 -import codechicken.core.gui.GuiDraw._ -import net.bdew.gendustry.nei.helpers.RecipeComponent -import java.util -import net.minecraft.item.ItemStack -import codechicken.nei.PositionedStack -import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect -import java.awt.Rectangle - -abstract class BaseRecipeHandler(val offX: Int, val offY: Int) extends TemplateRecipeHandler { - - abstract class CachedRecipeWithComponents extends CachedRecipe { - var components = List.empty[RecipeComponent] - def position(s: ItemStack, x: Int, y: Int) = new PositionedStack(s, x - offX, y - offY) - } - - def addTransferRect(r: Rect, id: String) { - transferRects.add(new RecipeTransferRect(new Rectangle(r.x.round - offX, r.y.round - offY, r.w.round, r.h.round), id)) - } - - override def drawExtras(recipe: Int) { - for (component <- arecipes.get(recipe).asInstanceOf[CachedRecipeWithComponents].components) - component.render(Point(offX, offY)) - super.drawExtras(recipe) - } - - override def mouseClicked(gui: GuiRecipe, button: Int, recipe: Int): Boolean = { - val mrel = GuiDraw.getMousePosition - gui.getRecipePosition(recipe) +(offX, offY) -(gui.guiLeft, gui.guiTop) - for (component <- arecipes.get(recipe).asInstanceOf[CachedRecipeWithComponents].components) - if (component.rect.contains(mrel) && component.mouseClick(button)) return true - super.mouseClicked(gui, button, recipe) - } - - override def handleTooltip(gui: GuiRecipe, currenttip: util.List[String], recipe: Int) = { - import scala.collection.JavaConversions._ - val mrel = GuiDraw.getMousePosition - gui.getRecipePosition(recipe) +(offX, offY) -(gui.guiLeft, gui.guiTop) - for (component <- arecipes.get(recipe).asInstanceOf[CachedRecipeWithComponents].components) - if (component.rect.contains(mrel)) currenttip.addAll(component.getTooltip) - super.handleTooltip(gui, currenttip, recipe) - } - - override def drawBackground(recipe: Int) { - GL11.glColor4f(1, 1, 1, 1) - changeTexture(getGuiTexture) - drawTexturedModalRect(0, 0, offX, offY, 166, 65) - } -} diff --git a/src/net/bdew/gendustry/nei/ExtractorHandler.scala b/src/net/bdew/gendustry/nei/ExtractorHandler.scala deleted file mode 100644 index 7530deb..0000000 --- a/src/net/bdew/gendustry/nei/ExtractorHandler.scala +++ /dev/null @@ -1,105 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.gendustry.Gendustry -import net.bdew.lib.gui.Rect -import net.bdew.gendustry.config.{Items, Fluids, Machines} -import net.minecraft.item.ItemStack -import net.minecraftforge.fluids.FluidStack -import net.bdew.gendustry.fluids.LiquidDNASources -import net.bdew.gendustry.nei.helpers.{PowerComponent, FluidComponent} -import net.bdew.lib.Misc -import codechicken.nei.recipe.GuiRecipe -import java.util -import forestry.api.genetics.{IAlleleSpecies, AlleleManager} -import forestry.api.arboriculture.{EnumGermlingType, ITreeRoot} -import forestry.api.apiculture.{EnumBeeType, IBeeRoot} -import forestry.api.lepidopterology.{EnumFlutterType, IButterflyRoot} - -class ExtractorHandler extends BaseRecipeHandler(5, 13) { - val dnaRect = new Rect(152, 19, 16, 58) - val mjRect = new Rect(8, 19, 16, 58) - - import scala.collection.JavaConversions._ - - class ExtractorRecipe(val in: ItemStack, val out: Int) extends CachedRecipeWithComponents { - - val inPositioned = position(in, 44, 41) - val labware = position(new ItemStack(Items.labware), 94, 19) - val getResult = null - - components :+= new FluidComponent(dnaRect, new FluidStack(Fluids.dna, out), Machines.extractor.tankSize) - components :+= new PowerComponent(mjRect, Machines.extractor.mjPerItem, Machines.extractor.maxStoredEnergy) - - override def getOtherStacks = List(inPositioned, labware) - } - - def getRecipe(i: Int) = arecipes.get(i).asInstanceOf[ExtractorRecipe] - - override def loadTransferRects() { - addTransferRect(Rect(79, 41, 53, 15), "Extractor") - } - - def getRecipeIndividuals(sp: IAlleleSpecies) = { - val root = sp.getRoot - val indiv = root.templateAsIndividual(root.getTemplate(sp.getUID)) - indiv.analyze() - root match { - case bees: IBeeRoot => - List( - bees.getMemberStack(indiv, EnumBeeType.PRINCESS.ordinal()), - bees.getMemberStack(indiv, EnumBeeType.QUEEN.ordinal()), - bees.getMemberStack(indiv, EnumBeeType.DRONE.ordinal()) - ) - case trees: ITreeRoot => - List( - trees.getMemberStack(indiv, EnumGermlingType.POLLEN.ordinal()), - trees.getMemberStack(indiv, EnumGermlingType.SAPLING.ordinal()) - ) - case butterflies: IButterflyRoot => - List( - butterflies.getMemberStack(indiv, EnumFlutterType.BUTTERFLY.ordinal()), - butterflies.getMemberStack(indiv, EnumFlutterType.SERUM.ordinal()), - butterflies.getMemberStack(indiv, EnumFlutterType.CATERPILLAR.ordinal()) - ) - } - } - - def addAllRecipes() { - val species = Misc.filterType(AlleleManager.alleleRegistry.getRegisteredAlleles.values(), classOf[IAlleleSpecies]) - val stacks = species.map(getRecipeIndividuals).flatten.filter(LiquidDNASources.getValue(_) > 0) - stacks.foreach(x => arecipes.add(new ExtractorRecipe(x, LiquidDNASources.getValue(x)))) - } - - override def loadCraftingRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("liquid", Seq(x: FluidStack)) if x.fluidID == Fluids.dna.getID => addAllRecipes() - case ("item", Seq(x: ItemStack)) if x.itemID == Fluids.dna.getBlockID => addAllRecipes() - case ("Extractor", _) => addAllRecipes() - } - } - - override def loadUsageRecipes(stack: ItemStack) { - val res = LiquidDNASources.getValue(stack) - if (res > 0) { - arecipes.add(new ExtractorRecipe(stack, res)) - } - } - - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, currenttip: util.List[String], recipe: Int): util.List[String] = { - if (stack == getRecipe(recipe).labware.item) - currenttip.add(Misc.toLocalF("gendustry.label.consume", Machines.extractor.labwareConsumeChance.toInt)) - super.handleItemTooltip(gui, stack, currenttip, recipe) - } - - def getGuiTexture = Gendustry.modId + ":textures/gui/extractor.png" - def getRecipeName = Misc.toLocal("tile.gendustry.extractor.name") -} diff --git a/src/net/bdew/gendustry/nei/ImprinterHandler.scala b/src/net/bdew/gendustry/nei/ImprinterHandler.scala deleted file mode 100644 index ccf7b94..0000000 --- a/src/net/bdew/gendustry/nei/ImprinterHandler.scala +++ /dev/null @@ -1,108 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.lib.gui.Rect -import net.bdew.gendustry.config.{Items, Machines} -import net.bdew.gendustry.nei.helpers.PowerComponent -import forestry.api.genetics._ -import forestry.api.apiculture.{EnumBeeType, IBeeRoot} -import forestry.api.arboriculture.{EnumGermlingType, ITreeRoot} -import net.minecraft.item.ItemStack -import net.bdew.gendustry.Gendustry -import codechicken.nei.recipe.GuiRecipe -import java.util -import net.bdew.lib.Misc -import net.bdew.gendustry.forestry.GeneSampleInfo -import scala.Some -import forestry.api.lepidopterology.IButterflyRoot - -class ImprinterHandler extends BaseRecipeHandler(5, 13) { - val mutagenRect = new Rect(32, 19, 16, 58) - val mjRect = new Rect(8, 19, 16, 58) - - import scala.collection.JavaConversions._ - - class ImprinterRecipe(tpl: ItemStack) extends CachedRecipeWithComponents { - val getResult = position(getExampleStack(tpl, true), 137, 49) - val input = position(getExampleStack(tpl, false), 41, 49) - val template = position(tpl, 74, 28) - val labware = position(new ItemStack(Items.labware), 98, 28) - - components :+= new PowerComponent(mjRect, Machines.imprinter.mjPerItem, Machines.imprinter.maxStoredEnergy) - - override def getOtherStacks = List(input, template, labware) - } - - def getExampleStack(template: ItemStack, modded: Boolean): ItemStack = { - val root = Items.geneTemplate.getSpecies(template) - - val tpl = root match { - case bees: IBeeRoot => bees.getTemplate("forestry.speciesForest").clone() - case trees: ITreeRoot => trees.getTemplate("forestry.treeOak").clone() - case flies: IButterflyRoot => flies.getTemplate("forestry.lepiCabbageWhite").clone() - } - - if (modded) { - for (sample <- Items.geneTemplate.getSamples(template)) - tpl(sample.chromosome) = sample.allele - } - - val indiv = root.templateAsIndividual(tpl) - indiv.analyze() - - root match { - case bees: IBeeRoot => bees.getMemberStack(indiv, EnumBeeType.PRINCESS.ordinal()) - case trees: ITreeRoot => trees.getMemberStack(indiv, EnumGermlingType.SAPLING.ordinal()) - case flies: IButterflyRoot => flies.getMemberStack(indiv, 0) - } - } - - def getRecipe(i: Int) = arecipes.get(i).asInstanceOf[ImprinterRecipe] - - override def loadTransferRects() { - addTransferRect(Rect(63, 49, 66, 15), "Imprinter") - } - - def addExample() { - val bees = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees") - val cult = AlleleManager.alleleRegistry.getAllele("forestry.speciesCultivated") - val template = new ItemStack(Items.geneTemplate) - Items.geneTemplate.addSample(template, GeneSampleInfo(bees, 0, cult)) - arecipes.add(new ImprinterRecipe(template)) - } - - override def loadUsageRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("item", Seq(x: ItemStack)) if x.itemID == Items.labware.itemID => addExample() - case ("item", Seq(stack: ItemStack)) if stack.itemID == Items.geneTemplate.itemID => - if (Items.geneTemplate.getSpecies(stack) == null) - addExample() - else - arecipes.add(new ImprinterRecipe(stack)) - case ("Imprinter", _) => addExample() - } - } - - override def loadCraftingRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("Imprinter", _) => addExample() - } - } - - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, currenttip: util.List[String], recipe: Int): util.List[String] = { - if (stack == getRecipe(recipe).labware.item) - currenttip += Misc.toLocalF("gendustry.label.consume", Machines.mutatron.labwareConsumeChance.toInt) - super.handleItemTooltip(gui, stack, currenttip, recipe) - } - - def getGuiTexture = Gendustry.modId + ":textures/gui/imprinter.png" - def getRecipeName = Misc.toLocal("tile.gendustry.imprinter.name") -} diff --git a/src/net/bdew/gendustry/nei/LiquifierHandler.scala b/src/net/bdew/gendustry/nei/LiquifierHandler.scala deleted file mode 100644 index cee6def..0000000 --- a/src/net/bdew/gendustry/nei/LiquifierHandler.scala +++ /dev/null @@ -1,66 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.gendustry.Gendustry -import net.bdew.lib.gui.Rect -import net.bdew.gendustry.config.{Fluids, Machines} -import net.minecraft.item.ItemStack -import net.minecraftforge.fluids.FluidStack -import net.bdew.gendustry.fluids.ProteinSources -import net.bdew.gendustry.nei.helpers.{PowerComponent, FluidComponent} -import net.bdew.lib.Misc - -class LiquifierHandler extends BaseRecipeHandler(5, 13) { - val proteinRect = new Rect(152, 19, 16, 58) - val mjRect = new Rect(8, 19, 16, 58) - - class LiquifierRecipe(val in: ItemStack, val out: Int) extends CachedRecipeWithComponents { - - import scala.collection.JavaConversions._ - - val inPositioned = position(in, 44, 41) - val getResult = null - - components :+= new FluidComponent(proteinRect, new FluidStack(Fluids.protein, out), Machines.liquifier.tankSize) - components :+= new PowerComponent(mjRect, Machines.liquifier.mjPerItem, Machines.liquifier.maxStoredEnergy) - - override def getOtherStacks = List(inPositioned) - } - - def getRecipe(i: Int) = arecipes.get(i).asInstanceOf[LiquifierRecipe] - - override def loadTransferRects() { - addTransferRect(Rect(79, 41, 53, 15), "Liquifier") - } - - def addAllRecipes() { - for ((id, vals) <- ProteinSources.values; (meta, out) <- vals) - arecipes.add(new LiquifierRecipe(new ItemStack(id, 1, meta), out)) - } - - override def loadCraftingRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("liquid", Seq(x: FluidStack)) if x.fluidID == Fluids.protein.getID => addAllRecipes() - case ("item", Seq(x: ItemStack)) if x.itemID == Fluids.protein.getBlockID => addAllRecipes() - case ("Liquifier", _) => addAllRecipes() - } - } - - override def loadUsageRecipes(stack: ItemStack) { - val res = ProteinSources.getValue(stack) - if (res > 0) { - arecipes.add(new LiquifierRecipe(stack, res)) - } - } - - def getGuiTexture = Gendustry.modId + ":textures/gui/liquifier.png" - def getRecipeName = Misc.toLocal("tile.gendustry.liquifier.name") -} diff --git a/src/net/bdew/gendustry/nei/MutagenProducerHandler.scala b/src/net/bdew/gendustry/nei/MutagenProducerHandler.scala deleted file mode 100644 index 140c2c9..0000000 --- a/src/net/bdew/gendustry/nei/MutagenProducerHandler.scala +++ /dev/null @@ -1,66 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.gendustry.Gendustry -import net.bdew.lib.gui.Rect -import net.bdew.gendustry.config.{Fluids, Machines} -import net.minecraft.item.ItemStack -import net.minecraftforge.fluids.FluidStack -import net.bdew.gendustry.fluids.MutagenSources -import net.bdew.gendustry.nei.helpers.{PowerComponent, FluidComponent} -import net.bdew.lib.Misc - -class MutagenProducerHandler extends BaseRecipeHandler(5, 13) { - val mutagenRect = new Rect(152, 19, 16, 58) - val mjRect = new Rect(8, 19, 16, 58) - - class MutagenProducerRecipe(val in: ItemStack, val out: Int) extends CachedRecipeWithComponents { - - import scala.collection.JavaConversions._ - - val inPositioned = position(in, 44, 41) - val getResult = null - - components :+= new FluidComponent(mutagenRect, new FluidStack(Fluids.mutagen, out), Machines.mutagenProducer.tankSize) - components :+= new PowerComponent(mjRect, Machines.mutagenProducer.mjPerItem, Machines.mutagenProducer.maxStoredEnergy) - - override def getOtherStacks = List(inPositioned) - } - - def getRecipe(i: Int) = arecipes.get(i).asInstanceOf[MutagenProducerRecipe] - - override def loadTransferRects() { - addTransferRect(Rect(79, 41, 53, 15), "MutagenProducer") - } - - def addAllRecipes() { - for ((id, vals) <- MutagenSources.values; (meta, out) <- vals) - arecipes.add(new MutagenProducerRecipe(new ItemStack(id, 1, meta), out)) - } - - override def loadCraftingRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("liquid", Seq(x: FluidStack)) if x.fluidID == Fluids.mutagen.getID => addAllRecipes() - case ("item", Seq(x: ItemStack)) if x.itemID == Fluids.mutagen.getBlockID => addAllRecipes() - case ("MutagenProducer", _) => addAllRecipes() - } - } - - override def loadUsageRecipes(stack: ItemStack) { - val res = MutagenSources.getValue(stack) - if (res > 0) { - arecipes.add(new MutagenProducerRecipe(stack, res)) - } - } - - def getGuiTexture = Gendustry.modId + ":textures/gui/mutagenproducer.png" - def getRecipeName = Misc.toLocal("tile.gendustry.mutagen.producer.name") -} diff --git a/src/net/bdew/gendustry/nei/MutatronHandler.scala b/src/net/bdew/gendustry/nei/MutatronHandler.scala deleted file mode 100644 index 7a9c879..0000000 --- a/src/net/bdew/gendustry/nei/MutatronHandler.scala +++ /dev/null @@ -1,113 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.lib.gui.Rect -import net.bdew.gendustry.config.{Fluids, Items, Machines} -import net.minecraftforge.fluids.FluidStack -import net.bdew.gendustry.nei.helpers.{PowerComponent, FluidComponent} -import forestry.api.genetics.{AlleleManager, ISpeciesRoot, IMutation} -import forestry.api.apiculture.{EnumBeeType, IBeeRoot} -import forestry.api.arboriculture.{EnumGermlingType, ITreeRoot} -import net.minecraft.item.ItemStack -import net.bdew.gendustry.Gendustry -import codechicken.nei.recipe.GuiRecipe -import java.util -import net.bdew.lib.Misc - -class MutatronHandler extends BaseRecipeHandler(5, 13) { - val mutagenRect = new Rect(32, 19, 16, 58) - val mjRect = new Rect(8, 19, 16, 58) - - import scala.collection.JavaConversions._ - - class MutatronRecipe(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) - val labware = position(new ItemStack(Items.labware), 98, 17) - - components :+= new FluidComponent(mutagenRect, new FluidStack(Fluids.mutagen, Machines.mutatron.mutagenPerItem), Machines.mutatron.tankSize) - components :+= new PowerComponent(mjRect, Machines.mutatron.mjPerItem, Machines.mutatron.maxStoredEnergy) - - override def getOtherStacks = List(in1, in2, labware) - } - - def getRecipeStack(slot: Int, mutation: IMutation): ItemStack = { - val root = mutation.getRoot - val individual = slot match { - case 0 => root.templateAsIndividual(root.getTemplate(mutation.getAllele0.getUID)) - case 1 => root.templateAsIndividual(root.getTemplate(mutation.getAllele1.getUID)) - case 2 => root.templateAsIndividual(mutation.getTemplate) - } - individual.analyze() - return (root, slot) match { - case (bees: IBeeRoot, 0) => bees.getMemberStack(individual, EnumBeeType.PRINCESS.ordinal()) - case (bees: IBeeRoot, 1) => bees.getMemberStack(individual, EnumBeeType.DRONE.ordinal()) - case (bees: IBeeRoot, 2) => bees.getMemberStack(individual, EnumBeeType.QUEEN.ordinal()) - case (trees: ITreeRoot, 0) => trees.getMemberStack(individual, EnumGermlingType.SAPLING.ordinal()) - case (trees: ITreeRoot, 1) => trees.getMemberStack(individual, EnumGermlingType.POLLEN.ordinal()) - case (trees: ITreeRoot, 2) => trees.getMemberStack(individual, EnumGermlingType.SAPLING.ordinal()) - case (root: ISpeciesRoot, _) => root.getMemberStack(individual, 0) - } - } - - def getRecipe(i: Int) = arecipes.get(i).asInstanceOf[MutatronRecipe] - - override def loadTransferRects() { - addTransferRect(Rect(89, 41, 40, 15), "Mutatron") - } - - def addAllRecipes() { - for ((_, root) <- AlleleManager.alleleRegistry.getSpeciesRoot; mutation <- root.getMutations(false)) { - arecipes.add(new MutatronRecipe(mutation)) - } - } - - override def loadUsageRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("liquid", Seq(x: FluidStack)) if x.fluidID == Fluids.mutagen.getID => addAllRecipes() - case ("item", Seq(x: ItemStack)) if x.itemID == Fluids.mutagen.getBlockID => addAllRecipes() - case ("item", Seq(x: ItemStack)) if x.itemID == Items.labware.itemID => addAllRecipes() - case ("item", Seq(x: ItemStack)) => - val individual = AlleleManager.alleleRegistry.getIndividual(x) - if (individual != null) { - for (mutation <- NEICache.speciesUsedMutations(individual.getGenome.getPrimary)) - arecipes.add(new MutatronRecipe(mutation)) - } - case ("Mutatron", _) => addAllRecipes() - } - } - - override def loadCraftingRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("item", Seq(x: ItemStack)) => - val individual = AlleleManager.alleleRegistry.getIndividual(x) - if (individual != null) { - for (mutation <- NEICache.speciesResultMutations(individual.getGenome.getPrimary)) - arecipes.add(new MutatronRecipe(mutation)) - } - case ("Mutatron", _) => addAllRecipes() - } - } - - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, currenttip: util.List[String], recipe: Int): util.List[String] = { - if (stack == getRecipe(recipe).labware.item) - currenttip += Misc.toLocalF("gendustry.label.consume", Machines.mutatron.labwareConsumeChance.toInt) - if (stack == getRecipe(recipe).getResult.item) { - currenttip += Misc.toLocalF("gendustry.label.mutatron.degrade", Machines.mutatron.degradeChanceNatural.toInt) - currenttip += Misc.toLocalF("gendustry.label.mutatron.death", Machines.mutatron.deathChanceArtificial.toInt) - } - super.handleItemTooltip(gui, stack, currenttip, recipe) - } - - def getGuiTexture = Gendustry.modId + ":textures/gui/mutatron.png" - def getRecipeName = Misc.toLocal("tile.gendustry.mutatron.name") -} diff --git a/src/net/bdew/gendustry/nei/NEICache.scala b/src/net/bdew/gendustry/nei/NEICache.scala deleted file mode 100644 index d5c8dbf..0000000 --- a/src/net/bdew/gendustry/nei/NEICache.scala +++ /dev/null @@ -1,80 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import forestry.api.genetics._ -import net.bdew.lib.Misc -import net.bdew.gendustry.Gendustry -import net.bdew.gendustry.forestry.GeneSampleInfo - -object NEICache { - - implicit object MutationOrdering extends Ordering[IMutation] { - def compare(x: IMutation, y: IMutation): Int = - if (x.getRoot != y.getRoot) - x.getRoot.getUID.compareTo(y.getRoot.getUID) - else if (x.getTemplate.apply(0).getUID != y.getTemplate.apply(0).getUID) - x.getTemplate.apply(0).getUID.compareTo(y.getTemplate.apply(0).getUID) - else if (x.getAllele0 != y.getAllele0) - x.getAllele0.getUID.compareTo(y.getAllele0.getUID) - else - x.getAllele1.getUID.compareTo(y.getAllele1.getUID) - } - - implicit object SpeciesOrdering extends Ordering[IAlleleSpecies] { - def compare(x: IAlleleSpecies, y: IAlleleSpecies): Int = - if (x.getRoot != y.getRoot) - x.getRoot.getUID.compareTo(y.getRoot.getUID) - else - x.getUID.compareTo(y.getUID) - } - - implicit object SampleOrdering extends Ordering[GeneSampleInfo] { - def compare(x: GeneSampleInfo, y: GeneSampleInfo): Int = - if (x.root != y.root) - x.root.getUID.compareTo(y.root.getUID) - else if (x.chromosome != y.chromosome) - x.chromosome.compareTo(y.chromosome) - else - x.allele.getUID.compareTo(y.allele.getUID) - } - - val speciesResultMutations = collection.mutable.Map.empty[IAlleleSpecies, collection.SortedSet[IMutation]].withDefault(x => collection.SortedSet.empty[IMutation]) - val speciesUsedMutations = collection.mutable.Map.empty[IAlleleSpecies, collection.SortedSet[IMutation]].withDefault(x => collection.SortedSet.empty[IMutation]) - val speciesChromosomes = collection.mutable.Map.empty[GeneSampleInfo, collection.SortedSet[IAlleleSpecies]].withDefault(x => collection.SortedSet.empty[IAlleleSpecies]) - var geneSamples = collection.SortedSet.empty[GeneSampleInfo] - - def load() { - import scala.collection.JavaConversions._ - - Gendustry.logInfo("Preparing genetics cache ...") - - 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 - } - - Gendustry.logInfo("%d mutation outputs", speciesResultMutations.size) - Gendustry.logInfo("%d mutation inputs", speciesUsedMutations.size) - - for (species <- Misc.filterType(AlleleManager.alleleRegistry.getRegisteredAlleles.values(), classOf[IAlleleSpecies])) { - for ((allele, chromosome) <- species.getRoot.getTemplate(species.getUID).zipWithIndex) { - if (allele != null && !AlleleManager.alleleRegistry.isBlacklisted(allele.getUID)) - speciesChromosomes(GeneSampleInfo(species.getRoot, chromosome, allele)) += species - } - } - - geneSamples ++= speciesChromosomes.keys - - Gendustry.logInfo("%d chromosomes", speciesChromosomes.size) - Gendustry.logInfo("Done") - } -} diff --git a/src/net/bdew/gendustry/nei/NEIGendustryConfig.scala b/src/net/bdew/gendustry/nei/NEIGendustryConfig.scala deleted file mode 100644 index 30c0b42..0000000 --- a/src/net/bdew/gendustry/nei/NEIGendustryConfig.scala +++ /dev/null @@ -1,77 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import codechicken.nei.api.{API, IConfigureNEI} -import net.bdew.gendustry.config.{Machines, Config, Items} -import cpw.mods.fml.common.event.FMLInterModComms -import net.bdew.gendustry.Gendustry -import codechicken.nei.forge.GuiContainerManager -import codechicken.nei.recipe.{ICraftingHandler, IUsageHandler} - -class NEIGendustryConfig extends IConfigureNEI { - def getName: String = "Gendustry" - def getVersion: String = "GENDUSTRY_VER" - - def addRecipeHandler(h: IUsageHandler with ICraftingHandler) { - API.registerRecipeHandler(h) - API.registerUsageHandler(h) - } - - def loadConfig() { - NEICache.load() - if (Config.neiAddSamples) - NEICache.geneSamples.foreach(x => API.addNBTItem(Items.geneSample.newStack(x))) - - addRecipeHandler(new TemplateCraftingHandler) - - if (Machines.mutagenProducer.enabled) { - addRecipeHandler(new MutagenProducerHandler) - FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Mutagen Producer@MutagenProducer") - } - - if (Machines.mutatron.enabled) { - addRecipeHandler(new MutatronHandler) - FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Mutatron@Mutatron") - } - - if (Machines.sampler.enabled) { - addRecipeHandler(new SamplerHandler) - FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Sampler@Sampler") - } - - if (Machines.imprinter.enabled) { - addRecipeHandler(new ImprinterHandler) - FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Imprinter@Imprinter") - } - - if (Machines.extractor.enabled) { - addRecipeHandler(new ExtractorHandler) - FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Extractor@Extractor") - } - - if (Machines.liquifier.enabled) { - addRecipeHandler(new LiquifierHandler) - FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Liquifier@Liquifier") - } - - if (Machines.replicator.enabled) { - addRecipeHandler(new ReplicatorHandler) - FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Replicator@Replicator") - } - - if (Machines.transposer.enabled) { - addRecipeHandler(new TransposerHandler) - FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Transposer@Transposer") - } - - GuiContainerManager.addTooltipHandler(new SmeltingTooltipHandler) - } -} diff --git a/src/net/bdew/gendustry/nei/NEIRecipeProxy.scala b/src/net/bdew/gendustry/nei/NEIRecipeProxy.scala deleted file mode 100644 index dc65364..0000000 --- a/src/net/bdew/gendustry/nei/NEIRecipeProxy.scala +++ /dev/null @@ -1,22 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.lib.Misc -import codechicken.nei.recipe.GuiCraftingRecipe - -object NEIRecipeProxy { - val hasNei = Misc.haveModVersion("NotEnoughItems") - - def openRecipes(id: String) { - if (hasNei) - GuiCraftingRecipe.openRecipeGui(id) - } -} diff --git a/src/net/bdew/gendustry/nei/NeiDrawTarget.scala b/src/net/bdew/gendustry/nei/NeiDrawTarget.scala deleted file mode 100644 index be4c517..0000000 --- a/src/net/bdew/gendustry/nei/NeiDrawTarget.scala +++ /dev/null @@ -1,19 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.lib.gui.SimpleDrawTarget -import codechicken.core.gui.GuiDraw -import net.minecraft.client.Minecraft - -object NEIDrawTarget extends SimpleDrawTarget { - def getZLevel = GuiDraw.gui.getZLevel - def getFontRenderer = Minecraft.getMinecraft.fontRenderer -} diff --git a/src/net/bdew/gendustry/nei/ReplicatorHandler.scala b/src/net/bdew/gendustry/nei/ReplicatorHandler.scala deleted file mode 100644 index ae96ff1..0000000 --- a/src/net/bdew/gendustry/nei/ReplicatorHandler.scala +++ /dev/null @@ -1,76 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.lib.gui.Rect -import net.bdew.gendustry.config.{Fluids, Items, Machines} -import net.minecraftforge.fluids.FluidStack -import net.bdew.gendustry.nei.helpers.{PowerComponent, FluidComponent} -import net.minecraft.item.ItemStack -import net.bdew.gendustry.Gendustry -import net.bdew.lib.Misc -import net.bdew.gendustry.forestry.GeneticsHelper - -class ReplicatorHandler extends BaseRecipeHandler(5, 13) { - val dnaRect = Rect(32, 19, 16, 58) - val proteinRect = Rect(56, 19, 16, 58) - val mjRect = new Rect(8, 19, 16, 58) - - import scala.collection.JavaConversions._ - - class ReplicatorRecipe(template: ItemStack, out: ItemStack) extends CachedRecipeWithComponents { - val getResult = position(out, 142, 41) - val templateStack = position(template, 98, 17) - - components :+= new FluidComponent(dnaRect, new FluidStack(Fluids.dna, Machines.replicator.dnaPerItem), Machines.replicator.dnaTankSize) - components :+= new FluidComponent(proteinRect, new FluidStack(Fluids.protein, Machines.replicator.proteinPerItem), Machines.replicator.proteinTankSize) - components :+= new PowerComponent(mjRect, Machines.replicator.mjPerItem, Machines.replicator.maxStoredEnergy) - - override def getOtherStacks = List(templateStack) - } - - def addRecipe(tpl: ItemStack) { - arecipes.add(new ReplicatorRecipe(tpl, GeneticsHelper.individualFromTemplate(tpl, Machines.replicator.makePristineBees))) - } - - def addRecipe(uid: String) { - addRecipe(GeneticsHelper.templateFromSpeciesUID(uid)) - } - - def getRecipe(i: Int) = arecipes.get(i).asInstanceOf[ReplicatorRecipe] - - override def loadTransferRects() { - addTransferRect(Rect(89, 41, 40, 15), "Replicator") - } - - def addAllRecipes() { - addRecipe("forestry.speciesForest") - addRecipe("forestry.treeOak") - addRecipe("forestry.lepiCabbageWhite") - } - - override def loadUsageRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("liquid", Seq(x: FluidStack)) if x.fluidID == Fluids.dna.getID => addAllRecipes() - case ("liquid", Seq(x: FluidStack)) if x.fluidID == Fluids.protein.getID => addAllRecipes() - case ("item", Seq(x: ItemStack)) if x.itemID == Items.geneTemplate.itemID && Items.geneTemplate.isComplete(x) => addRecipe(x) - case ("Replicator", _) => addAllRecipes() - } - } - - override def loadCraftingRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("Replicator", _) => addAllRecipes() - } - } - - def getGuiTexture = Gendustry.modId + ":textures/gui/replicator.png" - def getRecipeName = Misc.toLocal("tile.gendustry.replicator.name") -} diff --git a/src/net/bdew/gendustry/nei/SamplerHandler.scala b/src/net/bdew/gendustry/nei/SamplerHandler.scala deleted file mode 100644 index c9e3f01..0000000 --- a/src/net/bdew/gendustry/nei/SamplerHandler.scala +++ /dev/null @@ -1,126 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.lib.gui.Rect -import net.bdew.gendustry.config.{Items, Machines} -import net.bdew.gendustry.nei.helpers.PowerComponent -import forestry.api.genetics._ -import forestry.api.apiculture.{EnumBeeType, IBeeRoot} -import forestry.api.arboriculture.{EnumGermlingType, ITreeRoot} -import net.minecraft.item.ItemStack -import net.bdew.gendustry.Gendustry -import codechicken.nei.recipe.GuiRecipe -import java.util -import net.bdew.lib.Misc -import net.bdew.gendustry.forestry.GeneSampleInfo -import scala.Some -import net.bdew.gendustry.compat.ExtraBeesProxy - -class SamplerHandler extends BaseRecipeHandler(5, 13) { - val mutagenRect = new Rect(32, 19, 16, 58) - val mjRect = new Rect(8, 19, 16, 58) - - import scala.collection.JavaConversions._ - import NEICache.SampleOrdering - - class SamplerRecipe(sample: GeneSampleInfo, input: ItemStack) extends CachedRecipeWithComponents { - val getResult = position(Items.geneSample.newStack(sample), 137, 49) - val individual = position(input, 41, 49) - val sampleBlank = position(new ItemStack(Items.geneSampleBlank), 74, 28) - val labware = position(new ItemStack(Items.labware), 98, 28) - - components :+= new PowerComponent(mjRect, Machines.sampler.mjPerItem, Machines.sampler.maxStoredEnergy) - - override def getOtherStacks = List(individual, sampleBlank, labware) - } - - def getRecipeStack(species: IAlleleSpecies): ItemStack = { - val root = species.getRoot - val individual = root.templateAsIndividual(root.getTemplate(species.getUID)) - individual.analyze() - return root match { - case bees: IBeeRoot => bees.getMemberStack(individual, EnumBeeType.DRONE.ordinal()) - case trees: ITreeRoot => trees.getMemberStack(individual, EnumGermlingType.SAPLING.ordinal()) - case _ => root.getMemberStack(individual, 0) - } - } - - def getRecipe(i: Int) = arecipes.get(i).asInstanceOf[SamplerRecipe] - - override def loadTransferRects() { - addTransferRect(Rect(63, 49, 66, 15), "Sampler") - } - - def addAllRecipes() { - for (info <- NEICache.geneSamples; species <- NEICache.speciesChromosomes(info)) { - arecipes.add(new SamplerRecipe(info, getRecipeStack(species))) - } - if (Machines.sampler.convertEBSerums && ExtraBeesProxy.ebLoaded) { - for (sample <- NEICache.geneSamples if sample.root.isInstanceOf[IBeeRoot]) { - val serum = ExtraBeesProxy.makeSerumFromSample(sample) - if (serum != null) arecipes.add(new SamplerRecipe(sample, serum)) - } - } - } - - override def loadUsageRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("item", Seq(x: ItemStack)) if x.itemID == Items.labware.itemID => addAllRecipes() - case ("item", Seq(x: ItemStack)) if x.itemID == Items.geneSampleBlank.itemID => addAllRecipes() - case ("item", Seq(stack: ItemStack)) => - val individual = AlleleManager.alleleRegistry.getIndividual(stack) - if (individual != null) { - val root = individual.getGenome.getSpeciesRoot - var alleles = collection.SortedSet.empty[GeneSampleInfo] - for ((chromosome, n) <- individual.getGenome.getChromosomes.zipWithIndex if chromosome != null) { - if (chromosome.getPrimaryAllele != null && !AlleleManager.alleleRegistry.isBlacklisted(chromosome.getPrimaryAllele.getUID)) - alleles += GeneSampleInfo(root, n, chromosome.getPrimaryAllele) - if (chromosome.getSecondaryAllele != null && !AlleleManager.alleleRegistry.isBlacklisted(chromosome.getSecondaryAllele.getUID)) - alleles += GeneSampleInfo(root, n, chromosome.getSecondaryAllele) - } - alleles.foreach(sample => arecipes.add(new SamplerRecipe(sample, stack))) - } else if (Machines.sampler.convertEBSerums && ExtraBeesProxy.isSerum(stack)) { - val sample = ExtraBeesProxy.getSerumSample(stack) - if (sample != null) - arecipes.add(new SamplerRecipe(sample, stack)) - } - case ("Sampler", _) => addAllRecipes() - } - } - - override def loadCraftingRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("item", Seq(stack: ItemStack)) if stack.itemID == Items.geneSample.itemID => - val info = Items.geneSample.getInfo(stack) - if (info == null) { - addAllRecipes() - } else { - for (species <- NEICache.speciesChromosomes(info)) { - arecipes.add(new SamplerRecipe(info, getRecipeStack(species))) - } - if (Machines.sampler.convertEBSerums && ExtraBeesProxy.ebLoaded) { - val serum = ExtraBeesProxy.makeSerumFromSample(info) - if (serum != null) arecipes.add(new SamplerRecipe(info, serum)) - } - } - case ("Sampler", _) => addAllRecipes() - } - } - - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, currenttip: util.List[String], recipe: Int): util.List[String] = { - if (stack == getRecipe(recipe).labware.item) - currenttip += Misc.toLocalF("gendustry.label.consume", Machines.mutatron.labwareConsumeChance.toInt) - super.handleItemTooltip(gui, stack, currenttip, recipe) - } - - def getGuiTexture = Gendustry.modId + ":textures/gui/sampler.png" - def getRecipeName = Misc.toLocal("tile.gendustry.sampler.name") -} diff --git a/src/net/bdew/gendustry/nei/SmeltingTooltipHandler.scala b/src/net/bdew/gendustry/nei/SmeltingTooltipHandler.scala deleted file mode 100644 index b0711fb..0000000 --- a/src/net/bdew/gendustry/nei/SmeltingTooltipHandler.scala +++ /dev/null @@ -1,35 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import codechicken.nei.forge.IContainerTooltipHandler -import net.minecraft.client.gui.inventory.GuiContainer -import net.minecraft.item.ItemStack -import java.util -import codechicken.nei.recipe.{FurnaceRecipeHandler, GuiRecipe} -import net.bdew.gendustry.config.Items -import net.bdew.lib.Misc - -class SmeltingTooltipHandler extends IContainerTooltipHandler { - def handleTooltipFirst(gui: GuiContainer, mousex: Int, mousey: Int, currenttip: util.List[String]) = currenttip - def handleItemTooltip(gui: GuiContainer, itemstack: ItemStack, currenttip: util.List[String]) = { - if (gui.isInstanceOf[GuiRecipe]) { - val gr = gui.asInstanceOf[GuiRecipe] - val handler = gr.currenthandlers.get(gr.recipetype) - if (handler.isInstanceOf[FurnaceRecipeHandler]) { - if (itemstack.itemID == Items.geneSample.itemID) - currenttip.add(Misc.toLocal("gendustry.label.erase")) - if (itemstack.itemID == Items.geneTemplate.itemID) - currenttip.add(Misc.toLocal("gendustry.label.erase")) - } - } - currenttip - } -} diff --git a/src/net/bdew/gendustry/nei/TemplateCraftingHandler.scala b/src/net/bdew/gendustry/nei/TemplateCraftingHandler.scala deleted file mode 100644 index 0409ba1..0000000 --- a/src/net/bdew/gendustry/nei/TemplateCraftingHandler.scala +++ /dev/null @@ -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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import codechicken.nei.recipe.ShapelessRecipeHandler -import net.minecraft.item.ItemStack -import net.bdew.gendustry.config.Items -import net.bdew.lib.Misc -import net.minecraft.client.gui.inventory.GuiContainer -import net.minecraft.inventory.Container -import codechicken.core.gui.GuiDraw - -class TemplateCraftingHandler extends ShapelessRecipeHandler { - - def addRecipe() { - import scala.collection.JavaConversions._ - val rec = List(new ItemStack(Items.geneTemplate), new ItemStack(Items.geneSample), new ItemStack(Items.geneSample)) - val out = new ItemStack(Items.geneTemplate) - arecipes.add(new CachedShapelessRecipe(rec, out)) - } - - override def loadCraftingRecipes(result: ItemStack) { - if (result.itemID == Items.geneTemplate.itemID) - addRecipe() - } - - override def loadUsageRecipes(ingredient: ItemStack) { - if (ingredient.itemID == Items.geneTemplate.itemID || ingredient.itemID == Items.geneSample.itemID) - addRecipe() - } - - override def drawExtras(recipe: Int) = { - GuiDraw.fontRenderer.drawSplitString(Misc.toLocal("gendustry.label.template.crafting"), 5, 65, 155, 0x404040) - } - - override def recipiesPerPage() = 1 - override def hasOverlay(gui: GuiContainer, container: Container, recipe: Int) = false - override def loadTransferRects() {} - override def getRecipeName = Misc.toLocal("item.gendustry.GeneTemplate.name") -} diff --git a/src/net/bdew/gendustry/nei/TransposerHandler.scala b/src/net/bdew/gendustry/nei/TransposerHandler.scala deleted file mode 100644 index 4ac3aee..0000000 --- a/src/net/bdew/gendustry/nei/TransposerHandler.scala +++ /dev/null @@ -1,108 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei - -import net.bdew.lib.gui.Rect -import net.bdew.gendustry.config.{Items, Machines} -import net.bdew.gendustry.nei.helpers.PowerComponent -import forestry.api.genetics._ -import net.minecraft.item.ItemStack -import net.bdew.gendustry.Gendustry -import codechicken.nei.recipe.GuiRecipe -import java.util -import net.bdew.lib.Misc -import net.bdew.gendustry.forestry.GeneSampleInfo -import scala.Some -import net.bdew.lib.items.IStack - -class TransposerHandler extends BaseRecipeHandler(5, 13) { - val mutagenRect = new Rect(32, 19, 16, 58) - val mjRect = new Rect(8, 19, 16, 58) - - import scala.collection.JavaConversions._ - - class TransposerRecipe(blankStack: ItemStack, outStack: ItemStack, templateStack: ItemStack) extends CachedRecipeWithComponents { - val getResult = position(outStack, 137, 49) - val blank = position(blankStack, 41, 49) - val template = position(templateStack, 74, 28) - val labware = position(new ItemStack(Items.labware), 98, 28) - - components :+= new PowerComponent(mjRect, Machines.transposer.mjPerItem, Machines.transposer.maxStoredEnergy) - - override def getOtherStacks = List(template, blank, labware) - } - - def addRecipe(template: ItemStack) = template match { - case IStack(Items.geneSample) => - arecipes.add(new TransposerRecipe(new ItemStack(Items.geneSampleBlank), template, template)) - case IStack(Items.geneTemplate) => - arecipes.add(new TransposerRecipe(new ItemStack(Items.geneTemplate), template, template)) - } - - def getRecipe(i: Int) = arecipes.get(i).asInstanceOf[TransposerRecipe] - - override def loadTransferRects() { - addTransferRect(Rect(63, 49, 66, 15), "Transposer") - } - - lazy val forestSampleInfo = GeneSampleInfo(AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"), 0, - AlleleManager.alleleRegistry.getAllele("forestry.speciesForest")) - - def addSampleRecipe() = addRecipe(Items.geneSample.newStack(forestSampleInfo)) - - def addTemplateRecipe() { - val tpl = new ItemStack(Items.geneTemplate) - Items.geneTemplate.addSample(tpl, forestSampleInfo) - addRecipe(tpl) - } - - def addAllRecipes() { - addSampleRecipe() - addTemplateRecipe() - } - - override def loadUsageRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("item", Seq(IStack(Items.labware))) => addAllRecipes() - case ("item", Seq(IStack(Items.geneSampleBlank))) => addSampleRecipe() - case ("item", Seq(stack: ItemStack)) if stack.itemID == Items.geneSample.itemID => - addRecipe(stack) - case ("item", Seq(stack: ItemStack)) if stack.itemID == Items.geneTemplate.itemID => - if (Items.geneTemplate.getSpecies(stack) == null) - addTemplateRecipe() - else - addRecipe(stack) - - case ("Transposer", _) => addAllRecipes() - } - } - - override def loadCraftingRecipes(outputId: String, results: AnyRef*): Unit = { - Some(outputId, results) collect { - case ("item", Seq(stack: ItemStack)) if stack.itemID == Items.geneSample.itemID => - addRecipe(stack) - case ("item", Seq(stack: ItemStack)) if stack.itemID == Items.geneTemplate.itemID => - if (Items.geneTemplate.getSpecies(stack) == null) - addTemplateRecipe() - else - addRecipe(stack) - case ("Transposer", _) => addAllRecipes() - } - } - - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, currenttip: util.List[String], recipe: Int): util.List[String] = { - if (stack == getRecipe(recipe).labware.item) - currenttip += Misc.toLocalF("gendustry.label.consume", Machines.mutatron.labwareConsumeChance.toInt) - super.handleItemTooltip(gui, stack, currenttip, recipe) - } - - def getGuiTexture = Gendustry.modId + ":textures/gui/transposer.png" - def getRecipeName = Misc.toLocal("tile.gendustry.transposer.name") -} diff --git a/src/net/bdew/gendustry/nei/helpers/FluidComponent.scala b/src/net/bdew/gendustry/nei/helpers/FluidComponent.scala deleted file mode 100644 index 26414b6..0000000 --- a/src/net/bdew/gendustry/nei/helpers/FluidComponent.scala +++ /dev/null @@ -1,57 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei.helpers - -import net.bdew.lib.gui.{Texture, Point, Rect} -import codechicken.nei.recipe.{GuiUsageRecipe, GuiCraftingRecipe} -import net.minecraftforge.fluids.FluidStack -import java.text.DecimalFormat -import org.lwjgl.opengl.GL11 -import net.bdew.gendustry.gui.Textures -import net.bdew.gendustry.nei.NEIDrawTarget - -class FluidComponent(rect: Rect, fstack: FluidStack, capacity: Int) extends RecipeComponent(rect) { - val formater = new DecimalFormat("#,###") - - def getTooltip = List(fstack.getFluid.getLocalizedName, "%s mB".format(formater.format(fstack.amount))) - - def mouseClick(button: Int) = button match { - case 0 => GuiCraftingRecipe.openRecipeGui("liquid", fstack) - case 1 => GuiUsageRecipe.openRecipeGui("liquid", fstack) - case _ => false - } - - def render(offset: Point) { - val orect = rect - offset - - GL11.glEnable(GL11.GL_BLEND) - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) - - if (fstack.getFluid.getStillIcon != null) { - val icon = Texture(Texture.BLOCKS, fstack.getFluid.getStillIcon) - var fillHeight = orect.h * fstack.amount / capacity - var yStart = 0 - - while (fillHeight > 0) { - if (fillHeight > 16) { - NEIDrawTarget.drawTexture(new Rect(orect.x, orect.y2 - 16 - yStart, orect.w, 16), icon) - fillHeight -= 16 - } else { - NEIDrawTarget.drawTextureInterpolate(new Rect(orect.x, orect.y2 - 16 - yStart, orect.w, 16), icon, 0, 1 - fillHeight / 16, 1, 1) - fillHeight = 0 - } - yStart = yStart + 16 - } - } - - GL11.glDisable(GL11.GL_BLEND) - NEIDrawTarget.drawTexture(orect, Textures.tankOverlay) - } -} \ No newline at end of file diff --git a/src/net/bdew/gendustry/nei/helpers/PowerComponent.scala b/src/net/bdew/gendustry/nei/helpers/PowerComponent.scala deleted file mode 100644 index ec9e33c..0000000 --- a/src/net/bdew/gendustry/nei/helpers/PowerComponent.scala +++ /dev/null @@ -1,25 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei.helpers - -import net.bdew.lib.gui.{Point, Rect} -import java.text.DecimalFormat -import net.bdew.gendustry.gui.Textures -import net.bdew.gendustry.config.Config -import net.bdew.gendustry.nei.NEIDrawTarget - -class PowerComponent(rect: Rect, power: Float, capacity: Float) extends RecipeComponent(rect) { - val formater = new DecimalFormat("#,###") - def getTooltip = List("%s %s".format(formater.format(power * Config.powerShowMultiplier), Config.powerShowUnits)) - def mouseClick(button: Int) = false - def render(offset: Point) { - NEIDrawTarget.drawTextureInterpolate(rect - offset, Textures.powerFill, 0, 1 - (power / capacity), 1, 1) - } -} diff --git a/src/net/bdew/gendustry/nei/helpers/RecipeComponent.scala b/src/net/bdew/gendustry/nei/helpers/RecipeComponent.scala deleted file mode 100644 index 54363c0..0000000 --- a/src/net/bdew/gendustry/nei/helpers/RecipeComponent.scala +++ /dev/null @@ -1,18 +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 - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.nei.helpers - -import net.bdew.lib.gui.{Point, Rect} - -abstract class RecipeComponent(val rect: Rect) { - def getTooltip: List[String] - def mouseClick(button: Int): Boolean - def render(offset: Point) -}