mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-19 03:49:18 +00:00
Added imprinter recipe handler
This commit is contained in:
1 parent
281037754f
commit
3cd2bee1d6
3 files changed
+118
-5
No files matched your search
@@ -10,7 +10,7 @@
|
||||
package net.bdew.gendustry.machines.imprinter
|
||||
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.gui.{WidgetMJGauge, Textures}
|
||||
import net.bdew.gendustry.gui.{WidgetProgressBarNEI, WidgetMJGauge, Textures}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.bdew.lib.gui.{Rect, BaseScreen}
|
||||
@@ -21,7 +21,7 @@ class GuiImprinter(val te: TileImprinter, player: EntityPlayer) extends BaseScre
|
||||
val texture: ResourceLocation = new ResourceLocation(Gendustry.modId + ":textures/gui/imprinter.png")
|
||||
override def initGui() {
|
||||
super.initGui()
|
||||
addWidget(new WidgetProgressBar(new Rect(63, 49, 66, 15), Textures.whiteProgress(66), te.progress))
|
||||
addWidget(new WidgetProgressBarNEI(new Rect(63, 49, 66, 15), Textures.whiteProgress(66), te.progress, "Imprinter"))
|
||||
addWidget(new WidgetMJGauge(new Rect(8, 19, 16, 58), Textures.powerFill, te.power))
|
||||
addWidget(new WidgetLabel(Misc.toLocal("tile.gendustry.imprinter.name"), 8, 6, 4210752))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013
|
||||
* 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, Point}
|
||||
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 codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect
|
||||
import java.awt.Rectangle
|
||||
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 {
|
||||
lazy val offset = new Point(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() {
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(63 - offset.x, 49 - offset.y, 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")
|
||||
}
|
||||
@@ -33,12 +33,14 @@ class NEIGendustryConfig extends IConfigureNEI {
|
||||
addRecipeHandler(new MutagenProducerHandler)
|
||||
addRecipeHandler(new MutatronHandler)
|
||||
addRecipeHandler(new SamplerHandler)
|
||||
addRecipeHandler(new ImprinterHandler)
|
||||
addRecipeHandler(new TemplateCraftingHandler)
|
||||
|
||||
GuiContainerManager.addTooltipHandler(new SmeltingTooltipHandler)
|
||||
|
||||
FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Mutagen Producer@MutagenProducer");
|
||||
FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Mutatron@Mutatron");
|
||||
FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Sampler@Sampler");
|
||||
FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Mutagen Producer@MutagenProducer")
|
||||
FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Mutatron@Mutatron")
|
||||
FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Sampler@Sampler")
|
||||
FMLInterModComms.sendRuntimeMessage(Gendustry, "NEIPlugins", "register-crafting-handler", "Gendustry@Imprinter@Imprinter")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user