finished new chemplant NEI handler

This commit is contained in:
Boblet 2022-02-21 16:27:48 +01:00
parent 96db3e6767
commit adac3b1c53
3 changed files with 169 additions and 163 deletions

View File

@ -2,13 +2,16 @@ package com.hbm.handler.nei;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import com.hbm.inventory.FluidStack;
import com.hbm.inventory.RecipesCommon.AStack;
import com.hbm.inventory.gui.GUIMachineChemplant; import com.hbm.inventory.gui.GUIMachineChemplant;
import com.hbm.inventory.recipes.MachineRecipes; import com.hbm.inventory.recipes.ChemplantRecipes;
import com.hbm.inventory.recipes.ChemplantRecipes.ChemRecipe;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemFluidIcon;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import codechicken.nei.NEIServerUtils; import codechicken.nei.NEIServerUtils;
@ -17,71 +20,78 @@ import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
//TODO: destroy this abomination and replace it with something more sensible
public class ChemplantRecipeHandler extends TemplateRecipeHandler { public class ChemplantRecipeHandler extends TemplateRecipeHandler {
public LinkedList<RecipeTransferRect> transferRectsRec = new LinkedList<RecipeTransferRect>(); public LinkedList<RecipeTransferRect> transferRectsRec = new LinkedList<RecipeTransferRect>();
public LinkedList<RecipeTransferRect> transferRectsGui = new LinkedList<RecipeTransferRect>(); public LinkedList<RecipeTransferRect> transferRectsGui = new LinkedList<RecipeTransferRect>();
public LinkedList<Class<? extends GuiContainer>> guiRec = new LinkedList<Class<? extends GuiContainer>>(); public LinkedList<Class<? extends GuiContainer>> guiRec = new LinkedList<Class<? extends GuiContainer>>();
public LinkedList<Class<? extends GuiContainer>> guiGui = new LinkedList<Class<? extends GuiContainer>>(); public LinkedList<Class<? extends GuiContainer>> guiGui = new LinkedList<Class<? extends GuiContainer>>();
public class SmeltingSet extends TemplateRecipeHandler.CachedRecipe public class RecipeSet extends TemplateRecipeHandler.CachedRecipe {
{ PositionedStack[] itemIn = new PositionedStack[4];
PositionedStack input1; PositionedStack[] fluidIn = new PositionedStack[2];
PositionedStack input2; PositionedStack[] itemOut = new PositionedStack[4];
PositionedStack input3; PositionedStack[] fluidOut = new PositionedStack[2];
PositionedStack input4;
PositionedStack inputF1;
PositionedStack inputF2;
PositionedStack output1;
PositionedStack output2;
PositionedStack output3;
PositionedStack output4;
PositionedStack outputF1;
PositionedStack outputF2;
PositionedStack template; PositionedStack template;
public SmeltingSet(ItemStack inputF1, ItemStack inputF2, ItemStack input1, public RecipeSet(ChemRecipe recipe) {
ItemStack input2, ItemStack input3, ItemStack input4, ItemStack outputF1,
ItemStack outputF2, ItemStack output1, ItemStack output2, ItemStack output3,
ItemStack output4, ItemStack template) {
this.inputF1 = new PositionedStack(inputF1, 30, 6);
this.inputF2 = new PositionedStack(inputF2, 30 + 18, 6);
this.input1 = new PositionedStack(input1, 30, 6 + 18);
this.input2 = new PositionedStack(input2, 30 + 18, 6 + 18);
this.input3 = new PositionedStack(input3, 30, 6 + 36);
this.input4 = new PositionedStack(input4, 30 + 18, 6 + 36);
this.outputF1 = new PositionedStack(outputF1, 120, 6);
this.outputF2 = new PositionedStack(outputF2, 120 + 18, 6);
this.output1 = new PositionedStack(output1, 120, 6 + 18);
this.output2 = new PositionedStack(output2, 120 + 18, 6 + 18);
this.output3 = new PositionedStack(output3, 120, 6 + 36);
this.output4 = new PositionedStack(output4, 120 + 18, 6 + 36);
this.template = new PositionedStack(template, 84, 6);
}
@Override for(int i = 0; i < recipe.inputs.length; i++) {
AStack in = recipe.inputs[i];
if(in == null) continue;
this.itemIn[i] = new PositionedStack(in.extractForNEI(), 30 + (i % 2) * 18, 24 + (i / 2) * 18);
}
for(int i = 0; i < recipe.inputFluids.length; i++) {
FluidStack in = recipe.inputFluids[i];
if(in == null) continue;
ItemStack drop = ItemFluidIcon.make(in.type, in.fill);
this.fluidIn[i] = new PositionedStack(drop, 30 + (i % 2) * 18, 6);
}
for(int i = 0; i < recipe.outputs.length; i++) {
ItemStack out = recipe.outputs[i];
if(out == null) continue;
this.itemOut[i] = new PositionedStack(out, 120 + (i % 2) * 18, 24 + (i / 2) * 18);
}
for(int i = 0; i < recipe.outputFluids.length; i++) {
FluidStack out = recipe.outputFluids[i];
if(out == null) continue;
ItemStack drop = ItemFluidIcon.make(out.type, out.fill);
this.fluidOut[i] = new PositionedStack(drop, 120 + (i % 2) * 18, 6);
}
this.template = new PositionedStack(new ItemStack(ModItems.chemistry_template, 1, recipe.getId()), 84, 6);
}
@Override
public List<PositionedStack> getIngredients() { public List<PositionedStack> getIngredients() {
return getCycledIngredients(cycleticks / 48, Arrays.asList(new PositionedStack[] {input1, input2, input3, input4, inputF1, inputF2, template})); List<PositionedStack> stacks = new ArrayList<PositionedStack>();
}
@Override for(PositionedStack stack : itemIn) if(stack != null) stacks.add(stack);
for(PositionedStack stack : fluidIn) if(stack != null) stacks.add(stack);
stacks.add(template);
return getCycledIngredients(cycleticks / 20, stacks);
}
@Override
public List<PositionedStack> getOtherStacks() { public List<PositionedStack> getOtherStacks() {
List<PositionedStack> stacks = new ArrayList<PositionedStack>(); List<PositionedStack> stacks = new ArrayList<PositionedStack>();
stacks.add(output1);
stacks.add(output2);
stacks.add(output3);
stacks.add(output4);
stacks.add(outputF1);
stacks.add(outputF2);
return stacks;
}
@Override for(PositionedStack stack : itemOut) if(stack != null) stacks.add(stack);
for(PositionedStack stack : fluidOut) if(stack != null) stacks.add(stack);
stacks.add(template);
return stacks;
}
@Override
public PositionedStack getResult() { public PositionedStack getResult() {
return output1; return null;
} }
} }
@Override @Override
public String getRecipeName() { public String getRecipeName() {
@ -95,59 +105,48 @@ public class ChemplantRecipeHandler extends TemplateRecipeHandler {
@Override @Override
public void loadCraftingRecipes(String outputId, Object... results) { public void loadCraftingRecipes(String outputId, Object... results) {
/*if ((outputId.equals("chemistry")) && getClass() == ChemplantRecipeHandler.class) {
Map<Object[], Object[]> recipes = MachineRecipes.instance().getChemistryRecipes(); if((outputId.equals("chemistry")) && getClass() == ChemplantRecipeHandler.class) {
for (Map.Entry<Object[], Object[]> recipe : recipes.entrySet()) {
this.arecipes.add(new SmeltingSet( for(ChemRecipe recipe : ChemplantRecipes.recipes) {
(ItemStack)recipe.getKey()[0], this.arecipes.add(new RecipeSet(recipe));
(ItemStack)recipe.getKey()[1],
(ItemStack)recipe.getKey()[2],
(ItemStack)recipe.getKey()[3],
(ItemStack)recipe.getKey()[4],
(ItemStack)recipe.getKey()[5],
(ItemStack)recipe.getValue()[0],
(ItemStack)recipe.getValue()[1],
(ItemStack)recipe.getValue()[2],
(ItemStack)recipe.getValue()[3],
(ItemStack)recipe.getValue()[4],
(ItemStack)recipe.getValue()[5],
(ItemStack)recipe.getKey()[6]));
} }
} else { } else {
super.loadCraftingRecipes(outputId, results); super.loadCraftingRecipes(outputId, results);
}*/ }
} }
@Override @Override
public void loadCraftingRecipes(ItemStack result) { public void loadCraftingRecipes(ItemStack result) {
/*Map<Object[], Object[]> recipes = MachineRecipes.instance().getChemistryRecipes();
for (Map.Entry<Object[], Object[]> recipe : recipes.entrySet()) { outer:
if (compareFluidStacks(result, (ItemStack)recipe.getValue()[0]) || for(ChemRecipe recipe : ChemplantRecipes.recipes) {
compareFluidStacks(result, (ItemStack)recipe.getValue()[1]) ||
NEIServerUtils.areStacksSameTypeCrafting(result, (ItemStack)recipe.getValue()[2]) || for(ItemStack out : recipe.outputs) {
NEIServerUtils.areStacksSameTypeCrafting(result, (ItemStack)recipe.getValue()[3]) ||
NEIServerUtils.areStacksSameTypeCrafting(result, (ItemStack)recipe.getValue()[4]) || if(out != null && NEIServerUtils.areStacksSameTypeCrafting(result, out)) {
NEIServerUtils.areStacksSameTypeCrafting(result, (ItemStack)recipe.getValue()[5])) this.arecipes.add(new RecipeSet(recipe));
this.arecipes.add(new SmeltingSet( continue outer;
(ItemStack)recipe.getKey()[0], }
(ItemStack)recipe.getKey()[1], }
(ItemStack)recipe.getKey()[2],
(ItemStack)recipe.getKey()[3], for(FluidStack out : recipe.outputFluids) {
(ItemStack)recipe.getKey()[4],
(ItemStack)recipe.getKey()[5], if(out != null) {
(ItemStack)recipe.getValue()[0], ItemStack drop = ItemFluidIcon.make(out.type, out.fill);
(ItemStack)recipe.getValue()[1],
(ItemStack)recipe.getValue()[2], if(compareFluidStacks(result, drop)) {
(ItemStack)recipe.getValue()[3], this.arecipes.add(new RecipeSet(recipe));
(ItemStack)recipe.getValue()[4], continue outer;
(ItemStack)recipe.getValue()[5], }
(ItemStack)recipe.getKey()[6])); }
}*/ }
}
} }
@Override @Override
public void loadUsageRecipes(String inputId, Object... ingredients) { public void loadUsageRecipes(String inputId, Object... ingredients) {
if ((inputId.equals("chemistry")) && getClass() == ChemplantRecipeHandler.class) { if((inputId.equals("chemistry")) && getClass() == ChemplantRecipeHandler.class) {
loadCraftingRecipes("chemistry", new Object[0]); loadCraftingRecipes("chemistry", new Object[0]);
} else { } else {
super.loadUsageRecipes(inputId, ingredients); super.loadUsageRecipes(inputId, ingredients);
@ -156,64 +155,68 @@ public class ChemplantRecipeHandler extends TemplateRecipeHandler {
@Override @Override
public void loadUsageRecipes(ItemStack ingredient) { public void loadUsageRecipes(ItemStack ingredient) {
/*Map<Object[], Object[]> recipes = MachineRecipes.instance().getChemistryRecipes();
for (Map.Entry<Object[], Object[]> recipe : recipes.entrySet()) { outer:
if (compareFluidStacks(ingredient, (ItemStack)recipe.getKey()[0]) || for(ChemRecipe recipe : ChemplantRecipes.recipes) {
compareFluidStacks(ingredient, (ItemStack)recipe.getKey()[1]) ||
NEIServerUtils.areStacksSameTypeCrafting(ingredient, (ItemStack)recipe.getKey()[2]) || for(AStack in : recipe.inputs) {
NEIServerUtils.areStacksSameTypeCrafting(ingredient, (ItemStack)recipe.getKey()[3]) ||
NEIServerUtils.areStacksSameTypeCrafting(ingredient, (ItemStack)recipe.getKey()[4]) || if(in != null) {
NEIServerUtils.areStacksSameTypeCrafting(ingredient, (ItemStack)recipe.getKey()[5]) || List<ItemStack> stacks = in.extractForNEI();
NEIServerUtils.areStacksSameTypeCrafting(ingredient, (ItemStack)recipe.getKey()[6]))
this.arecipes.add(new SmeltingSet( for(ItemStack stack : stacks) {
(ItemStack)recipe.getKey()[0], if(NEIServerUtils.areStacksSameTypeCrafting(ingredient, stack)) {
(ItemStack)recipe.getKey()[1], this.arecipes.add(new RecipeSet(recipe));
(ItemStack)recipe.getKey()[2], continue outer;
(ItemStack)recipe.getKey()[3], }
(ItemStack)recipe.getKey()[4], }
(ItemStack)recipe.getKey()[5], }
(ItemStack)recipe.getValue()[0], }
(ItemStack)recipe.getValue()[1],
(ItemStack)recipe.getValue()[2], for(FluidStack in : recipe.inputFluids) {
(ItemStack)recipe.getValue()[3],
(ItemStack)recipe.getValue()[4], if(in != null) {
(ItemStack)recipe.getValue()[5], ItemStack drop = ItemFluidIcon.make(in.type, in.fill);
(ItemStack)recipe.getKey()[6]));
}*/ if(compareFluidStacks(ingredient, drop)) {
this.arecipes.add(new RecipeSet(recipe));
continue outer;
}
}
}
}
} }
private boolean compareFluidStacks(ItemStack sta1, ItemStack sta2) { private boolean compareFluidStacks(ItemStack sta1, ItemStack sta2) {
return sta1.getItem() == sta2.getItem() && sta1.getItemDamage() == sta2.getItemDamage(); return sta1.getItem() == sta2.getItem() && sta1.getItemDamage() == sta2.getItemDamage();
} }
@Override @Override
public Class<? extends GuiContainer> getGuiClass() { public Class<? extends GuiContainer> getGuiClass() {
//return GUITestDiFurnace.class; return null;
return null; }
}
@Override @Override
public void loadTransferRects() { public void loadTransferRects() {
transferRectsGui = new LinkedList<RecipeTransferRect>(); transferRectsGui = new LinkedList<RecipeTransferRect>();
guiGui = new LinkedList<Class<? extends GuiContainer>>(); guiGui = new LinkedList<Class<? extends GuiContainer>>();
transferRects.add(new RecipeTransferRect(new Rectangle(138 - 1 - 72, 23, 18 * 3, 18), "chemistry")); transferRects.add(new RecipeTransferRect(new Rectangle(138 - 1 - 72, 23, 18 * 3, 18), "chemistry"));
transferRectsGui.add(new RecipeTransferRect(new Rectangle(18 * 2 + 2, 89 - 7 - 11, 18 * 5 - 4, 18 + 16), "chemistry")); transferRectsGui.add(new RecipeTransferRect(new Rectangle(18 * 2 + 2, 89 - 7 - 11, 18 * 5 - 4, 18 + 16), "chemistry"));
guiGui.add(GUIMachineChemplant.class); guiGui.add(GUIMachineChemplant.class);
RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects); RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects);
RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui); RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui);
} }
@Override @Override
public void drawExtras(int recipe) { public void drawExtras(int recipe) {
drawProgressBar(83 - (18 * 4) - 9 + 1, 6, 0, 86, 16, 18 * 3 - 2, 480, 7); drawProgressBar(83 - (18 * 4) - 9 + 1, 6, 0, 86, 16, 18 * 3 - 2, 480, 7);
drawProgressBar(83 - 3 + 16 + 5 - 36, 5 + 18, 16, 86, 18 * 3, 18, 48, 0);
}
drawProgressBar(83 - 3 + 16 + 5 - 36, 5 + 18, 16, 86, 18 * 3, 18, 48, 0); @Override
} public TemplateRecipeHandler newInstance() {
return super.newInstance();
@Override }
public TemplateRecipeHandler newInstance() {
return super.newInstance();
}
} }

View File

@ -859,6 +859,14 @@ public class AssemblerRecipes {
new ComparableStack(ModItems.crt_display, 8), new ComparableStack(ModItems.crt_display, 8),
}, 300); }, 300);
makeRecipe(new ComparableStack(ModBlocks.rbmk_crane_console, 1), new AStack[] {
new OreDictStack(STEEL.ingot(), 16),
new OreDictStack(AL.plate(), 8),
new ComparableStack(ModItems.plate_polymer, 4),
new ComparableStack(ModItems.circuit_gold, 1),
new ComparableStack(ModItems.circuit_tantalium, 10),
}, 300);
makeRecipe(new ComparableStack(ModBlocks.hadron_core, 1), new AStack[] { makeRecipe(new ComparableStack(ModBlocks.hadron_core, 1), new AStack[] {
new ComparableStack(ModBlocks.hadron_coil_alloy, 24), new ComparableStack(ModBlocks.hadron_coil_alloy, 24),
new OreDictStack(STEEL.ingot(), 8), new OreDictStack(STEEL.ingot(), 8),

View File

@ -2,11 +2,7 @@ package com.hbm.items.machine;
import java.util.List; import java.util.List;
import com.hbm.interfaces.Spaghetti;
import com.hbm.inventory.FluidStack;
import com.hbm.inventory.RecipesCommon.AStack;
import com.hbm.inventory.recipes.ChemplantRecipes; import com.hbm.inventory.recipes.ChemplantRecipes;
import com.hbm.inventory.recipes.MachineRecipes;
import com.hbm.inventory.recipes.ChemplantRecipes.ChemRecipe; import com.hbm.inventory.recipes.ChemplantRecipes.ChemRecipe;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.util.I18nUtil; import com.hbm.util.I18nUtil;
@ -72,13 +68,13 @@ public class ItemChemistryTemplate extends Item {
try { try {
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("info.template_out_p")); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("info.template_out_p"));
for(int i = 0; i < 4; i++) { for(int i = 0; i < 4; i++) {
if(recipe.outputs.length > i && recipe.outputs[i] != null) { if(recipe.outputs[i] != null) {
list.add(recipe.outputs[i].stackSize + "x " + recipe.outputs[i].getDisplayName()); list.add(recipe.outputs[i].stackSize + "x " + recipe.outputs[i].getDisplayName());
} }
} }
for(int i = 0; i < 2; i++) { for(int i = 0; i < 2; i++) {
if(recipe.outputFluids.length > i && recipe.outputFluids[i] != null) { if(recipe.outputFluids[i] != null) {
list.add(recipe.outputFluids[i].fill + "mB " + I18n.format(recipe.outputFluids[i].type.getUnlocalizedName())); list.add(recipe.outputFluids[i].fill + "mB " + I18n.format(recipe.outputFluids[i].type.getUnlocalizedName()));
} }
} }
@ -86,13 +82,13 @@ public class ItemChemistryTemplate extends Item {
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("info.template_in_p")); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("info.template_in_p"));
for(int i = 0; i < recipe.inputs.length; i++) { for(int i = 0; i < recipe.inputs.length; i++) {
if(recipe.inputs.length > i && recipe.inputs[i] != null) { if(recipe.inputs[i] != null) {
list.add(recipe.inputs[i].stacksize + "x " + recipe.inputs[i].extractForCyclingDisplay(20).getDisplayName()); list.add(recipe.inputs[i].stacksize + "x " + recipe.inputs[i].extractForCyclingDisplay(20).getDisplayName());
} }
} }
for(int i = 0; i < 2; i++) { for(int i = 0; i < 2; i++) {
if(recipe.inputFluids.length > i && recipe.inputFluids[i] != null) { if(recipe.inputFluids[i] != null) {
list.add(recipe.inputFluids[i].fill + "mB " + I18n.format(recipe.inputFluids[i].type.getUnlocalizedName())); list.add(recipe.inputFluids[i].fill + "mB " + I18n.format(recipe.inputFluids[i].type.getUnlocalizedName()));
} }
} }
@ -104,5 +100,4 @@ public class ItemChemistryTemplate extends Item {
list.add("0x334077-0x6A298F-0xDF3795-0x334077"); list.add("0x334077-0x6A298F-0xDF3795-0x334077");
} }
} }
} }