mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-17 19:15:24 +00:00
Add Splicer JEI recipes, improve Inoculator JEI recipes
This commit is contained in:
1 parent
a990ce3dc9
commit
3530a0e9df
11 files changed
+174
-38
No files matched your search
@@ -12,6 +12,8 @@ import binnie.genetics.integration.jei.incubator.LarvaeIncubatorRecipeWrapper;
|
||||
import binnie.genetics.integration.jei.inoculator.InoculatorRecipeCategory;
|
||||
import binnie.genetics.integration.jei.inoculator.InoculatorRecipeMaker;
|
||||
import binnie.genetics.integration.jei.inoculator.InoculatorRecipeWrapper;
|
||||
import binnie.genetics.integration.jei.inoculator.SplicerRecipeCategory;
|
||||
import binnie.genetics.integration.jei.inoculator.SplicerRecipeWrapper;
|
||||
import binnie.genetics.integration.jei.isolator.IsolatorRecipeCategory;
|
||||
import binnie.genetics.integration.jei.isolator.IsolatorRecipeMaker;
|
||||
import binnie.genetics.integration.jei.isolator.IsolatorRecipeWrapper;
|
||||
@@ -21,6 +23,7 @@ import binnie.genetics.integration.jei.polymeriser.PolymeriserRecipeWrapper;
|
||||
import binnie.genetics.integration.jei.sequencer.SequencerRecipeCategory;
|
||||
import binnie.genetics.integration.jei.sequencer.SequencerRecipeMaker;
|
||||
import binnie.genetics.integration.jei.sequencer.SequencerRecipeWrapper;
|
||||
import binnie.genetics.machine.AdvGeneticMachine;
|
||||
import binnie.genetics.machine.GeneticMachine;
|
||||
import binnie.genetics.machine.LaboratoryMachine;
|
||||
import binnie.genetics.machine.incubator.Incubator;
|
||||
@@ -65,7 +68,8 @@ public class GeneticsJeiPlugin extends BlankModPlugin {
|
||||
new IsolatorRecipeCategory(),
|
||||
new PolymeriserRecipeCategory(),
|
||||
new SequencerRecipeCategory(),
|
||||
new InoculatorRecipeCategory()
|
||||
new InoculatorRecipeCategory(),
|
||||
new SplicerRecipeCategory()
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
@@ -74,7 +78,8 @@ public class GeneticsJeiPlugin extends BlankModPlugin {
|
||||
new SimpleRecipeHandler<>(IsolatorRecipeWrapper.class, RecipeUids.ISOLATOR),
|
||||
new SimpleRecipeHandler<>(PolymeriserRecipeWrapper.class, RecipeUids.POLYMERISER),
|
||||
new SimpleRecipeHandler<>(SequencerRecipeWrapper.class, RecipeUids.SEQUENCER),
|
||||
new SimpleRecipeHandler<>(InoculatorRecipeWrapper.class, RecipeUids.INOCULATOR)
|
||||
new SimpleRecipeHandler<>(InoculatorRecipeWrapper.class, RecipeUids.INOCULATOR),
|
||||
new SimpleRecipeHandler<>(SplicerRecipeWrapper.class, RecipeUids.SPLICER)
|
||||
);
|
||||
|
||||
registry.addRecipeCategoryCraftingItem(LaboratoryMachine.Incubator.get(1), RecipeUids.INCUBATOR, RecipeUids.INCUBATOR_LARVAE);
|
||||
@@ -82,6 +87,7 @@ public class GeneticsJeiPlugin extends BlankModPlugin {
|
||||
registry.addRecipeCategoryCraftingItem(GeneticMachine.Polymeriser.get(1), RecipeUids.POLYMERISER);
|
||||
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.addRecipes(Incubator.getRecipes());
|
||||
registry.addRecipes(LarvaeIncubatorRecipeMaker.create(Incubator.getLarvaeRecipe()));
|
||||
|
||||
@@ -7,4 +7,5 @@ public class RecipeUids {
|
||||
public static final String POLYMERISER = "binnie.genetics.polymeriser";
|
||||
public static final String SEQUENCER = "binnie.genetics.sequencer";
|
||||
public static final String INOCULATOR = "binnie.genetics.inoculator";
|
||||
public static final String SPLICER = "binnie.genetics.splicer";
|
||||
}
|
||||
+18
-6
@@ -23,9 +23,15 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InoculatorRecipeCategory extends BlankRecipeCategory<InoculatorRecipeWrapper> {
|
||||
private final IDrawableAnimated arrowAnimated;
|
||||
private final boolean splicer;
|
||||
|
||||
public InoculatorRecipeCategory() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
protected InoculatorRecipeCategory(boolean splicer) {
|
||||
this.arrowAnimated = GeneticsJeiPlugin.drawables.createArrowAnimated(56);
|
||||
this.splicer = splicer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,8 +51,10 @@ public class InoculatorRecipeCategory extends BlankRecipeCategory<InoculatorReci
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
IDrawable tank = GeneticsJeiPlugin.drawables.getTank();
|
||||
tank.draw(minecraft, 0, 0);
|
||||
if (!splicer) {
|
||||
IDrawable tank = GeneticsJeiPlugin.drawables.getTank();
|
||||
tank.draw(minecraft, 0, 0);
|
||||
}
|
||||
|
||||
IDrawable arrow = GeneticsJeiPlugin.drawables.getArrow();
|
||||
arrow.draw(minecraft, 69, 25);
|
||||
@@ -61,16 +69,20 @@ public class InoculatorRecipeCategory extends BlankRecipeCategory<InoculatorReci
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, InoculatorRecipeWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IDrawable tankOverlay = GeneticsJeiPlugin.drawables.getTankOverlay();
|
||||
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
|
||||
fluidStacks.init(Inoculator.TANK_VEKTOR, true, 1, 1, 16, 58, 100, false, tankOverlay);
|
||||
fluidStacks.set(ingredients);
|
||||
if (!splicer) {
|
||||
IDrawable tankOverlay = GeneticsJeiPlugin.drawables.getTankOverlay();
|
||||
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
|
||||
fluidStacks.init(Inoculator.TANK_VEKTOR, 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, 21);
|
||||
itemStacks.init(2, false, 92, 21);
|
||||
|
||||
recipeWrapper.setCurrentIngredients(itemStacks.getGuiIngredients());
|
||||
|
||||
IFocus<?> focus = recipeLayout.getFocus();
|
||||
Object focusValue = focus.getValue();
|
||||
if (focusValue instanceof ItemStack) {
|
||||
|
||||
+16
-2
@@ -3,7 +3,9 @@ package binnie.genetics.integration.jei.inoculator;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.genetics.item.ItemSerum;
|
||||
import binnie.genetics.item.ItemSerumArray;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
@@ -33,8 +35,20 @@ public class InoculatorRecipeMaker {
|
||||
ItemStack serum = ItemSerum.create(new Gene(species, speciesChromosomeType, root));
|
||||
serum.setItemDamage(0); // set fully charged
|
||||
|
||||
InoculatorRecipeWrapper recipeWrapper = new InoculatorRecipeWrapper(serum, memberStack);
|
||||
recipes.add(recipeWrapper);
|
||||
recipes.add(new InoculatorRecipeWrapper(serum, memberStack));
|
||||
recipes.add(new SplicerRecipeWrapper(serum, memberStack));
|
||||
|
||||
ItemStack serumArray = ItemSerumArray.create(new Gene(species, speciesChromosomeType, root));
|
||||
serumArray.setItemDamage(0); // set fully charged
|
||||
for (IChromosomeType chromosomeType : root.getKaryotype()) {
|
||||
if (chromosomeType != speciesChromosomeType) {
|
||||
IAllele allele = defaultTemplate[chromosomeType.ordinal()];
|
||||
Engineering.addGene(serumArray, new Gene(allele, chromosomeType, root));
|
||||
}
|
||||
}
|
||||
|
||||
recipes.add(new InoculatorRecipeWrapper(serumArray, memberStack));
|
||||
recipes.add(new SplicerRecipeWrapper(serumArray, memberStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+62
-1
@@ -2,23 +2,39 @@ package binnie.genetics.integration.jei.inoculator;
|
||||
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.machine.inoculator.InoculatorLogic;
|
||||
import binnie.genetics.machine.splicer.SplicerLogic;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
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 org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.awt.Color;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
public class InoculatorRecipeWrapper extends BlankRecipeWrapper {
|
||||
private static final FluidStack BACTERIA_VECTOR = GeneticLiquid.BacteriaVector.get(InoculatorLogic.BACTERIA_PER_PROCESS);
|
||||
|
||||
private final ItemStack inputSerum;
|
||||
private final ItemStack wildcardTarget;
|
||||
private final boolean splicer;
|
||||
@Nullable
|
||||
private Map<Integer, ? extends IGuiIngredient<ItemStack>> currentIngredients;
|
||||
|
||||
public InoculatorRecipeWrapper(ItemStack inputSerum, ItemStack wildcardTarget) {
|
||||
this(inputSerum, wildcardTarget, false);
|
||||
}
|
||||
|
||||
protected InoculatorRecipeWrapper(ItemStack inputSerum, ItemStack wildcardTarget, boolean splicer) {
|
||||
this.inputSerum = inputSerum;
|
||||
this.wildcardTarget = wildcardTarget;
|
||||
this.splicer = splicer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,12 +46,56 @@ public class InoculatorRecipeWrapper extends BlankRecipeWrapper {
|
||||
|
||||
ingredients.setOutput(ItemStack.class, wildcardTarget);
|
||||
|
||||
ingredients.setInput(FluidStack.class, BACTERIA_VECTOR);
|
||||
if (!splicer) {
|
||||
ingredients.setInput(FluidStack.class, BACTERIA_VECTOR);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentIngredients(Map<Integer, ? extends IGuiIngredient<ItemStack>> currentIngredients) {
|
||||
this.currentIngredients = currentIngredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
if (currentIngredients == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack inputSerum = null;
|
||||
ItemStack targetStack = null;
|
||||
|
||||
IGuiIngredient<ItemStack> guiIngredient = currentIngredients.get(0);
|
||||
if (guiIngredient != null) {
|
||||
inputSerum = guiIngredient.getDisplayedIngredient();
|
||||
}
|
||||
guiIngredient = currentIngredients.get(1);
|
||||
if (guiIngredient != null) {
|
||||
targetStack = guiIngredient.getDisplayedIngredient();
|
||||
}
|
||||
|
||||
if (inputSerum != null && targetStack != null) {
|
||||
int power;
|
||||
int processTicks;
|
||||
if (splicer) {
|
||||
int numGenes = SplicerLogic.getGenesToUse(inputSerum, targetStack);
|
||||
power = SplicerLogic.getProcessEnergy(numGenes);
|
||||
processTicks = SplicerLogic.getProcessLength(numGenes);
|
||||
} else {
|
||||
power = InoculatorLogic.getProcessBaseEnergy(inputSerum);
|
||||
processTicks = InoculatorLogic.getProcessLength(inputSerum);
|
||||
}
|
||||
|
||||
// todo: 1.11 use MinecraftForgeClient#getLocale() for integer formatting
|
||||
NumberFormat decimalFormat = DecimalFormat.getIntegerInstance();
|
||||
String powerString = decimalFormat.format(power) + " RF";
|
||||
int xPower = 15 + (recipeWidth - minecraft.fontRendererObj.getStringWidth(powerString)) / 2;
|
||||
minecraft.fontRendererObj.drawString(powerString, xPower, 5, Color.gray.getRGB());
|
||||
|
||||
// todo: find a localized duration formatter
|
||||
String processTime = DurationFormatUtils.formatDurationWords(processTicks * 1000 / 20, true, true);
|
||||
int xTime = 15 + (recipeWidth - minecraft.fontRendererObj.getStringWidth(processTime)) / 2;
|
||||
minecraft.fontRendererObj.drawString(processTime, xTime, 45, Color.gray.getRGB());
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getInputSerum() {
|
||||
@@ -45,4 +105,5 @@ public class InoculatorRecipeWrapper extends BlankRecipeWrapper {
|
||||
public ItemStack getWildcardTarget() {
|
||||
return wildcardTarget;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package binnie.genetics.integration.jei.inoculator;
|
||||
|
||||
import binnie.genetics.integration.jei.RecipeUids;
|
||||
|
||||
public class SplicerRecipeCategory extends InoculatorRecipeCategory {
|
||||
public SplicerRecipeCategory() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return RecipeUids.SPLICER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Splicing";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package binnie.genetics.integration.jei.inoculator;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SplicerRecipeWrapper extends InoculatorRecipeWrapper {
|
||||
public SplicerRecipeWrapper(ItemStack inputSerum, ItemStack wildcardTarget) {
|
||||
super(inputSerum, wildcardTarget, true);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public abstract class ItemGene extends ItemCore {
|
||||
public abstract String getItemStackDisplayName(final ItemStack p0);
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List<ItemStack> itemList) {
|
||||
}
|
||||
|
||||
public abstract IGeneItem getGeneItem(final ItemStack p0);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ItemSerum extends ItemGene implements IItemSerum {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List<ItemStack> itemList) {
|
||||
for (final ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
final Map<IChromosomeType, List<IAllele>> chromosomeMap = Binnie.Genetics.getChromosomeMap(root);
|
||||
for (final Map.Entry<IChromosomeType, List<IAllele>> entry : chromosomeMap.entrySet()) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ItemSerumArray extends ItemGene implements IItemSerum {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List<ItemStack> itemList) {
|
||||
for (final ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
for (final IIndividual template : root.getIndividualTemplates()) {
|
||||
if (template.getGenome().getPrimary().isSecret()) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package binnie.genetics.machine.splicer;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ComponentProcess;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.genetics.Genetics;
|
||||
@@ -14,38 +14,58 @@ import forestry.api.genetics.IIndividual;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class SplicerLogic extends ComponentProcessSetCost implements IProcess {
|
||||
int nOfGenes;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
float n = this.getNumberOfGenes();
|
||||
public class SplicerLogic extends ComponentProcess implements IProcess {
|
||||
public static int PROCESS_ENERGY = 12000000;
|
||||
public static int PROCESS_LENGTH = 1200;
|
||||
|
||||
public static int getProcessLength(int numberOfGenes) {
|
||||
float n = numberOfGenes;
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
// Fix for / by 0
|
||||
int temp = (int) (super.getProcessLength() * n);
|
||||
int temp = (int) (PROCESS_LENGTH * n);
|
||||
return temp != 0 ? temp : 1;
|
||||
}
|
||||
|
||||
public static int getProcessEnergy(int numberOfGenes) {
|
||||
float n = numberOfGenes;
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
return (int) (PROCESS_ENERGY * n);
|
||||
}
|
||||
|
||||
private int nOfGenes;
|
||||
|
||||
public SplicerLogic(final Machine machine) {
|
||||
super(machine);
|
||||
this.nOfGenes = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
int n = this.getNumberOfGenes();
|
||||
return getProcessLength(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
float n = this.getNumberOfGenes();
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
return (int) (super.getProcessEnergy() * n);
|
||||
int n = this.getNumberOfGenes();
|
||||
return getProcessEnergy(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
this.nOfGenes = this.getGenesToUse();
|
||||
}
|
||||
|
||||
protected int getGenesToUse() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
this.nOfGenes = getGenesToUse(serum, target);
|
||||
}
|
||||
|
||||
public static int getGenesToUse(@Nullable ItemStack serum, @Nullable ItemStack target) {
|
||||
if (serum == null || target == null) {
|
||||
return 1;
|
||||
}
|
||||
@@ -82,11 +102,6 @@ public class SplicerLogic extends ComponentProcessSetCost implements IProcess {
|
||||
return "Splicing in " + n + ((f > 1) ? ("/" + f) : "") + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
public SplicerLogic(final Machine machine) {
|
||||
super(machine, 12000000, 1200);
|
||||
this.nOfGenes = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(Splicer.SLOT_TARGET)) {
|
||||
@@ -147,9 +162,8 @@ public class SplicerLogic extends ComponentProcessSetCost implements IProcess {
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
final IGene[] arr$;
|
||||
final IGene[] genes = arr$ = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (final IGene gene : arr$) {
|
||||
final IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (final IGene gene : genes) {
|
||||
Splicer.setGene(gene, target, 0);
|
||||
Splicer.setGene(gene, target, 1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user