mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
139 lines
5.5 KiB
Java
139 lines
5.5 KiB
Java
package com.hbm.handler;
|
|
|
|
import java.awt.Rectangle;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map.Entry;
|
|
|
|
import com.hbm.inventory.MachineRecipes;
|
|
import com.hbm.inventory.gui.GUIMachineCMBFactory;
|
|
import com.hbm.inventory.gui.GUIMachineShredder;
|
|
import com.hbm.inventory.gui.GUITestDiFurnace;
|
|
import com.hbm.lib.RefStrings;
|
|
|
|
import codechicken.nei.NEIServerUtils;
|
|
import codechicken.nei.PositionedStack;
|
|
import codechicken.nei.recipe.FurnaceRecipeHandler;
|
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
|
import codechicken.nei.recipe.FurnaceRecipeHandler.FuelPair;
|
|
import codechicken.nei.recipe.FurnaceRecipeHandler.SmeltingPair;
|
|
import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe;
|
|
import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect;
|
|
import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRectHandler;
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
import net.minecraft.client.gui.inventory.GuiFurnace;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
|
|
|
public class CMBFurnaceRecipeHandler extends TemplateRecipeHandler {
|
|
|
|
public LinkedList<RecipeTransferRect> transferRectsRec = 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>> guiGui = new LinkedList<Class<? extends GuiContainer>>();
|
|
|
|
public class SmeltingSet extends TemplateRecipeHandler.CachedRecipe
|
|
{
|
|
PositionedStack input1;
|
|
PositionedStack input2;
|
|
PositionedStack result;
|
|
|
|
public SmeltingSet(ItemStack input1, ItemStack input2, ItemStack result) {
|
|
input1.stackSize = 1;
|
|
input2.stackSize = 1;
|
|
this.input1 = new PositionedStack(input1, 66, 6);
|
|
this.input2 = new PositionedStack(input2, 66, 42);
|
|
this.result = new PositionedStack(result, 129, 24);
|
|
}
|
|
|
|
public List<PositionedStack> getIngredients() {
|
|
return getCycledIngredients(cycleticks / 48, Arrays.asList(new PositionedStack[] {input1, input2}));
|
|
}
|
|
|
|
public PositionedStack getResult() {
|
|
return result;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getRecipeName() {
|
|
return "CMB Steel Furnace";
|
|
}
|
|
|
|
@Override
|
|
public String getGuiTexture() {
|
|
return RefStrings.MODID + ":textures/gui/gui_nei_cmb.png";
|
|
}
|
|
|
|
public void loadCraftingRecipes(String outputId, Object... results) {
|
|
if ((outputId.equals("cmbsmelting")) && getClass() == CMBFurnaceRecipeHandler.class) {
|
|
Map<Object[], Object> recipes = MachineRecipes.instance().getCMBRecipes();
|
|
for (Map.Entry<Object[], Object> recipe : recipes.entrySet()) {
|
|
this.arecipes.add(new SmeltingSet((ItemStack)recipe.getKey()[0], (ItemStack)recipe.getKey()[1], (ItemStack)recipe.getValue()));
|
|
}
|
|
} else {
|
|
super.loadCraftingRecipes(outputId, results);
|
|
}
|
|
}
|
|
|
|
public void loadCraftingRecipes(ItemStack result) {
|
|
Map<Object[], Object> recipes = MachineRecipes.instance().getCMBRecipes();
|
|
for (Map.Entry<Object[], Object> recipe : recipes.entrySet()) {
|
|
if (NEIServerUtils.areStacksSameType((ItemStack)recipe.getValue(), result))
|
|
this.arecipes.add(new SmeltingSet((ItemStack)recipe.getKey()[0], (ItemStack)recipe.getKey()[1], (ItemStack)recipe.getValue()));
|
|
}
|
|
}
|
|
|
|
public void loadUsageRecipes(String inputId, Object... ingredients) {
|
|
if ((inputId.equals("cmbsmelting")) && getClass() == CMBFurnaceRecipeHandler.class) {
|
|
loadCraftingRecipes("cmbsmelting", new Object[0]);
|
|
} else {
|
|
super.loadUsageRecipes(inputId, ingredients);
|
|
}
|
|
}
|
|
|
|
public void loadUsageRecipes(ItemStack ingredient) {
|
|
Map<Object[], Object> recipes = MachineRecipes.instance().getCMBRecipes();
|
|
for (Map.Entry<Object[], Object> recipe : recipes.entrySet()) {
|
|
if (NEIServerUtils.areStacksSameType(ingredient, (ItemStack)recipe.getKey()[0]) || NEIServerUtils.areStacksSameType(ingredient, (ItemStack)recipe.getKey()[1]))
|
|
this.arecipes.add(new SmeltingSet((ItemStack)recipe.getKey()[0], (ItemStack)recipe.getKey()[1], (ItemStack)recipe.getValue()));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Class<? extends GuiContainer> getGuiClass() {
|
|
//return GUITestDiFurnace.class;
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void loadTransferRects() {
|
|
transferRectsGui = new LinkedList<RecipeTransferRect>();
|
|
guiGui = new LinkedList<Class<? extends GuiContainer>>();
|
|
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(74 + 6, 23, 24, 18), "cmbsmelting"));
|
|
transferRectsGui.add(new RecipeTransferRect(new Rectangle(63 - 7 + 4, 89 - 11, 34, 18), "cmbsmelting"));
|
|
guiGui.add(GUIMachineCMBFactory.class);
|
|
RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects);
|
|
RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui);
|
|
}
|
|
|
|
@Override
|
|
public void drawExtras(int recipe) {
|
|
|
|
drawProgressBar(83 - (18 * 4) - 9 + 1, 6, 36, 86, 16, 18 * 3 - 2, 480, 7);
|
|
drawProgressBar(83 - (18 * 4) - 9 + 1 + 18, 6, 36 + 48, 86, 16, 18 * 3 - 2, 480, 7);
|
|
|
|
drawProgressBar(83 - 3 + 16, 5 + 18, 100, 118, 24, 16, 48, 0);
|
|
}
|
|
|
|
@Override
|
|
public TemplateRecipeHandler newInstance() {
|
|
return super.newInstance();
|
|
}
|
|
|
|
}
|