mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 04:10:07 +00:00
Add Genepool JEI recipes
This commit is contained in:
1 parent
3530a0e9df
commit
0f716a0a16
7 files changed
+191
-27
No files matched your search
@@ -4,6 +4,9 @@ import binnie.core.integration.jei.Drawables;
|
||||
import binnie.core.integration.jei.SimpleRecipeHandler;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.api.IItemChargeable;
|
||||
import binnie.genetics.integration.jei.genepool.GenepoolRecipeCategory;
|
||||
import binnie.genetics.integration.jei.genepool.GenepoolRecipeMaker;
|
||||
import binnie.genetics.integration.jei.genepool.GenepoolRecipeWrapper;
|
||||
import binnie.genetics.integration.jei.incubator.IncubatorRecipeCategory;
|
||||
import binnie.genetics.integration.jei.incubator.IncubatorRecipeHandler;
|
||||
import binnie.genetics.integration.jei.incubator.LarvaeIncubatorRecipeCategory;
|
||||
@@ -69,7 +72,8 @@ public class GeneticsJeiPlugin extends BlankModPlugin {
|
||||
new PolymeriserRecipeCategory(),
|
||||
new SequencerRecipeCategory(),
|
||||
new InoculatorRecipeCategory(),
|
||||
new SplicerRecipeCategory()
|
||||
new SplicerRecipeCategory(),
|
||||
new GenepoolRecipeCategory()
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
@@ -79,7 +83,8 @@ public class GeneticsJeiPlugin extends BlankModPlugin {
|
||||
new SimpleRecipeHandler<>(PolymeriserRecipeWrapper.class, RecipeUids.POLYMERISER),
|
||||
new SimpleRecipeHandler<>(SequencerRecipeWrapper.class, RecipeUids.SEQUENCER),
|
||||
new SimpleRecipeHandler<>(InoculatorRecipeWrapper.class, RecipeUids.INOCULATOR),
|
||||
new SimpleRecipeHandler<>(SplicerRecipeWrapper.class, RecipeUids.SPLICER)
|
||||
new SimpleRecipeHandler<>(SplicerRecipeWrapper.class, RecipeUids.SPLICER),
|
||||
new SimpleRecipeHandler<>(GenepoolRecipeWrapper.class, RecipeUids.GENEPOOL)
|
||||
);
|
||||
|
||||
registry.addRecipeCategoryCraftingItem(LaboratoryMachine.Incubator.get(1), RecipeUids.INCUBATOR, RecipeUids.INCUBATOR_LARVAE);
|
||||
@@ -88,6 +93,7 @@ public class GeneticsJeiPlugin extends BlankModPlugin {
|
||||
registry.addRecipeCategoryCraftingItem(GeneticMachine.Sequencer.get(1), RecipeUids.SEQUENCER);
|
||||
registry.addRecipeCategoryCraftingItem(GeneticMachine.Inoculator.get(1), RecipeUids.INOCULATOR);
|
||||
registry.addRecipeCategoryCraftingItem(AdvGeneticMachine.Splicer.get(1), RecipeUids.SPLICER);
|
||||
registry.addRecipeCategoryCraftingItem(LaboratoryMachine.Genepool.get(1), RecipeUids.GENEPOOL);
|
||||
|
||||
registry.addRecipes(Incubator.getRecipes());
|
||||
registry.addRecipes(LarvaeIncubatorRecipeMaker.create(Incubator.getLarvaeRecipe()));
|
||||
@@ -95,6 +101,7 @@ public class GeneticsJeiPlugin extends BlankModPlugin {
|
||||
registry.addRecipes(PolymeriserRecipeMaker.create());
|
||||
registry.addRecipes(SequencerRecipeMaker.create());
|
||||
registry.addRecipes(InoculatorRecipeMaker.create());
|
||||
registry.addRecipes(GenepoolRecipeMaker.create());
|
||||
}
|
||||
|
||||
private static class ChargeableSubtypeInterpreter implements ISubtypeRegistry.ISubtypeInterpreter {
|
||||
|
||||
@@ -8,4 +8,5 @@ public class RecipeUids {
|
||||
public static final String SEQUENCER = "binnie.genetics.sequencer";
|
||||
public static final String INOCULATOR = "binnie.genetics.inoculator";
|
||||
public static final String SPLICER = "binnie.genetics.splicer";
|
||||
public static final String GENEPOOL = "binnie.genetics.genepool";
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package binnie.genetics.integration.jei.genepool;
|
||||
|
||||
import binnie.genetics.integration.jei.GeneticsJeiPlugin;
|
||||
import binnie.genetics.integration.jei.RecipeUids;
|
||||
import binnie.genetics.machine.genepool.Genepool;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class GenepoolRecipeCategory extends BlankRecipeCategory<GenepoolRecipeWrapper> {
|
||||
private final IDrawableAnimated arrowAnimated;
|
||||
|
||||
public GenepoolRecipeCategory() {
|
||||
this.arrowAnimated = GeneticsJeiPlugin.drawables.createArrowAnimated(56);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return RecipeUids.GENEPOOL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Genepool";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return GeneticsJeiPlugin.guiHelper.createBlankDrawable(114, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
IDrawable tank = GeneticsJeiPlugin.drawables.getTank();
|
||||
tank.draw(minecraft, 0, 0);
|
||||
tank.draw(minecraft, 95, 0);
|
||||
|
||||
IDrawable arrow = GeneticsJeiPlugin.drawables.getArrow();
|
||||
arrow.draw(minecraft, 69, 45);
|
||||
arrowAnimated.draw(minecraft, 69, 45);
|
||||
|
||||
IDrawable slot = GeneticsJeiPlugin.guiHelper.getSlotDrawable();
|
||||
slot.draw(minecraft, 22, 0);
|
||||
slot.draw(minecraft, 42, 41);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, GenepoolRecipeWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IDrawable tankOverlay = GeneticsJeiPlugin.drawables.getTankOverlay();
|
||||
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
|
||||
fluidStacks.init(Genepool.TANK_DNA, false, 96, 1, 16, 58, 100, false, tankOverlay);
|
||||
fluidStacks.init(Genepool.TANK_ETHANOL, true, 1, 1, 16, 58, 100, false, tankOverlay);
|
||||
fluidStacks.set(ingredients);
|
||||
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init(0, true, 22, 0);
|
||||
itemStacks.init(1, true, 42, 41);
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package binnie.genetics.integration.jei.genepool;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.ISpeciesType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class GenepoolRecipeMaker {
|
||||
public static List<GenepoolRecipeWrapper> create() {
|
||||
List<GenepoolRecipeWrapper> recipes = new ArrayList<>();
|
||||
|
||||
Collection<ISpeciesRoot> roots = AlleleManager.alleleRegistry.getSpeciesRoot().values();
|
||||
for (ISpeciesRoot root : roots) {
|
||||
ISpeciesType[] speciesTypes = root.getIconType().getClass().getEnumConstants();
|
||||
IAllele[] defaultTemplate = root.getDefaultTemplate();
|
||||
IIndividual individual = root.templateAsIndividual(defaultTemplate);
|
||||
for (ISpeciesType speciesType : speciesTypes) {
|
||||
ItemStack memberStack = root.getMemberStack(individual, speciesType);
|
||||
memberStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
|
||||
|
||||
GenepoolRecipeWrapper recipeWrapper = new GenepoolRecipeWrapper(memberStack);
|
||||
recipes.add(recipeWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package binnie.genetics.integration.jei.genepool;
|
||||
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.genepool.GenepoolLogic;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GenepoolRecipeWrapper extends BlankRecipeWrapper {
|
||||
private static final ItemStack ENZYME = GeneticsItems.Enzyme.get(1);
|
||||
|
||||
private final ItemStack input;
|
||||
private final FluidStack dnaOutput;
|
||||
private final FluidStack ethanolInput;
|
||||
|
||||
public GenepoolRecipeWrapper(ItemStack input) {
|
||||
this.input = input;
|
||||
int dnaAmount = GenepoolLogic.getDNAAmount(input);
|
||||
this.dnaOutput = GeneticLiquid.RawDNA.get(dnaAmount);
|
||||
this.ethanolInput = Fluids.BIO_ETHANOL.getFluid(Math.round(dnaAmount * 1.2f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
List<ItemStack> inputs = new ArrayList<>();
|
||||
inputs.add(ENZYME);
|
||||
inputs.add(input);
|
||||
ingredients.setInputs(ItemStack.class, inputs);
|
||||
|
||||
ingredients.setInput(FluidStack.class, ethanolInput);
|
||||
ingredients.setOutput(FluidStack.class, dnaOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
float usedEnzyme = GenepoolLogic.ENZYME_PER_PROCESS;
|
||||
String usedString = String.format("%.2f", usedEnzyme);
|
||||
minecraft.fontRendererObj.drawString(usedString, 22, 20, Color.gray.getRGB());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package binnie.genetics.integration.jei.genepool;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -13,14 +13,28 @@ import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GenepoolLogic extends ComponentProcessSetCost implements IProcess {
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
public static final float ENZYME_PER_PROCESS = 0.25f;
|
||||
|
||||
public static int getDNAAmount(final ItemStack stack) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
|
||||
if (root == Binnie.Genetics.getBeeRoot()) {
|
||||
if (Binnie.Genetics.getBeeRoot().isDrone(stack)) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isMated(stack)) {
|
||||
return 50;
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
|
||||
return 10;
|
||||
}
|
||||
|
||||
private float ethanolDrain;
|
||||
|
||||
public GenepoolLogic(final Machine machine) {
|
||||
super(machine, 8000, 400);
|
||||
this.enzymePerProcess = 0.25f;
|
||||
this.ethanolPerProcess = 50.0f;
|
||||
this.ethanolDrain = 0.0f;
|
||||
}
|
||||
|
||||
@@ -34,7 +48,7 @@ public class GenepoolLogic extends ComponentProcessSetCost implements IProcess {
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().spaceInTank(Genepool.TANK_DNA, this.getDNAAmount(this.getUtil().getStack(0)))) {
|
||||
if (!this.getUtil().spaceInTank(Genepool.TANK_DNA, getDNAAmount(this.getUtil().getStack(0)))) {
|
||||
return new ErrorState.NoSpace(Genetics.proxy.localise("machine.errors.tanks.no.room.desc"), new int[]{0});
|
||||
}
|
||||
if (!this.getUtil().liquidInTank(Genepool.TANK_ETHANOL, 1)) {
|
||||
@@ -49,35 +63,20 @@ public class GenepoolLogic extends ComponentProcessSetCost implements IProcess {
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final int amount = this.getDNAAmount(this.getUtil().getStack(Genepool.SLOT_BEE));
|
||||
ItemStack individual = this.getUtil().getStack(Genepool.SLOT_BEE);
|
||||
final int amount = getDNAAmount(individual);
|
||||
this.getUtil().fillTank(Genepool.TANK_DNA, GeneticLiquid.RawDNA.get(amount));
|
||||
this.getUtil().deleteStack(Genepool.SLOT_BEE);
|
||||
}
|
||||
|
||||
private int getDNAAmount(final ItemStack stack) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root == null) {
|
||||
return 10;
|
||||
}
|
||||
if (root != Binnie.Genetics.getBeeRoot()) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isDrone(stack)) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isMated(stack)) {
|
||||
return 50;
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.ethanolDrain += this.getDNAAmount(this.getUtil().getStack(Genepool.SLOT_BEE)) * 1.2f * this.getProgressPerTick() / 100.0f;
|
||||
ItemStack individual = this.getUtil().getStack(Genepool.SLOT_BEE);
|
||||
this.ethanolDrain += getDNAAmount(individual) * 1.2f * this.getProgressPerTick() / 100.0f;
|
||||
if (this.ethanolDrain >= 1.0f) {
|
||||
this.getUtil().drainTank(Genepool.TANK_ETHANOL, 1);
|
||||
--this.ethanolDrain;
|
||||
}
|
||||
this.getMachine().getInterface(IChargedSlots.class).alterCharge(Genepool.SLOT_ENZYME, -this.enzymePerProcess * this.getProgressPerTick() / 100.0f);
|
||||
this.getMachine().getInterface(IChargedSlots.class).alterCharge(Genepool.SLOT_ENZYME, -ENZYME_PER_PROCESS * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user