Add NEI support for Genetics
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package binnie.core.nei;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
public class NEIUtils {
|
||||
public static FluidStack getFluidStack(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
FluidStack fluidStack = null;
|
||||
if (stack.getItem() instanceof IFluidContainerItem) {
|
||||
fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
|
||||
}
|
||||
|
||||
if (fluidStack == null) {
|
||||
fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||
}
|
||||
|
||||
if (fluidStack == null && Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock) {
|
||||
Fluid fluid = ((IFluidBlock) Block.getBlockFromItem(stack.getItem())).getFluid();
|
||||
if (fluid != null) {
|
||||
fluidStack = new FluidStack(fluid, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
return fluidStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean areFluidsSameType(FluidStack fluidStack1, FluidStack fluidStack2) {
|
||||
if (fluidStack1 != null && fluidStack2 != null) {
|
||||
return fluidStack1.getFluid() == fluidStack2.getFluid();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package binnie.core.nei;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PositionedFluidTank {
|
||||
|
||||
public FluidTank[] tanks;
|
||||
public FluidTank tank;
|
||||
public Rectangle position;
|
||||
public String overlayTexture;
|
||||
public Point overlayTexturePos;
|
||||
public boolean flowingTexture = false;
|
||||
public boolean showAmount = true;
|
||||
public boolean perTick = false;
|
||||
|
||||
public PositionedFluidTank(FluidTank[] tanks, Rectangle position, String overlayTexture, Point overlayTexturePos) {
|
||||
this.position = position;
|
||||
this.tanks = tanks;
|
||||
this.tank = tanks[0];
|
||||
this.overlayTexture = overlayTexture;
|
||||
this.overlayTexturePos = overlayTexturePos;
|
||||
}
|
||||
|
||||
public PositionedFluidTank(Collection<FluidStack> fluids, int capacity, Rectangle position, String overlayTexture, Point overlayTexturePos) {
|
||||
this(createFluidTanks(capacity, fluids), position, overlayTexture, overlayTexturePos);
|
||||
}
|
||||
|
||||
public PositionedFluidTank(FluidStack fluid, int capacity, Rectangle position, String overlayTexture, Point overlayTexturePos) {
|
||||
this(createFluidTanks(capacity, Collections.singletonList(fluid)), position, overlayTexture, overlayTexturePos);
|
||||
}
|
||||
|
||||
public PositionedFluidTank(FluidStack fluid, int capacity, Rectangle position) {
|
||||
this(fluid, capacity, position, null, null);
|
||||
}
|
||||
|
||||
private static FluidTank[] createFluidTanks(int capacity, Collection<FluidStack> fluidStacks) {
|
||||
FluidTank[] tanks = new FluidTank[fluidStacks.size()];
|
||||
int i = 0;
|
||||
for (FluidStack fluidStack : fluidStacks) {
|
||||
tanks[i++] = new FluidTank(fluidStacks != null ? fluidStack.copy() : null, capacity);
|
||||
}
|
||||
return tanks;
|
||||
}
|
||||
|
||||
public List<String> handleTooltip(List<String> currenttip) {
|
||||
if (this.tank == null || this.tank.getFluid() == null || this.tank.getFluid().getFluid() == null || this.tank.getFluid().amount <= 0) {
|
||||
return currenttip;
|
||||
}
|
||||
currenttip.add(this.tank.getFluid().getLocalizedName());
|
||||
if (this.showAmount) {
|
||||
currenttip.add(EnumChatFormatting.GRAY.toString() + this.tank.getFluid().amount + (this.perTick ? " mB/t" : " mB"));
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public boolean transfer(boolean usage) {
|
||||
if (this.tank.getFluid() != null && this.tank.getFluid().amount > 0) {
|
||||
if (usage) {
|
||||
return GuiUsageRecipe.openRecipeGui("liquid", this.tank.getFluid());
|
||||
} else {
|
||||
return GuiCraftingRecipe.openRecipeGui("liquid", this.tank.getFluid());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
if (this.tank == null || this.tank.getFluid() == null || this.tank.getFluid().getFluid() == null || this.tank.getFluid().amount <= 0) {
|
||||
return;
|
||||
}
|
||||
final IIcon fluidIcon;
|
||||
if (this.flowingTexture && this.tank.getFluid().getFluid().getFlowingIcon() != null) {
|
||||
fluidIcon = this.tank.getFluid().getFluid().getFlowingIcon();
|
||||
} else if (this.tank.getFluid().getFluid().getStillIcon() != null) {
|
||||
fluidIcon = this.tank.getFluid().getFluid().getStillIcon();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
GuiDraw.changeTexture(TextureMap.locationBlocksTexture);
|
||||
int color = this.tank.getFluid().getFluid().getColor(this.tank.getFluid());
|
||||
GL11.glColor3ub((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF));
|
||||
|
||||
int amount = Math.max(Math.min(this.position.height, this.tank.getFluid().amount * this.position.height / this.tank.getCapacity()), 1);
|
||||
int posY = this.position.y + this.position.height - amount;
|
||||
|
||||
for (int i = 0; i < this.position.width; i += 16) {
|
||||
for (int j = 0; j < amount; j += 16) {
|
||||
int drawWidth = Math.min(this.position.width - i, 16);
|
||||
int drawHeight = Math.min(amount - j, 16);
|
||||
|
||||
int drawX = this.position.x + i;
|
||||
int drawY = posY + j;
|
||||
|
||||
double minU = fluidIcon.getMinU();
|
||||
double maxU = fluidIcon.getMaxU();
|
||||
double minV = fluidIcon.getMinV();
|
||||
double maxV = fluidIcon.getMaxV();
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(drawX, drawY + drawHeight, 0, minU, minV + (maxV - minV) * drawHeight / 16F);
|
||||
tessellator.addVertexWithUV(drawX + drawWidth, drawY + drawHeight, 0, minU + (maxU - minU) * drawWidth / 16F, minV + (maxV - minV) * drawHeight / 16F);
|
||||
tessellator.addVertexWithUV(drawX + drawWidth, drawY, 0, minU + (maxU - minU) * drawWidth / 16F, minV);
|
||||
tessellator.addVertexWithUV(drawX, drawY, 0, minU, minV);
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.overlayTexture != null && this.overlayTexturePos != null) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(this.overlayTexture);
|
||||
GuiDraw.drawTexturedModalRect(this.position.x, this.position.y, this.overlayTexturePos.x, this.overlayTexturePos.y, this.position.width, this.position.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPermutationToRender(int index) {
|
||||
this.tank = this.tanks[index];
|
||||
}
|
||||
|
||||
public int getPermutationCount() {
|
||||
return this.tanks.length;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package binnie.core.nei;
|
||||
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PositionedStackAdv extends PositionedStack {
|
||||
|
||||
private final List<String> tooltip = new ArrayList<>();
|
||||
|
||||
public PositionedStackAdv(Object object, int x, int y) {
|
||||
super(object, x, y);
|
||||
}
|
||||
|
||||
public PositionedStackAdv(Object object, int x, int y, List<String> tooltip) {
|
||||
super(object, x, y);
|
||||
this.addToTooltip(tooltip);
|
||||
}
|
||||
|
||||
public Rectangle getRect() {
|
||||
return new Rectangle(this.relx - 1, this.rely - 1, 18, 18);
|
||||
}
|
||||
|
||||
public List<String> handleTooltip(GuiRecipe guiRecipe, List<String> currenttip) {
|
||||
if (!this.tooltip.isEmpty()) {
|
||||
for (String tip : this.tooltip) {
|
||||
currenttip.add(tip);
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public PositionedStackAdv addToTooltip(List<String> lines) {
|
||||
for (String tip : lines) {
|
||||
this.tooltip.add(tip);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public PositionedStackAdv addToTooltip(String line) {
|
||||
this.tooltip.add(line);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package binnie.core.nei;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
|
||||
|
||||
public void prepare() {
|
||||
}
|
||||
|
||||
public void changeToGuiTexture() {
|
||||
GuiDraw.changeTexture(this.getGuiTexture());
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public void addTransferRect(int x, int y, int width, int height) {
|
||||
this.transferRects.add(new RecipeTransferRect(new Rectangle(x, y, width, height), this.getOverlayIdentifier()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int recipe) {
|
||||
super.drawForeground(recipe);
|
||||
this.drawFluidTanks(recipe);
|
||||
this.changeToGuiTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("liquid") && results[0] instanceof FluidStack && ((FluidStack) results[0]).getFluid() != null) {
|
||||
this.loadCraftingRecipes((FluidStack) results[0]);
|
||||
} else if (outputId.equals(this.getOverlayIdentifier())) {
|
||||
this.loadAllRecipes();
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadAllRecipes() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
FluidStack fluid = NEIUtils.getFluidStack(result);
|
||||
if (fluid != null && fluid.getFluid() != null) {
|
||||
this.loadCraftingRecipes(fluid);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(FluidStack result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients) {
|
||||
if (inputId.equals("liquid") && ingredients[0] instanceof FluidStack && ((FluidStack) ingredients[0]).getFluid() != null) {
|
||||
this.loadUsageRecipes((FluidStack) ingredients[0]);
|
||||
} else {
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingred) {
|
||||
FluidStack fluid = NEIUtils.getFluidStack(ingred);
|
||||
if (fluid != null && fluid.getFluid() != null) {
|
||||
this.loadUsageRecipes(fluid);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUsageRecipes(FluidStack ingredient) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe guiRecipe, List<String> currenttip, int recipe) {
|
||||
super.handleTooltip(guiRecipe, currenttip, recipe);
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
if (GuiContainerManager.shouldShowTooltip(guiRecipe)) {
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
Point offset = guiRecipe.getRecipePosition(recipe);
|
||||
Point relMouse = new Point(mouse.x - (guiRecipe.width - 176) / 2 - offset.x, mouse.y - (guiRecipe.height - Math.min(Math.max(guiRecipe.height - 68, 166), 370)) / 2 - 10 - offset.y);
|
||||
currenttip = this.provideTooltip(guiRecipe, currenttip, crecipe, relMouse);
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public List<String> provideTooltip(GuiRecipe guiRecipe, List<String> currenttip, CachedBaseRecipe crecipe, Point relMouse) {
|
||||
if (crecipe.getFluidTanks() != null) {
|
||||
for (PositionedFluidTank tank : crecipe.getFluidTanks()) {
|
||||
if (tank.position.contains(relMouse)) {
|
||||
tank.handleTooltip(currenttip);
|
||||
}
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiRecipe guiRecipe, ItemStack itemStack, List<String> currenttip, int recipe) {
|
||||
super.handleItemTooltip(guiRecipe, itemStack, currenttip, recipe);
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
Point offset = guiRecipe.getRecipePosition(recipe);
|
||||
Point relMouse = new Point(mouse.x - (guiRecipe.width - 176) / 2 - offset.x, mouse.y - (guiRecipe.height - Math.min(Math.max(guiRecipe.height - 68, 166), 370)) / 2 - 10 - offset.y);
|
||||
|
||||
currenttip = this.provideItemTooltip(guiRecipe, itemStack, currenttip, crecipe, relMouse);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public List<String> provideItemTooltip(GuiRecipe guiRecipe, ItemStack itemStack, List<String> currenttip, CachedBaseRecipe crecipe, Point relMouse) {
|
||||
for (PositionedStack stack : crecipe.getIngredients()) {
|
||||
if (stack instanceof PositionedStackAdv && ((PositionedStackAdv) stack).getRect().contains(relMouse)) {
|
||||
currenttip = ((PositionedStackAdv) stack).handleTooltip(guiRecipe, currenttip);
|
||||
}
|
||||
}
|
||||
for (PositionedStack stack : crecipe.getOtherStacks()) {
|
||||
if (stack instanceof PositionedStackAdv && ((PositionedStackAdv) stack).getRect().contains(relMouse)) {
|
||||
currenttip = ((PositionedStackAdv) stack).handleTooltip(guiRecipe, currenttip);
|
||||
}
|
||||
}
|
||||
PositionedStack stack = crecipe.getResult();
|
||||
if (stack instanceof PositionedStackAdv && ((PositionedStackAdv) stack).getRect().contains(relMouse)) {
|
||||
currenttip = ((PositionedStackAdv) stack).handleTooltip(guiRecipe, currenttip);
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) {
|
||||
if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) {
|
||||
if (this.transferFluidTank(gui, recipe, false)) {
|
||||
return true;
|
||||
}
|
||||
} else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) {
|
||||
if (this.transferFluidTank(gui, recipe, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.keyTyped(gui, keyChar, keyCode, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiRecipe gui, int button, int recipe) {
|
||||
if (button == 0) {
|
||||
if (this.transferFluidTank(gui, recipe, false)) {
|
||||
return true;
|
||||
}
|
||||
} else if (button == 1) {
|
||||
if (this.transferFluidTank(gui, recipe, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.mouseClicked(gui, button, recipe);
|
||||
}
|
||||
|
||||
protected boolean transferFluidTank(GuiRecipe guiRecipe, int recipe, boolean usage) {
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
|
||||
if (crecipe.getFluidTanks() != null) {
|
||||
for (PositionedFluidTank tank : crecipe.getFluidTanks()) {
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
Point offset = guiRecipe.getRecipePosition(recipe);
|
||||
Point relMouse = new Point(mouse.x - (guiRecipe.width - 176) / 2 - offset.x, mouse.y - (guiRecipe.height - Math.min(Math.max(guiRecipe.height - 68, 166), 370)) / 2 - 10 - offset.y);
|
||||
|
||||
if (tank.position.contains(relMouse)) {
|
||||
return tank.transfer(usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void drawFluidTanks(int recipe) {
|
||||
CachedRecipe cachedRecipe = this.arecipes.get(recipe);
|
||||
if (cachedRecipe instanceof CachedBaseRecipe) {
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) cachedRecipe;
|
||||
if (crecipe.getFluidTanks() != null) {
|
||||
for (PositionedFluidTank fluidTank : crecipe.getFluidTanks()) {
|
||||
fluidTank.draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class CachedBaseRecipe extends CachedRecipe {
|
||||
|
||||
public List<PositionedFluidTank> getFluidTanks() {
|
||||
List<PositionedFluidTank> tanks = new ArrayList<>();
|
||||
PositionedFluidTank tank = this.getFluidTank();
|
||||
if (tank != null) {
|
||||
tanks.add(tank);
|
||||
}
|
||||
return tanks;
|
||||
}
|
||||
|
||||
public PositionedFluidTank getFluidTank() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import binnie.genetics.item.ItemDatabase;
|
||||
import binnie.genetics.item.ItemSerumArray;
|
||||
import binnie.genetics.item.ModuleItem;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.nei.IMCForNEI;
|
||||
import binnie.genetics.proxy.Proxy;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
@@ -60,6 +61,7 @@ public class Genetics extends AbstractMod {
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
addModule(new ModuleItem());
|
||||
addModule(new ModuleMachine());
|
||||
IMCForNEI.IMCSender();
|
||||
preInit();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,14 @@ import binnie.core.machines.MachineUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IIncubatorRecipe {
|
||||
boolean isInputLiquid(FluidStack liquid);
|
||||
|
||||
boolean isInputLiquidSufficient(FluidStack liquid);
|
||||
|
||||
@Deprecated
|
||||
boolean isItemStack(ItemStack stack);
|
||||
|
||||
void doTask(MachineUtil machine);
|
||||
@@ -16,4 +19,18 @@ public interface IIncubatorRecipe {
|
||||
float getChance();
|
||||
|
||||
boolean roomForOutput(MachineUtil machine);
|
||||
|
||||
float getLossChance();
|
||||
|
||||
@Nullable
|
||||
FluidStack getInput();
|
||||
|
||||
@Nullable
|
||||
FluidStack getOutput();
|
||||
|
||||
@Nullable
|
||||
ItemStack getInputStack();
|
||||
|
||||
ItemStack getExpectedOutput();
|
||||
|
||||
}
|
||||
@@ -27,8 +27,8 @@ public class Acclimatiser {
|
||||
public static final int SLOT_TARGET = 4;
|
||||
public static final float ENERGY_PER_TICK = 2.0f;
|
||||
|
||||
protected static Map<ItemStack, Float> temperatureItems = new HashMap<>();
|
||||
protected static Map<ItemStack, Float> humidityItems = new HashMap<>();
|
||||
public static Map<ItemStack, Float> temperatureItems = new HashMap<>();
|
||||
public static Map<ItemStack, Float> humidityItems = new HashMap<>();
|
||||
|
||||
private static List<ToleranceSystem> toleranceSystems = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -2,12 +2,14 @@ package binnie.genetics.machine.incubator;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.MachineUtil;
|
||||
import binnie.genetics.api.IIncubatorRecipe;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -15,88 +17,36 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Incubator {
|
||||
public static final int[] SLOT_QUEUE = new int[]{0, 1, 2};
|
||||
public static final int[] SLOT_OUTPUT = new int[]{4, 5, 6};
|
||||
public static final int SLOT_INCUBATOR = 3;
|
||||
public static final int TANK_INPUT = 0;
|
||||
public static final int TANK_OUTPUT = 1;
|
||||
public static final float ENERGY_PER_TICK = 2.0f;
|
||||
public static final List<IIncubatorRecipe> RECIPES = new ArrayList<>();
|
||||
public static final int POWER_CAPACITY = 2000;
|
||||
public static final int INPUT_TANK_CAPACITY = 2000;
|
||||
public static final int OUTPU_TANK_CAPACITY = 2000;
|
||||
public static final int[] SLOT_QUEUE = new int[]{0, 1, 2};
|
||||
public static final int[] SLOT_OUTPUT = new int[]{4, 5, 6};
|
||||
public static final int SLOT_INCUBATOR = 3;
|
||||
public static final int TANK_INPUT = 0;
|
||||
public static final int TANK_OUTPUT = 1;
|
||||
public static final float ENERGY_PER_TICK = 2.0f;
|
||||
public static final List<IIncubatorRecipe> RECIPES = new ArrayList<>();
|
||||
public static final int POWER_CAPACITY = 2000;
|
||||
public static final int INPUT_TANK_CAPACITY = 2000;
|
||||
public static final int OUTPU_TANK_CAPACITY = 2000;
|
||||
|
||||
public static void addRecipes() {
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(Binnie.Liquid.getLiquidStack("water", 25), GeneticLiquid.GrowthMedium.get(25), 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
public static void addRecipes() {
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticsItems.GrowthMedium.get(1), Binnie.Liquid.getLiquidStack("water", 25), GeneticLiquid.GrowthMedium.get(25), 0.2f));
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(new ItemStack(Items.wheat), GeneticLiquid.GrowthMedium.get(25), GeneticLiquid.Bacteria.get(5), 0.2f));
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticsItems.GrowthMedium.get(1), GeneticLiquid.Bacteria.get(0), GeneticLiquid.Bacteria.get(5), 0.05f));
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(new ItemStack(Items.sugar), GeneticLiquid.Bacteria.get(2), null, 0.5f, 0.2f).setOutputStack(GeneticsItems.Enzyme.get(1)));
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticsItems.GrowthMedium.get(1), GeneticLiquid.BacteriaPoly.get(0), GeneticLiquid.BacteriaPoly.get(5), 0.05f));
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticsItems.GrowthMedium.get(1), GeneticLiquid.BacteriaVector.get(0), GeneticLiquid.BacteriaVector.get(5), 0.05f));
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(new ItemStack(Items.dye, 1, 15), GeneticLiquid.Bacteria.get(10), GeneticLiquid.BacteriaPoly.get(10), 0.1f));
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(new ItemStack(Items.blaze_powder), GeneticLiquid.Bacteria.get(10), GeneticLiquid.BacteriaVector.get(10), 0.05f));
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.GrowthMedium.get(25), GeneticLiquid.Bacteria.get(5), 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return new ItemStack(Items.wheat).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(0), GeneticLiquid.Bacteria.get(5), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(2), null, 0.5f, 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return stack.getItem() == Items.sugar;
|
||||
}
|
||||
}.setOutputStack(GeneticsItems.Enzyme.get(1)));
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.BacteriaPoly.get(0), GeneticLiquid.BacteriaPoly.get(5), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.BacteriaVector.get(0), GeneticLiquid.BacteriaVector.get(5), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(10), GeneticLiquid.BacteriaPoly.get(10), 0.1f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return new ItemStack(Items.dye, 1, 15).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(10), GeneticLiquid.BacteriaVector.get(10), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return new ItemStack(Items.blaze_powder).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.GrowthMedium.get(50), null, 1.0f, 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return Binnie.Genetics.getBeeRoot().isMember(stack) && Binnie.Genetics.getBeeRoot().getType(stack) == EnumBeeType.LARVAE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutputStack(MachineUtil machine) {
|
||||
ItemStack larvae = machine.getStack(SLOT_INCUBATOR);
|
||||
IBee bee = Binnie.Genetics.getBeeRoot().getMember(larvae);
|
||||
return Binnie.Genetics.getBeeRoot().getMemberStack(bee, EnumBeeType.DRONE.ordinal());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
AlleleManager.alleleRegistry.getRegisteredAlleles().values().forEach(iAllele -> {
|
||||
IAllele[] template = BeeManager.beeRoot.getTemplate(iAllele.getUID());
|
||||
if (template != null) {
|
||||
IIndividual individual = BeeManager.beeRoot.templateAsIndividual(template);
|
||||
ItemStack bee = BeeManager.beeRoot.getMemberStack(individual, EnumBeeType.LARVAE.ordinal());
|
||||
Incubator.RECIPES.add(new IncubatorRecipeLarvae(bee));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,142 +9,147 @@ import binnie.core.util.I18N;
|
||||
import binnie.genetics.api.IIncubatorRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class IncubatorComponentLogic extends ComponentProcessIndefinate implements IProcess {
|
||||
IIncubatorRecipe recipe;
|
||||
private Random rand;
|
||||
private boolean roomForOutput;
|
||||
IIncubatorRecipe recipe;
|
||||
private final Random rand;
|
||||
private boolean roomForOutput;
|
||||
|
||||
public IncubatorComponentLogic(Machine machine) {
|
||||
super(machine, Incubator.ENERGY_PER_TICK);
|
||||
recipe = null;
|
||||
rand = new Random();
|
||||
roomForOutput = true;
|
||||
}
|
||||
public IncubatorComponentLogic(Machine machine) {
|
||||
super(machine, Incubator.ENERGY_PER_TICK);
|
||||
recipe = null;
|
||||
rand = new Random();
|
||||
roomForOutput = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (recipe != null) {
|
||||
return super.canWork();
|
||||
}
|
||||
return new ErrorState(
|
||||
I18N.localise("genetics.machine.incubator.error.noRecipe.title"),
|
||||
I18N.localise("genetics.machine.incubator.error.noRecipe")
|
||||
);
|
||||
}
|
||||
private static boolean isStackValid(ItemStack stack, IIncubatorRecipe recipe) {
|
||||
return OreDictionary.itemMatches(recipe.getInputStack(), stack, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (recipe != null) {
|
||||
if (!recipe.isInputLiquidSufficient(getUtil().getFluid(Incubator.TANK_INPUT))) {
|
||||
return new ErrorState.InsufficientLiquid(
|
||||
I18N.localise("genetics.machine.incubator.error.noLiquid"),
|
||||
Incubator.TANK_INPUT
|
||||
);
|
||||
}
|
||||
if (!roomForOutput) {
|
||||
return new ErrorState.TankSpace(
|
||||
I18N.localise("genetics.machine.incubator.error.noRoom"),
|
||||
Incubator.TANK_OUTPUT
|
||||
);
|
||||
}
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (recipe != null) {
|
||||
return super.canWork();
|
||||
}
|
||||
return new ErrorState(
|
||||
I18N.localise("genetics.machine.incubator.error.noRecipe.title"),
|
||||
I18N.localise("genetics.machine.incubator.error.noRecipe")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
if (rand.nextInt(20) == 0 && recipe != null && rand.nextFloat() < recipe.getChance()) {
|
||||
recipe.doTask(getUtil());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (recipe != null) {
|
||||
if (!recipe.isInputLiquidSufficient(getUtil().getFluid(Incubator.TANK_INPUT))) {
|
||||
return new ErrorState.InsufficientLiquid(
|
||||
I18N.localise("genetics.machine.incubator.error.noLiquid"),
|
||||
Incubator.TANK_INPUT
|
||||
);
|
||||
}
|
||||
if (!roomForOutput) {
|
||||
return new ErrorState.TankSpace(
|
||||
I18N.localise("genetics.machine.incubator.error.noRoom"),
|
||||
Incubator.TANK_OUTPUT
|
||||
);
|
||||
}
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress() {
|
||||
return recipe != null;
|
||||
}
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
if (rand.nextInt(20) == 0 && recipe != null && rand.nextFloat() < recipe.getChance()) {
|
||||
recipe.doTask(getUtil());
|
||||
}
|
||||
}
|
||||
|
||||
private IIncubatorRecipe getRecipe(ItemStack stack, FluidStack liquid) {
|
||||
for (IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
boolean rightLiquid = recipe.isInputLiquid(liquid);
|
||||
boolean rightItem = recipe.isItemStack(stack);
|
||||
if (rightLiquid && rightItem) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean inProgress() {
|
||||
return recipe != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
private IIncubatorRecipe getRecipe(ItemStack stack, FluidStack liquid) {
|
||||
for (IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
boolean rightLiquid = recipe.isInputLiquid(liquid);
|
||||
boolean rightItem = isStackValid(stack, recipe);
|
||||
if (rightLiquid && rightItem) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
FluidStack liquid = getUtil().getFluid(Incubator.TANK_INPUT);
|
||||
ItemStack incubator = getUtil().getStack(Incubator.SLOT_INCUBATOR);
|
||||
if (recipe != null && (incubator == null || liquid == null || !recipe.isInputLiquid(liquid) || !recipe.isItemStack(incubator))) {
|
||||
recipe = null;
|
||||
ItemStack leftover = new TransferRequest(incubator, getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation()
|
||||
.transfer(true);
|
||||
getUtil().setStack(Incubator.SLOT_INCUBATOR, leftover);
|
||||
}
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (recipe == null) {
|
||||
if (liquid == null) {
|
||||
return;
|
||||
}
|
||||
FluidStack liquid = getUtil().getFluid(Incubator.TANK_INPUT);
|
||||
ItemStack incubator = getUtil().getStack(Incubator.SLOT_INCUBATOR);
|
||||
if (recipe != null && (incubator == null || liquid == null || !recipe.isInputLiquid(liquid) || !isStackValid(incubator, recipe))) {
|
||||
recipe = null;
|
||||
ItemStack leftover = new TransferRequest(incubator, getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation()
|
||||
.transfer(true);
|
||||
getUtil().setStack(Incubator.SLOT_INCUBATOR, leftover);
|
||||
}
|
||||
|
||||
if (incubator != null) {
|
||||
IIncubatorRecipe recipe = getRecipe(incubator, liquid);
|
||||
if (recipe != null) {
|
||||
this.recipe = recipe;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (recipe == null) {
|
||||
if (liquid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IIncubatorRecipe potential = null;
|
||||
int potentialSlot = 0;
|
||||
for (int slot : Incubator.SLOT_QUEUE) {
|
||||
ItemStack stack = getUtil().getStack(slot);
|
||||
if (stack == null || potential != null) {
|
||||
continue;
|
||||
}
|
||||
if (incubator != null) {
|
||||
IIncubatorRecipe recipe = getRecipe(incubator, liquid);
|
||||
if (recipe != null) {
|
||||
this.recipe = recipe;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (IIncubatorRecipe recipe2 : Incubator.RECIPES) {
|
||||
boolean rightLiquid = recipe2.isInputLiquid(liquid);
|
||||
boolean rightItem = recipe2.isItemStack(stack);
|
||||
if (rightLiquid && rightItem) {
|
||||
potential = recipe2;
|
||||
potentialSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
IIncubatorRecipe potential = null;
|
||||
int potentialSlot = 0;
|
||||
for (int slot : Incubator.SLOT_QUEUE) {
|
||||
ItemStack stack = getUtil().getStack(slot);
|
||||
if (stack == null || potential != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (potential != null) {
|
||||
TransferRequest removal = new TransferRequest(incubator, getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation();
|
||||
for (IIncubatorRecipe recipe2 : Incubator.RECIPES) {
|
||||
boolean rightLiquid = recipe2.isInputLiquid(liquid);
|
||||
boolean rightItem = isStackValid(stack, recipe2);
|
||||
if (rightLiquid && rightItem) {
|
||||
potential = recipe2;
|
||||
potentialSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (removal.transfer(false) == null) {
|
||||
recipe = potential;
|
||||
}
|
||||
if (potential != null) {
|
||||
TransferRequest removal = new TransferRequest(incubator, getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation();
|
||||
|
||||
removal.transfer(true);
|
||||
ItemStack stack2 = getUtil().getStack(potentialSlot);
|
||||
getUtil().setStack(potentialSlot, null);
|
||||
getUtil().setStack(Incubator.SLOT_INCUBATOR, stack2);
|
||||
}
|
||||
}
|
||||
if (removal.transfer(false) == null) {
|
||||
recipe = potential;
|
||||
}
|
||||
|
||||
if (recipe != null) {
|
||||
roomForOutput = recipe.roomForOutput(getUtil());
|
||||
}
|
||||
}
|
||||
removal.transfer(true);
|
||||
ItemStack stack2 = getUtil().getStack(potentialSlot);
|
||||
getUtil().setStack(potentialSlot, null);
|
||||
getUtil().setStack(Incubator.SLOT_INCUBATOR, stack2);
|
||||
}
|
||||
}
|
||||
|
||||
if (recipe != null) {
|
||||
roomForOutput = recipe.roomForOutput(getUtil());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,90 +6,126 @@ import binnie.genetics.api.IIncubatorRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class IncubatorRecipe implements IIncubatorRecipe {
|
||||
protected FluidStack input;
|
||||
protected FluidStack output;
|
||||
protected float lossChance;
|
||||
protected ItemStack outputStack;
|
||||
protected float tickChance;
|
||||
public class IncubatorRecipe implements IIncubatorRecipe {
|
||||
|
||||
public IncubatorRecipe(FluidStack input, FluidStack output, float lossChance) {
|
||||
this(input, output, lossChance, 1.0f);
|
||||
}
|
||||
private final FluidStack input;
|
||||
@Nullable
|
||||
private final FluidStack output;
|
||||
private final float lossChance;
|
||||
private final float tickChance;
|
||||
private final ItemStack inputStack;
|
||||
@Nullable
|
||||
private ItemStack outputStack;
|
||||
|
||||
public IncubatorRecipe(FluidStack input, FluidStack output, float lossChance, float chance) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.lossChance = lossChance;
|
||||
tickChance = chance;
|
||||
}
|
||||
public IncubatorRecipe(ItemStack inputStack, final FluidStack input, @Nullable final FluidStack output, final float lossChance) {
|
||||
this(inputStack, input, output, lossChance, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance() {
|
||||
return tickChance;
|
||||
}
|
||||
public IncubatorRecipe(ItemStack inputStack, final FluidStack input, @Nullable final FluidStack output, final float lossChance, final float chance) {
|
||||
this.inputStack = inputStack;
|
||||
this.outputStack = null;
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.lossChance = lossChance;
|
||||
this.tickChance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputLiquid(FluidStack liquid) {
|
||||
return liquid != null && input.isFluidEqual(liquid);
|
||||
}
|
||||
@Override
|
||||
public float getChance() {
|
||||
return this.tickChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputLiquidSufficient(FluidStack liquid) {
|
||||
return liquid != null && liquid.amount >= 500;
|
||||
}
|
||||
@Override
|
||||
public float getLossChance() {
|
||||
return lossChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doTask(MachineUtil machine) {
|
||||
machine.drainTank(Incubator.TANK_INPUT, input.amount);
|
||||
if (output != null) {
|
||||
machine.fillTank(Incubator.TANK_OUTPUT, output);
|
||||
}
|
||||
@Override
|
||||
public boolean isInputLiquid(final FluidStack fluid) {
|
||||
return fluid != null && this.input.isFluidEqual(fluid);
|
||||
}
|
||||
|
||||
outputStack = getOutputStack(machine);
|
||||
if (outputStack != null) {
|
||||
ItemStack output = outputStack.copy();
|
||||
TransferRequest product = new TransferRequest(output, machine.getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation();
|
||||
product.transfer(true);
|
||||
}
|
||||
@Override
|
||||
public boolean isInputLiquidSufficient(final FluidStack fluid) {
|
||||
return fluid != null && fluid.amount >= this.input.amount;
|
||||
}
|
||||
|
||||
Random rand = machine.getRandom();
|
||||
if (rand.nextFloat() < lossChance) {
|
||||
machine.decreaseStack(Incubator.SLOT_INCUBATOR, 1);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IncubatorRecipe setOutputStack(ItemStack stack) {
|
||||
outputStack = stack;
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public FluidStack getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
protected ItemStack getOutputStack(MachineUtil util) {
|
||||
return outputStack;
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
public FluidStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean roomForOutput(MachineUtil machine) {
|
||||
if (output != null && !machine.isTankEmpty(Incubator.TANK_OUTPUT)) {
|
||||
if (!machine.getFluid(Incubator.TANK_OUTPUT).isFluidEqual(output) ||
|
||||
!machine.spaceInTank(Incubator.TANK_OUTPUT, output.amount)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ItemStack getInputStack() {
|
||||
return inputStack;
|
||||
}
|
||||
|
||||
ItemStack outputStack = getOutputStack(machine);
|
||||
if (outputStack == null) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getExpectedOutput() {
|
||||
return outputStack;
|
||||
}
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
TransferRequest product = new TransferRequest(output, machine.getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation();
|
||||
return product.transfer(false) == null;
|
||||
}
|
||||
@Override
|
||||
public void doTask(final MachineUtil machine) {
|
||||
machine.drainTank(Incubator.TANK_INPUT, this.input.amount);
|
||||
if (this.output != null) {
|
||||
machine.fillTank(Incubator.TANK_OUTPUT, this.output);
|
||||
}
|
||||
this.outputStack = this.getOutputStack(machine);
|
||||
if (this.outputStack != null) {
|
||||
final ItemStack output = this.outputStack.copy();
|
||||
final TransferRequest product = new TransferRequest(output, machine.getInventory()).setTargetSlots(Incubator.SLOT_OUTPUT).ignoreValidation();
|
||||
product.transfer(true);
|
||||
}
|
||||
final Random rand = machine.getRandom();
|
||||
if (rand.nextFloat() < this.lossChance) {
|
||||
machine.decreaseStack(Incubator.SLOT_INCUBATOR, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public IncubatorRecipe setOutputStack(final ItemStack stack) {
|
||||
this.outputStack = stack;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected ItemStack getOutputStack(final MachineUtil util) {
|
||||
return getExpectedOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean roomForOutput(final MachineUtil machine) {
|
||||
if (this.output != null && !machine.isTankEmpty(1)) {
|
||||
if (!this.output.isFluidEqual(machine.getFluid(Incubator.TANK_OUTPUT))) {
|
||||
return false;
|
||||
}
|
||||
if (!machine.spaceInTank(Incubator.TANK_OUTPUT, this.output.amount)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack outputStack = getOutputStack(machine);
|
||||
if (outputStack == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
TransferRequest product = new TransferRequest(output, machine.getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation();
|
||||
return product.transfer(false) == null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package binnie.genetics.machine.incubator;
|
||||
|
||||
import binnie.core.machines.MachineUtil;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class IncubatorRecipeLarvae extends IncubatorRecipe {
|
||||
public IncubatorRecipeLarvae(ItemStack beeLarvaeWildcard) {
|
||||
super(beeLarvaeWildcard, GeneticLiquid.GrowthMedium.get(50), null, 1.0f, 0.05f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutputStack(final MachineUtil machine) {
|
||||
final ItemStack larvae = machine.getStack(Incubator.SLOT_INCUBATOR);
|
||||
final IBee bee = BeeManager.beeRoot.getMember(larvae);
|
||||
if (bee == null) {
|
||||
return null;
|
||||
}
|
||||
return BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getExpectedOutput() {
|
||||
return BeeManager.beeRoot.getMemberStack(BeeManager.beeRoot.getMember(this.getInputStack()), EnumBeeType.DRONE.ordinal());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.nei.PositionedStackAdv;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.machine.acclimatiser.Acclimatiser;
|
||||
import binnie.genetics.machine.acclimatiser.ToleranceType;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AcclimatiserRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
private static final List<AcclimatiserRecipe> recipes = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
Acclimatiser.temperatureItems.forEach((resource, effect) -> {
|
||||
List<ItemStack> targets = new ArrayList<>();
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
targets.add(Mods.forestry.stack("beeDroneGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("beePrincessGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("beeQueenGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("beeLarvaeGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
targets.add(Mods.forestry.stack("butterflyGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("caterpillarGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("serumGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
targets.add(new ItemStack(Botany.flowerItem, 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(new ItemStack(Botany.seed, 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(new ItemStack(Botany.pollen, 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
recipes.add(new AcclimatiserRecipe(targets, resource, effect, ToleranceType.Temperature));
|
||||
});
|
||||
Acclimatiser.humidityItems.forEach((resource, effect) -> {
|
||||
List<ItemStack> targets = new ArrayList<>();
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
targets.add(Mods.forestry.stack("beeDroneGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("beePrincessGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("beeQueenGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("beeLarvaeGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
targets.add(Mods.forestry.stack("butterflyGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("caterpillarGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(Mods.forestry.stack("serumGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
targets.add(new ItemStack(Botany.flowerItem, 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(new ItemStack(Botany.seed, 1, OreDictionary.WILDCARD_VALUE));
|
||||
targets.add(new ItemStack(Botany.pollen, 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
recipes.add(new AcclimatiserRecipe(targets, resource, effect, ToleranceType.Humidity));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.acclimatiser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/acclimatiser.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.machine.labMachine.acclimatiser");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(75, 21, 18, 7);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 76);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
for (AcclimatiserRecipe recipe : recipes) {
|
||||
this.arecipes.add(new CachedAcclimatiserRecipe(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (AcclimatiserRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getResource(), ingredient)) {
|
||||
this.arecipes.add(new CachedAcclimatiserRecipe(recipe));
|
||||
} else {
|
||||
for (ItemStack itemStack : recipe.getTarget()) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(itemStack, ingredient)) {
|
||||
this.arecipes.add(new CachedAcclimatiserRecipe(recipe));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class AcclimatiserRecipe {
|
||||
private final ItemStack[] target;
|
||||
private final ItemStack resource;
|
||||
private final float effect;
|
||||
private final ToleranceType type;
|
||||
|
||||
public AcclimatiserRecipe(Object target, ItemStack resource, float effect, ToleranceType type) {
|
||||
this.target = NEIServerUtils.extractRecipeItems(target);
|
||||
this.resource = resource;
|
||||
this.effect = effect;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ItemStack getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
public ItemStack[] getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public float getEffect() {
|
||||
return this.effect;
|
||||
}
|
||||
|
||||
public ToleranceType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CachedAcclimatiserRecipe extends CachedBaseRecipe {
|
||||
|
||||
public List<PositionedStack> target = new ArrayList<>();
|
||||
public PositionedStack resource;
|
||||
public float effect;
|
||||
public ToleranceType type;
|
||||
public List<PositionedStack> ingredients = new ArrayList<>();
|
||||
|
||||
public CachedAcclimatiserRecipe(AcclimatiserRecipe recipe) {
|
||||
if (recipe.getTarget() != null) {
|
||||
for (int i = 0; i < recipe.getTarget().length; i++) {
|
||||
target.add(new PositionedStack(recipe.getTarget()[i], 31 + 18 * (i > 5 ? i % 6 : i), 29 + 18 * (i / 6)));
|
||||
}
|
||||
this.resource = new PositionedStackAdv(recipe.getResource(), 76, 2)
|
||||
.addToTooltip(StatCollector.translateToLocal("genetics.nei.tip." + (recipe.getType().equals(ToleranceType.Temperature) ? "temperature" : "humidity")))
|
||||
.addToTooltip(StatCollector.translateToLocalFormatted("genetics.nei.tip.effect", recipe.getEffect()));
|
||||
this.effect = recipe.getEffect();
|
||||
this.type = recipe.getType();
|
||||
|
||||
this.ingredients.addAll(this.target);
|
||||
this.ingredients.add(this.resource);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 40, this.ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.item.ItemSequence;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AnalyserRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
private static final List<AnalyserRecipe> recipes = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
recipes.add(new AnalyserRecipe(new ItemStack(Genetics.itemSequencer, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
recipes.add(new AnalyserRecipe(Mods.forestry.stack("beeDroneGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new AnalyserRecipe(Mods.forestry.stack("beePrincessGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new AnalyserRecipe(Mods.forestry.stack("beeQueenGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new AnalyserRecipe(Mods.forestry.stack("beeLarvaeGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
if (BinnieCore.isArboricultureActive()) {
|
||||
recipes.add(new AnalyserRecipe(Mods.forestry.stack("sapling", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new AnalyserRecipe(Mods.forestry.stack("pollenFertile", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
recipes.add(new AnalyserRecipe(Mods.forestry.stack("butterflyGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new AnalyserRecipe(Mods.forestry.stack("caterpillarGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new AnalyserRecipe(Mods.forestry.stack("serumGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
recipes.add(new AnalyserRecipe(new ItemStack(Botany.flowerItem, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new AnalyserRecipe(new ItemStack(Botany.seed, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new AnalyserRecipe(new ItemStack(Botany.pollen, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.analyser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/analyser.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.machine.labMachine.analyser");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(50, 13, 66, 11);
|
||||
this.addTransferRect(50, 42, 66, 11);
|
||||
this.addTransferRect(50, 24, 24, 18);
|
||||
this.addTransferRect(92, 24, 24, 18);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 74);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(50, 13, 176, 0, 66, 40, 40, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
for (AnalyserRecipe recipe : recipes) {
|
||||
this.arecipes.add(new CachedAnalyser(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(GeneticsItems.DNADye.get(0), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
} else {
|
||||
for (AnalyserRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getAnalysable(), ingredient)) {
|
||||
this.arecipes.add(new CachedAnalyser(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class AnalyserRecipe {
|
||||
private final ItemStack analysable;
|
||||
|
||||
public AnalyserRecipe(ItemStack analysable) {
|
||||
this.analysable = analysable;
|
||||
}
|
||||
|
||||
public ItemStack getDNADye() {
|
||||
return GeneticsItems.DNADye.get(1);
|
||||
}
|
||||
|
||||
public ItemStack getAnalysable() {
|
||||
return this.analysable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CachedAnalyser extends CachedBaseRecipe {
|
||||
|
||||
public PositionedStack analysable;
|
||||
public PositionedStack dnaDye;
|
||||
public List<PositionedStack> ingredients = new ArrayList<>();
|
||||
|
||||
public CachedAnalyser(AnalyserRecipe recipe) {
|
||||
if (recipe.getAnalysable() != null) {
|
||||
List<ItemStack> analysableList = new ArrayList<>();
|
||||
|
||||
if (recipe.getAnalysable().getItem() instanceof ItemSequence) {
|
||||
for (ItemStack seq : ItemList.itemMap.get(Genetics.itemSequencer)) {
|
||||
for (int i = Genetics.itemSequencer.getMaxDamage(); i >= 0; i--) {
|
||||
ItemStack temp = seq.copy();
|
||||
temp.setItemDamage(i);
|
||||
analysableList.add(temp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (ItemStack analysable : ItemList.itemMap.get(recipe.getAnalysable().getItem())) {
|
||||
if (analysable.getTagCompound() != null) {
|
||||
analysableList.add(analysable.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.analysable = new PositionedStack(analysableList, 75, 25);
|
||||
this.dnaDye = new PositionedStack(recipe.getDNADye(), 75, 56);
|
||||
|
||||
this.ingredients.add(this.analysable);
|
||||
this.ingredients.add(this.dnaDye);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
this.analysable.setPermutationToRender(cycleticks / 40 % this.analysable.items.length);
|
||||
return this.ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.item.ItemSerumArray;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DatabaseRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
private static final List<DatabaseRecipe> recipes = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
recipes.add(new DatabaseRecipe(new ItemStack(Genetics.itemSerum, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new DatabaseRecipe(new ItemStack(Genetics.itemSerumArray, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.database";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/database.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.item.database.0.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(75, 7, 24, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 74);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(75, 7, 176, 0, 24, 17, 40, 0);
|
||||
|
||||
List<String> desc = GuiDraw.fontRenderer.listFormattedStringToWidth(StatCollector.translateToLocalFormatted("genetics.nei.tip.databaseDesc"), 140);
|
||||
for (int i = 0; i < desc.size(); i++) {
|
||||
GuiDraw.drawStringC(desc.get(i), 88, 44 + 12 * (i - 1), 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
for (DatabaseRecipe recipe : recipes) {
|
||||
this.arecipes.add(new CachedDatabaseRecipe(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (DatabaseRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getSerum(), result)) {
|
||||
this.arecipes.add(new CachedDatabaseRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (DatabaseRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getEmptySerum(), ingredient)) {
|
||||
this.arecipes.add(new CachedDatabaseRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class DatabaseRecipe {
|
||||
|
||||
private final ItemStack serum;
|
||||
|
||||
public DatabaseRecipe(ItemStack serum) {
|
||||
this.serum = serum;
|
||||
}
|
||||
|
||||
public ItemStack getSerum() {
|
||||
return this.serum;
|
||||
}
|
||||
|
||||
public ItemStack getEmptySerum() {
|
||||
return this.serum.getItem() instanceof ItemSerumArray ? GeneticsItems.EmptyGenome.get(1) : GeneticsItems.EmptySerum.get(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CachedDatabaseRecipe extends CachedBaseRecipe {
|
||||
|
||||
public PositionedStack serum;
|
||||
public PositionedStack emptySerum;
|
||||
|
||||
public CachedDatabaseRecipe(DatabaseRecipe recipe) {
|
||||
if (recipe.getSerum() != null) {
|
||||
List<ItemStack> serums = new ArrayList<>();
|
||||
|
||||
for (ItemStack serumStack : ItemList.itemMap.get(recipe.getSerum().getItem())) {
|
||||
if (serumStack.getTagCompound() != null) {
|
||||
ItemStack temp = serumStack.copy();
|
||||
temp.setItemDamage(temp.getMaxDamage());
|
||||
serums.add(temp);
|
||||
}
|
||||
}
|
||||
|
||||
this.emptySerum = new PositionedStack(recipe.getEmptySerum(), 53, 7);
|
||||
this.serum = new PositionedStack(serums, 105, 7);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient() {
|
||||
this.serum.setPermutationToRender(cycleticks / 40 % this.serum.items.length);
|
||||
return this.serum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return this.emptySerum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.nei.NEIUtils;
|
||||
import binnie.core.nei.PositionedFluidTank;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GenepoolRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
private static final List<GenepoolRecipe> recipes = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
recipes.add(new GenepoolRecipe(Mods.forestry.stack("beeDroneGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new GenepoolRecipe(Mods.forestry.stack("beePrincessGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new GenepoolRecipe(Mods.forestry.stack("beeQueenGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new GenepoolRecipe(Mods.forestry.stack("beeLarvaeGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
if (BinnieCore.isArboricultureActive()) {
|
||||
recipes.add(new GenepoolRecipe(Mods.forestry.stack("sapling", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new GenepoolRecipe(Mods.forestry.stack("pollenFertile", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
recipes.add(new GenepoolRecipe(Mods.forestry.stack("butterflyGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new GenepoolRecipe(Mods.forestry.stack("caterpillarGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new GenepoolRecipe(Mods.forestry.stack("serumGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
recipes.add(new GenepoolRecipe(new ItemStack(Botany.flowerItem, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new GenepoolRecipe(new ItemStack(Botany.seed, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new GenepoolRecipe(new ItemStack(Botany.pollen, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.genepool";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/genepool.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.machine.labMachine.genepool");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(75, 38, 24, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 74);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(75, 38, 176, 0, 24, 17, 40, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
for (GenepoolRecipe recipe : recipes) {
|
||||
this.arecipes.add(new CachedGenepoolRecipe(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(FluidStack result) {
|
||||
if (NEIUtils.areFluidsSameType(GeneticLiquid.RawDNA.get(0), result)) {
|
||||
this.loadAllRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(GeneticsItems.Enzyme.get(1), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
} else {
|
||||
for (GenepoolRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getInput(), ingredient)) {
|
||||
this.arecipes.add(new CachedGenepoolRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(FluidStack ingredient) {
|
||||
if (NEIUtils.areFluidsSameType(Binnie.Liquid.getLiquidStack("bioethanol", 0), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
private static class GenepoolRecipe {
|
||||
private final ItemStack inputStack;
|
||||
|
||||
public GenepoolRecipe(ItemStack inputStack) {
|
||||
this.inputStack = inputStack;
|
||||
}
|
||||
|
||||
public FluidStack getRawDNA() {
|
||||
int amount;
|
||||
EnumBeeType type = Binnie.Genetics.getBeeRoot().getType(this.inputStack);
|
||||
|
||||
switch (type) {
|
||||
case QUEEN:
|
||||
amount = 50;
|
||||
break;
|
||||
case PRINCESS:
|
||||
amount = 30;
|
||||
break;
|
||||
default:
|
||||
amount = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
return GeneticLiquid.RawDNA.get(amount);
|
||||
}
|
||||
|
||||
public ItemStack getEnzyme() {
|
||||
return GeneticsItems.Enzyme.get(1);
|
||||
}
|
||||
|
||||
public FluidStack getEthanol() {
|
||||
return Binnie.Liquid.getLiquidStack("bioethanol", (int) (getRawDNA().amount * 1.2));
|
||||
}
|
||||
|
||||
public ItemStack getInput() {
|
||||
return this.inputStack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CachedGenepoolRecipe extends CachedBaseRecipe {
|
||||
public List<PositionedFluidTank> tanks = new ArrayList<>();
|
||||
public List<PositionedStack> ingredients = new ArrayList<>();
|
||||
public PositionedStack input;
|
||||
public PositionedStack enzyme;
|
||||
|
||||
public CachedGenepoolRecipe(GenepoolRecipe recipe) {
|
||||
if (recipe.getInput() != null) {
|
||||
this.tanks.add(new PositionedFluidTank(recipe.getEthanol(), 100, new Rectangle(38, 6, 16, 58)));
|
||||
this.tanks.add(new PositionedFluidTank(recipe.getRawDNA(), 100, new Rectangle(119, 6, 16, 58)));
|
||||
this.enzyme = new PositionedStack(recipe.getEnzyme(), 58, 6);
|
||||
this.input = new PositionedStack(recipe.getInput(), 78, 6);
|
||||
this.ingredients.add(this.enzyme);
|
||||
this.ingredients.add(this.input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 40, this.ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedFluidTank> getFluidTanks() {
|
||||
return this.tanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class IMCForNEI {
|
||||
public static void IMCSender() {
|
||||
sendHandler("genetics.isolator", "Genetics:machine:0");
|
||||
sendHandler("genetics.sequencer", "Genetics:machine:1");
|
||||
sendHandler("genetics.polymeriser", "Genetics:machine:2");
|
||||
sendHandler("genetics.inoculator", "Genetics:machine:3");
|
||||
sendHandler("genetics.analyser", "Genetics:labMachine:1");
|
||||
sendHandler("genetics.incubator", "Genetics:labMachine:2");
|
||||
sendHandler("genetics.genepool", "Genetics:labMachine:3");
|
||||
sendHandler("genetics.acclimatiser", "Genetics:labMachine:4");
|
||||
sendHandler("genetics.splicer", "Genetics:advMachine:0");
|
||||
sendHandler("genetics.database", "Genetics:database:0");
|
||||
|
||||
sendCatalyst("genetics.isolator", "Genetics:machine:0");
|
||||
sendCatalyst("genetics.sequencer", "Genetics:machine:1");
|
||||
sendCatalyst("genetics.polymeriser", "Genetics:machine:2");
|
||||
sendCatalyst("genetics.inoculator", "Genetics:machine:3");
|
||||
sendCatalyst("genetics.database", "Genetics:database:0");
|
||||
sendCatalyst("genetics.database", "Genetics:database:1");
|
||||
sendCatalyst("genetics.database", "Genetics:labMachine:0");
|
||||
sendCatalyst("genetics.analyser", "Genetics:labMachine:1");
|
||||
sendCatalyst("genetics.incubator", "Genetics:labMachine:2");
|
||||
sendCatalyst("genetics.genepool", "Genetics:labMachine:3");
|
||||
sendCatalyst("genetics.acclimatiser", "Genetics:labMachine:4");
|
||||
sendCatalyst("genetics.splicer", "Genetics:advMachine:0");
|
||||
}
|
||||
|
||||
private static void sendHandler(String aName, String aBlock) {
|
||||
NBTTagCompound aNBT = new NBTTagCompound();
|
||||
aNBT.setString("handler", aName);
|
||||
aNBT.setString("modName", "Genetics");
|
||||
aNBT.setString("modId", "Genetics");
|
||||
aNBT.setBoolean("modRequired", true);
|
||||
aNBT.setString("itemName", aBlock);
|
||||
aNBT.setInteger("handlerHeight", 76);
|
||||
aNBT.setInteger("handlerWidth", 166);
|
||||
aNBT.setInteger("maxRecipesPerPage", 4);
|
||||
aNBT.setInteger("yShift", 6);
|
||||
FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT);
|
||||
}
|
||||
|
||||
private static void sendCatalyst(String aName, String aStack, int aPriority) {
|
||||
NBTTagCompound aNBT = new NBTTagCompound();
|
||||
aNBT.setString("handlerID", aName);
|
||||
aNBT.setString("itemName", aStack);
|
||||
aNBT.setInteger("priority", aPriority);
|
||||
FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT);
|
||||
}
|
||||
|
||||
private static void sendCatalyst(String aName, String aStack) {
|
||||
sendCatalyst(aName, aStack, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.core.nei.NEIUtils;
|
||||
import binnie.core.nei.PositionedFluidTank;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.api.IIncubatorRecipe;
|
||||
import binnie.genetics.machine.incubator.Incubator;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IncubatorRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.incubator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/incubator.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.machine.labMachine.incubator");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(75, 27, 24, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 76);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(75, 27, 176, 0, 24, 17, 40, 0);
|
||||
GuiDraw.drawStringC(StatCollector.translateToLocal("genetics.nei.tip.loss"), 62, 5, 0xFFFFFF);
|
||||
GuiDraw.drawStringC(((CachedIncubatorRecipe) arecipes.get(recipe)).lossChance, 62, 15, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
for (IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
this.arecipes.add(new CachedIncubatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getExpectedOutput(), result)) {
|
||||
this.arecipes.add(new CachedIncubatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(FluidStack result) {
|
||||
for (IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
if (NEIUtils.areFluidsSameType(recipe.getOutput(), result)) {
|
||||
this.arecipes.add(new CachedIncubatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getInputStack(), ingredient)) {
|
||||
this.arecipes.add(new CachedIncubatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(FluidStack ingredient) {
|
||||
for (IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
if (NEIUtils.areFluidsSameType(recipe.getInput(), ingredient)) {
|
||||
this.arecipes.add(new CachedIncubatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CachedIncubatorRecipe extends CachedBaseRecipe {
|
||||
public List<PositionedFluidTank> tanks = new ArrayList<>();
|
||||
public PositionedStack input;
|
||||
public PositionedStack output;
|
||||
public String lossChance;
|
||||
public String tickChance;
|
||||
public boolean consume = true;
|
||||
|
||||
public CachedIncubatorRecipe(IIncubatorRecipe recipe) {
|
||||
if (recipe.getInput() != null) {
|
||||
FluidStack fluidStack = recipe.getInput();
|
||||
|
||||
if (fluidStack.amount == 0) {
|
||||
fluidStack.amount = 1;
|
||||
consume = false;
|
||||
}
|
||||
|
||||
boolean finalConsume = consume;
|
||||
PositionedFluidTank tank = new PositionedFluidTank(fluidStack, 100, new Rectangle(28, 6, 16, 58)) {
|
||||
@Override
|
||||
public List<String> handleTooltip(List<String> currenttip) {
|
||||
if (this.tank != null && this.tank.getFluid() != null && this.tank.getFluid().getFluid() != null && this.tank.getFluid().amount > 0) {
|
||||
currenttip.add(this.tank.getFluid().getLocalizedName());
|
||||
if (this.showAmount) {
|
||||
currenttip.add(EnumChatFormatting.GRAY.toString() + this.tank.getFluid().amount + (this.perTick ? " mB/t" : " mB"));
|
||||
}
|
||||
if (!finalConsume) {
|
||||
currenttip.add(StatCollector.translateToLocal("genetics.nei.tip.noConsume"));
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
};
|
||||
this.tanks.add(tank);
|
||||
}
|
||||
|
||||
if (recipe.getOutput() != null) {
|
||||
this.tanks.add(new PositionedFluidTank(recipe.getOutput(), 100, new Rectangle(130, 6, 16, 58)));
|
||||
}
|
||||
|
||||
if (recipe.getInputStack() != null) {
|
||||
this.input = new PositionedStack(recipe.getInputStack(), 53, 27);
|
||||
}
|
||||
|
||||
if (recipe.getExpectedOutput() != null) {
|
||||
this.output = new PositionedStack(recipe.getExpectedOutput(), 105, 27);
|
||||
}
|
||||
|
||||
this.lossChance = recipe.getLossChance() * 100 + "%";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedFluidTank> getFluidTanks() {
|
||||
return this.tanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.nei.NEIUtils;
|
||||
import binnie.core.nei.PositionedFluidTank;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InoculatorRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
private static final List<InoculatorRecipe> recipes = new ArrayList<>();
|
||||
|
||||
private void createInoculatorRecipeForNEI(ItemStack dnaManipulable) {
|
||||
recipes.add(new InoculatorRecipe(dnaManipulable, new ItemStack(Genetics.itemSerum, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new InoculatorRecipe(dnaManipulable, new ItemStack(Genetics.itemSerumArray, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
if (BinnieCore.isApicultureActive())
|
||||
createInoculatorRecipeForNEI(Mods.forestry.stack("beeLarvaeGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
if (BinnieCore.isArboricultureActive())
|
||||
createInoculatorRecipeForNEI(Mods.forestry.stack("pollenFertile", 1, OreDictionary.WILDCARD_VALUE));
|
||||
if (BinnieCore.isLepidopteryActive())
|
||||
createInoculatorRecipeForNEI(Mods.forestry.stack("serumGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
if (BinnieCore.isBotanyActive())
|
||||
createInoculatorRecipeForNEI(new ItemStack(Botany.pollen, 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.inoculator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/inoculator.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.machine.machine.inoculator");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(75, 27, 24, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 74);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(75, 27, 176, 0, 24, 17, 40, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
for (InoculatorRecipe recipe : recipes) {
|
||||
this.arecipes.add(new CachedInoculatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (InoculatorRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getDnaManipulable(), result)) {
|
||||
this.arecipes.add(new CachedInoculatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(FluidStack ingredient) {
|
||||
if (NEIUtils.areFluidsSameType(GeneticLiquid.BacteriaVector.get(0), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (InoculatorRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getDnaManipulable(), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(recipe.getSerum(), ingredient)) {
|
||||
this.arecipes.add(new CachedInoculatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class InoculatorRecipe {
|
||||
|
||||
private final ItemStack dnaManipulable;
|
||||
private final ItemStack serum;
|
||||
|
||||
public InoculatorRecipe(ItemStack dnaManipulable, ItemStack serum) {
|
||||
this.dnaManipulable = dnaManipulable;
|
||||
this.serum = serum;
|
||||
}
|
||||
|
||||
public FluidStack getBacteriaVector() {
|
||||
return GeneticLiquid.BacteriaVector.get(15);
|
||||
}
|
||||
|
||||
public ItemStack getDnaManipulable() {
|
||||
return this.dnaManipulable;
|
||||
}
|
||||
|
||||
public ItemStack getSerum() {
|
||||
return this.serum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CachedInoculatorRecipe extends CachedBaseRecipe {
|
||||
|
||||
public PositionedFluidTank bacteriaTank;
|
||||
public PositionedStack serum;
|
||||
public PositionedStack input;
|
||||
public PositionedStack output;
|
||||
public List<PositionedStack> ingredients = new ArrayList<>();
|
||||
|
||||
public CachedInoculatorRecipe(InoculatorRecipe recipe) {
|
||||
|
||||
if (recipe.getSerum() != null && recipe.getDnaManipulable() != null) {
|
||||
ISpeciesRoot root1 = AlleleManager.alleleRegistry.getSpeciesRoot(recipe.getDnaManipulable());
|
||||
List<ItemStack> serums = new ArrayList<>();
|
||||
|
||||
for (ItemStack serumStack : ItemList.itemMap.get(recipe.getSerum().getItem())) {
|
||||
if (serumStack.getTagCompound() != null) {
|
||||
IItemSerum itemSerum = (IItemSerum) serumStack.getItem();
|
||||
ISpeciesRoot root2 = itemSerum.getSpeciesRoot(serumStack);
|
||||
if (root1 == root2) serums.add(serumStack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
this.bacteriaTank = new PositionedFluidTank(recipe.getBacteriaVector(), 100, new Rectangle(28, 6, 16, 58));
|
||||
this.serum = new PositionedStack(serums, 53, 6);
|
||||
this.input = new PositionedStack(recipe.getDnaManipulable(), 53, 27);
|
||||
this.output = new PositionedStack(recipe.getDnaManipulable(), 105, 27);
|
||||
|
||||
this.ingredients.add(this.serum);
|
||||
this.ingredients.add(this.input);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
this.input.setPermutationToRender(cycleticks / 40 % this.input.items.length);
|
||||
this.serum.setPermutationToRender(cycleticks / 40 % this.serum.items.length);
|
||||
return this.ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
this.output.setPermutationToRender(cycleticks / 40 % this.output.items.length);
|
||||
return this.output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedFluidTank getFluidTank() {
|
||||
return this.bacteriaTank;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.core.nei.NEIUtils;
|
||||
import binnie.core.nei.PositionedFluidTank;
|
||||
import binnie.core.nei.PositionedStackAdv;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.item.ItemSequence;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IsolatorRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
private static final List<IsolatorRecipe> recipes = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
recipes.add(new IsolatorRecipe(Mods.forestry.stack("beeDroneGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new IsolatorRecipe(Mods.forestry.stack("beePrincessGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new IsolatorRecipe(Mods.forestry.stack("beeQueenGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new IsolatorRecipe(Mods.forestry.stack("beeLarvaeGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
if (BinnieCore.isArboricultureActive()) {
|
||||
recipes.add(new IsolatorRecipe(Mods.forestry.stack("sapling", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new IsolatorRecipe(Mods.forestry.stack("pollenFertile", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
recipes.add(new IsolatorRecipe(Mods.forestry.stack("butterflyGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new IsolatorRecipe(Mods.forestry.stack("caterpillarGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new IsolatorRecipe(Mods.forestry.stack("serumGE", 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
recipes.add(new IsolatorRecipe(new ItemStack(Botany.flowerItem, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new IsolatorRecipe(new ItemStack(Botany.seed, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new IsolatorRecipe(new ItemStack(Botany.pollen, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.isolator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/isolator.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.machine.machine.isolator");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(87, 27, 24, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 74);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(87, 27, 176, 0, 24, 17, 40, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
for (IsolatorRecipe recipe : recipes) {
|
||||
this.arecipes.add(new CachedIsolatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(Genetics.itemSequencer), result)) {
|
||||
for (IsolatorRecipe recipe : recipes) {
|
||||
this.arecipes.add(new CachedIsolatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(FluidStack ingredient) {
|
||||
if (NEIUtils.areFluidsSameType(Binnie.Liquid.getLiquidStack("bioethanol", 0), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(GeneticsItems.EmptySequencer.get(1), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(GeneticsItems.Enzyme.get(1), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
} else {
|
||||
for (IsolatorRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getInput(), ingredient)) {
|
||||
this.arecipes.add(new CachedIsolatorRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class IsolatorRecipe {
|
||||
|
||||
private final ItemStack input;
|
||||
|
||||
public IsolatorRecipe(ItemStack input) {
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
public ItemStack getInput() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
public ItemStack getOutputSequencer() {
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(this.input);
|
||||
|
||||
IChromosomeType speciesChromosomeType = root.getKaryotypeKey();
|
||||
IAllele[] defaultTemplate = root.getDefaultTemplate();
|
||||
IAllele species = defaultTemplate[speciesChromosomeType.ordinal()];
|
||||
|
||||
return ItemSequence.create(new Gene(species, speciesChromosomeType, root));
|
||||
}
|
||||
|
||||
public FluidStack getEthanol() {
|
||||
return Binnie.Liquid.getLiquidStack("bioethanol", 10);
|
||||
}
|
||||
|
||||
public ItemStack getEnzyme() {
|
||||
return GeneticsItems.Enzyme.get(1);
|
||||
}
|
||||
|
||||
public ItemStack getEmptySequencer() {
|
||||
return GeneticsItems.EmptySequencer.get(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CachedIsolatorRecipe extends CachedBaseRecipe {
|
||||
|
||||
public PositionedFluidTank ethanolTank;
|
||||
public PositionedStack emptySequencer;
|
||||
public PositionedStack input;
|
||||
public PositionedStack enzyme;
|
||||
public PositionedStack output;
|
||||
public List<PositionedStack> ingredients = new ArrayList<>();
|
||||
|
||||
public CachedIsolatorRecipe(IsolatorRecipe recipe) {
|
||||
this.ethanolTank = new PositionedFluidTank(recipe.getEthanol(), 100, new Rectangle(40, 6, 16, 58));
|
||||
this.emptySequencer = new PositionedStack(recipe.getEmptySequencer(), 65, 27);
|
||||
this.enzyme = new PositionedStack(recipe.getEnzyme(), 65, 48);
|
||||
|
||||
if (recipe.getInput() != null) {
|
||||
this.input = new PositionedStackAdv(recipe.getInput(), 65, 6)
|
||||
.addToTooltip(StatCollector.translateToLocal("genetics.nei.tip.loss") + " 5%");
|
||||
this.output = new PositionedStack(recipe.getOutputSequencer(), 117, 27);
|
||||
|
||||
this.ingredients.add(this.emptySequencer);
|
||||
this.ingredients.add(this.input);
|
||||
this.ingredients.add(this.enzyme);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 40, this.ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
this.output.setPermutationToRender(cycleticks / 40 % this.output.items.length);
|
||||
return this.output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedFluidTank getFluidTank() {
|
||||
return this.ethanolTank;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
|
||||
public class NEIGeneticsConfig implements IConfigureNEI {
|
||||
protected static void registerHandler(RecipeHandlerBase handler) {
|
||||
handler.prepare();
|
||||
API.registerRecipeHandler(handler);
|
||||
API.registerUsageHandler(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
registerHandler(new IsolatorRecipeHandler());
|
||||
registerHandler(new SequencerRecipeHandler());
|
||||
registerHandler(new PolymeriserRecipeHandler());
|
||||
registerHandler(new InoculatorRecipeHandler());
|
||||
registerHandler(new AnalyserRecipeHandler());
|
||||
registerHandler(new IncubatorRecipeHandler());
|
||||
registerHandler(new GenepoolRecipeHandler());
|
||||
registerHandler(new AcclimatiserRecipeHandler());
|
||||
registerHandler(new SplicerRecipeHandler());
|
||||
registerHandler(new DatabaseRecipeHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Genetics NEI";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return BinnieCore.VERSION;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.core.nei.NEIUtils;
|
||||
import binnie.core.nei.PositionedFluidTank;
|
||||
import binnie.core.nei.PositionedStackAdv;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.item.ItemSequence;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PolymeriserRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
private static final List<PolymeriserRecipe> recipes = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
recipes.add(new PolymeriserRecipe(new ItemStack(Genetics.itemSequencer, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new PolymeriserRecipe(new ItemStack(Genetics.itemSerum, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new PolymeriserRecipe(new ItemStack(Genetics.itemSerumArray, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.polymeriser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/polymeriser.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.machine.machine.polymeriser");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(95, 27, 24, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 74);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(95, 27, 176, 0, 24, 17, 40, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
for (PolymeriserRecipe recipe : recipes) {
|
||||
this.arecipes.add(new CachedPolymeriserRecipe(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (PolymeriserRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result)) {
|
||||
this.arecipes.add(new CachedPolymeriserRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(Items.gold_nugget), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
} else {
|
||||
for (PolymeriserRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getSerum(), ingredient)) {
|
||||
this.arecipes.add(new CachedPolymeriserRecipe(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(FluidStack ingredient) {
|
||||
if (NEIUtils.areFluidsSameType(GeneticLiquid.BacteriaPoly.get(0), ingredient) || NEIUtils.areFluidsSameType(GeneticLiquid.RawDNA.get(0), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
private static class PolymeriserRecipe {
|
||||
|
||||
private final ItemStack serum;
|
||||
|
||||
public PolymeriserRecipe(ItemStack serum) {
|
||||
this.serum = serum;
|
||||
}
|
||||
|
||||
public ItemStack getSerum() {
|
||||
return this.serum;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return this.serum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CachedPolymeriserRecipe extends CachedBaseRecipe {
|
||||
|
||||
public PositionedStack input;
|
||||
public PositionedStack output;
|
||||
public PositionedStack goldNugget;
|
||||
public PositionedFluidTank bacteriaPoly;
|
||||
public PositionedFluidTank rawDNA;
|
||||
public List<PositionedStack> ingredients = new ArrayList<>();
|
||||
public List<PositionedFluidTank> tanks = new ArrayList<>();
|
||||
|
||||
public CachedPolymeriserRecipe(PolymeriserRecipe recipe) {
|
||||
if (recipe.getSerum() != null) {
|
||||
|
||||
List<ItemStack> inputs = new ArrayList<>();
|
||||
List<ItemStack> outputs = new ArrayList<>();
|
||||
List<FluidStack> bacteriaPolyTanks = new ArrayList<>();
|
||||
List<FluidStack> rawDNATanks = new ArrayList<>();
|
||||
|
||||
for (ItemStack itemStack : ItemList.itemMap.get(recipe.getSerum().getItem())) {
|
||||
if (itemStack.getTagCompound() != null) {
|
||||
ItemStack temp = itemStack.copy();
|
||||
if (itemStack.getItem() instanceof IItemSerum) {
|
||||
temp.setItemDamage(itemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
inputs.add(temp);
|
||||
int bacteriaPolyAmount = 10 * temp.getItemDamage() * (temp.getTagCompound() == null ? 1 : Engineering.getGenes(temp).length);
|
||||
bacteriaPolyTanks.add(GeneticLiquid.BacteriaPoly.get(bacteriaPolyAmount));
|
||||
rawDNATanks.add(GeneticLiquid.RawDNA.get(bacteriaPolyAmount * 5));
|
||||
}
|
||||
}
|
||||
|
||||
this.input = new PositionedStack(inputs, 73, 27);
|
||||
this.goldNugget = new PositionedStackAdv(new ItemStack(Items.gold_nugget), 73, 48)
|
||||
.addToTooltip(StatCollector.translateToLocalFormatted("genetics.nei.tip.processSpeed", 5));
|
||||
this.ingredients.add(this.input);
|
||||
this.ingredients.add(this.goldNugget);
|
||||
|
||||
this.bacteriaPoly = new PositionedFluidTank(bacteriaPolyTanks, 10000, new Rectangle(27, 6, 16, 58), null, null);
|
||||
this.rawDNA = new PositionedFluidTank(rawDNATanks, 20000, new Rectangle(48, 6, 16, 58), null, null);
|
||||
this.tanks.add(this.bacteriaPoly);
|
||||
this.tanks.add(this.rawDNA);
|
||||
|
||||
for (ItemStack itemStack : ItemList.itemMap.get(recipe.getOutput().getItem())) {
|
||||
if (itemStack.getTagCompound() != null) {
|
||||
ItemStack temp = itemStack.copy();
|
||||
if (recipe.getOutput().getItem() instanceof ItemSequence) {
|
||||
temp.setItemDamage(0);
|
||||
}
|
||||
outputs.add(temp);
|
||||
}
|
||||
}
|
||||
this.output = new PositionedStack(outputs, 125, 27);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
this.input.setPermutationToRender(cycleticks / 40 % this.input.items.length);
|
||||
this.bacteriaPoly.setPermutationToRender(cycleticks / 40 % this.bacteriaPoly.tanks.length);
|
||||
this.rawDNA.setPermutationToRender(cycleticks / 40 % this.rawDNA.tanks.length);
|
||||
return this.ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
this.output.setPermutationToRender(cycleticks / 40 % this.output.items.length);
|
||||
return this.output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedFluidTank> getFluidTanks() {
|
||||
return this.tanks;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SequencerRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.sequencer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/sequencer.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.machine.machine.sequencer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(75, 19, 24, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 74);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(75, 19, 176, 0, 24, 17, 40, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
this.arecipes.add(new CachedSequencerRecipe());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(GeneticsItems.EmptySequencer.get(1), result)) {
|
||||
this.loadAllRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(Genetics.itemSequencer), ingredient)
|
||||
|| NEIServerUtils.areStacksSameTypeCrafting(GeneticsItems.FluorescentDye.get(1), ingredient)
|
||||
|| NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(Genetics.database), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
public class CachedSequencerRecipe extends CachedBaseRecipe {
|
||||
|
||||
public PositionedStack seq;
|
||||
public PositionedStack fluorescentDye = new PositionedStack(GeneticsItems.FluorescentDye.get(1), 53, 40);
|
||||
public PositionedStack database = new PositionedStack(new ItemStack(Genetics.database), 105, 19);
|
||||
public PositionedStack emptySeq = new PositionedStack(GeneticsItems.EmptySequencer.get(1), 105, 40);
|
||||
public List<PositionedStack> ingredients = new ArrayList<>();
|
||||
public List<PositionedStack> results = new ArrayList<>();
|
||||
|
||||
public CachedSequencerRecipe() {
|
||||
List<ItemStack> seqList = new ArrayList<>();
|
||||
|
||||
for (ItemStack itemStack : ItemList.itemMap.get(Genetics.itemSequencer)) {
|
||||
for (int i = Genetics.itemSequencer.getMaxDamage(); i >= 0; i--) {
|
||||
ItemStack temp = itemStack.copy();
|
||||
temp.setItemDamage(i);
|
||||
seqList.add(temp);
|
||||
}
|
||||
}
|
||||
|
||||
this.seq = new PositionedStack(seqList, 53, 19);
|
||||
|
||||
this.ingredients.add(this.seq);
|
||||
this.ingredients.add(this.fluorescentDye);
|
||||
|
||||
this.results.add(this.database);
|
||||
this.results.add(this.emptySeq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
this.seq.setPermutationToRender(cycleticks / 40 % this.seq.items.length);
|
||||
return this.ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks() {
|
||||
return this.results;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.nei.NEIUtils;
|
||||
import binnie.core.nei.PositionedFluidTank;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SplicerRecipeHandler extends RecipeHandlerBase {
|
||||
|
||||
private static final List<SplicerRecipe> recipes = new ArrayList<>();
|
||||
|
||||
private void createInoculatorRecipeForNEI(ItemStack dnaManipulable) {
|
||||
recipes.add(new SplicerRecipe(dnaManipulable, new ItemStack(Genetics.itemSerum, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
recipes.add(new SplicerRecipe(dnaManipulable, new ItemStack(Genetics.itemSerumArray, 1, OreDictionary.WILDCARD_VALUE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
if (BinnieCore.isApicultureActive())
|
||||
createInoculatorRecipeForNEI(Mods.forestry.stack("beeLarvaeGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
if (BinnieCore.isArboricultureActive())
|
||||
createInoculatorRecipeForNEI(Mods.forestry.stack("pollenFertile", 1, OreDictionary.WILDCARD_VALUE));
|
||||
if (BinnieCore.isLepidopteryActive())
|
||||
createInoculatorRecipeForNEI(Mods.forestry.stack("serumGE", 1, OreDictionary.WILDCARD_VALUE));
|
||||
if (BinnieCore.isBotanyActive())
|
||||
createInoculatorRecipeForNEI(new ItemStack(Botany.pollen, 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "genetics.splicer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "genetics:textures/gui/nei/splicer.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("genetics.machine.advMachine.splicer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(75, 27, 24, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 74);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(75, 27, 176, 0, 24, 17, 40, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
for (SplicerRecipe recipe : recipes) {
|
||||
this.arecipes.add(new CachedSplicer(recipe));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (SplicerRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getDnaManipulable(), result)) {
|
||||
this.arecipes.add(new CachedSplicer(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(FluidStack ingredient) {
|
||||
if (NEIUtils.areFluidsSameType(GeneticLiquid.BacteriaVector.get(0), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (SplicerRecipe recipe : recipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getDnaManipulable(), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(recipe.getSerum(), ingredient)) {
|
||||
this.arecipes.add(new CachedSplicer(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SplicerRecipe {
|
||||
private final ItemStack dnaManipulable;
|
||||
private final ItemStack serum;
|
||||
|
||||
public SplicerRecipe(ItemStack dnaManipulable, ItemStack serum) {
|
||||
this.dnaManipulable = dnaManipulable;
|
||||
this.serum = serum;
|
||||
}
|
||||
|
||||
public ItemStack getDnaManipulable() {
|
||||
return this.dnaManipulable;
|
||||
}
|
||||
|
||||
public ItemStack getSerum() {
|
||||
return this.serum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CachedSplicer extends CachedBaseRecipe {
|
||||
|
||||
public PositionedFluidTank bacteriaTank;
|
||||
public PositionedStack serum;
|
||||
public PositionedStack input;
|
||||
public PositionedStack output;
|
||||
public List<PositionedStack> ingredients = new ArrayList<>();
|
||||
|
||||
public CachedSplicer(SplicerRecipe recipe) {
|
||||
if (recipe.getSerum() != null && recipe.getDnaManipulable() != null) {
|
||||
ISpeciesRoot root1 = AlleleManager.alleleRegistry.getSpeciesRoot(recipe.getDnaManipulable());
|
||||
List<ItemStack> serums = new ArrayList<>();
|
||||
|
||||
for (ItemStack serumStack : ItemList.itemMap.get(recipe.getSerum().getItem())) {
|
||||
if (serumStack.getTagCompound() != null) {
|
||||
IItemSerum itemSerum = (IItemSerum) serumStack.getItem();
|
||||
ISpeciesRoot root2 = itemSerum.getSpeciesRoot(serumStack);
|
||||
if (root1 == root2) serums.add(serumStack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
this.serum = new PositionedStack(serums, 53, 40);
|
||||
this.input = new PositionedStack(recipe.getDnaManipulable(), 53, 14);
|
||||
this.output = new PositionedStack(recipe.getDnaManipulable(), 105, 27);
|
||||
|
||||
this.ingredients.add(this.serum);
|
||||
this.ingredients.add(this.input);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
this.input.setPermutationToRender(cycleticks / 40 % this.input.items.length);
|
||||
this.serum.setPermutationToRender(cycleticks / 40 % this.serum.items.length);
|
||||
return this.ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
this.output.setPermutationToRender(cycleticks / 40 % this.output.items.length);
|
||||
return this.output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedFluidTank getFluidTank() {
|
||||
return this.bacteriaTank;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,3 +266,12 @@ genetics.gui.analyst.wood.flammable=Flammable
|
||||
genetics.gui.analyst.wood.logs=Logs
|
||||
genetics.gui.analyst.wood.products=Refined Products
|
||||
genetics.gui.analyst.wood.noFruits=This tree has no\nfruits or nuts
|
||||
|
||||
genetics.nei.tip.loss=Loss:
|
||||
genetics.nei.tip.noConsume=Not Be Consumed
|
||||
genetics.nei.tip.effect=Effect: %s
|
||||
genetics.nei.tip.temperature=Temperature
|
||||
genetics.nei.tip.humidity=Humidity
|
||||
genetics.nei.tip.processSpeed=%dx Processing Speed
|
||||
genetics.nei.tip.rf=%dx Processing Speed
|
||||
genetics.nei.tip.databaseDesc=Open the database and pick up an empty serum. Click the serum on Sequenced gene to apply.
|
||||
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
After Width: | Height: | Size: 7.4 KiB |