mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-21 20:52:22 +00:00
Add NEI support for Genetics
This commit is contained in:
1 parent
2f796f4478
commit
4aaa092db9
34 files changed
+2598
-275
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user