diff --git a/src/main/java/techreborn/api/recipe/BaseRecipe.java b/src/main/java/techreborn/api/recipe/BaseRecipe.java index fca24c329..10dc5a84f 100644 --- a/src/main/java/techreborn/api/recipe/BaseRecipe.java +++ b/src/main/java/techreborn/api/recipe/BaseRecipe.java @@ -1,67 +1,67 @@ package techreborn.api.recipe; -import java.util.ArrayList; -import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import java.util.ArrayList; +import java.util.List; + /** * Extend this to add a recipe */ public abstract class BaseRecipe implements IBaseRecipeType { - public ArrayList inputs; + public ArrayList inputs; - public ArrayList outputs; + public ArrayList outputs; - public String name; + public String name; - public int tickTime; + public int tickTime; - public int euPerTick; + public int euPerTick; - public BaseRecipe(String name, int tickTime, int euPerTick) { - inputs = new ArrayList(); - outputs = new ArrayList(); - this.name = name; - //This adds all new recipes - this.tickTime = tickTime; - this.euPerTick = euPerTick; - } + public BaseRecipe(String name, int tickTime, int euPerTick) { + inputs = new ArrayList(); + outputs = new ArrayList(); + this.name = name; + //This adds all new recipes + this.tickTime = tickTime; + this.euPerTick = euPerTick; + } - @Override - public List getOutputs() { - return outputs; - } + @Override + public List getOutputs() { + return outputs; + } - @Override - public List getInputs() { - return inputs; - } + @Override + public List getInputs() { + return inputs; + } - @Override - public String getRecipeName() { - return name; - } + @Override + public String getRecipeName() { + return name; + } - @Override - public int tickTime() { - return tickTime; - } + @Override + public int tickTime() { + return tickTime; + } - @Override - public int euPerTick() { - return euPerTick; - } + @Override + public int euPerTick() { + return euPerTick; + } - @Override - public boolean canCraft(TileEntity tile) { - return true; - } + @Override + public boolean canCraft(TileEntity tile) { + return true; + } - @Override - public boolean onCraft(TileEntity tile) { - return true; - } + @Override + public boolean onCraft(TileEntity tile) { + return true; + } } diff --git a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java index 1bf87523b..c8d3d10c1 100644 --- a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java +++ b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java @@ -1,60 +1,60 @@ package techreborn.api.recipe; -import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import java.util.List; + /** * This is the base recipe class implement this to make a recipe handler */ public interface IBaseRecipeType { - /** - * Use this to get all of the inputs - * - * @return the List of inputs - */ - public List getInputs(); + /** + * Use this to get all of the inputs + * + * @return the List of inputs + */ + public List getInputs(); - /** - * Use this to get all of the outputs - * - * @return the List of outputs - */ - public List getOutputs(); + /** + * Use this to get all of the outputs + * + * @return the List of outputs + */ + public List getOutputs(); - /** - * This is the name to check that the recipe is the one that should be used in - * the tile entity that is set up to process this recipe. - * - * @return The recipeName - */ - public String getRecipeName(); + /** + * This is the name to check that the recipe is the one that should be used in + * the tile entity that is set up to process this recipe. + * + * @return The recipeName + */ + public String getRecipeName(); - /** - * This is how long the recipe needs to tick for the crafting operation to complete - * @return tick length - */ - public int tickTime(); + /** + * This is how long the recipe needs to tick for the crafting operation to complete + * + * @return tick length + */ + public int tickTime(); - /** - * This is how much eu Per tick the machine should use - * @return the amount of eu to be used per tick. - */ - public int euPerTick(); + /** + * This is how much eu Per tick the machine should use + * + * @return the amount of eu to be used per tick. + */ + public int euPerTick(); - /** - * - * @param tile the tile that is doing the crafting - * @return if true the recipe will craft, if false it will not - */ - public boolean canCraft(TileEntity tile); + /** + * @param tile the tile that is doing the crafting + * @return if true the recipe will craft, if false it will not + */ + public boolean canCraft(TileEntity tile); - /** - * - * @param tile the tile that is doing the crafting - * @return return true if fluid was taken and should craft - */ - public boolean onCraft(TileEntity tile); + /** + * @param tile the tile that is doing the crafting + * @return return true if fluid was taken and should craft + */ + public boolean onCraft(TileEntity tile); } diff --git a/src/main/java/techreborn/api/recipe/RecipeCrafter.java b/src/main/java/techreborn/api/recipe/RecipeCrafter.java index 9c25bf544..c405e81d2 100644 --- a/src/main/java/techreborn/api/recipe/RecipeCrafter.java +++ b/src/main/java/techreborn/api/recipe/RecipeCrafter.java @@ -1,248 +1,246 @@ package techreborn.api.recipe; import ic2.api.energy.prefab.BasicSink; - -import java.util.ArrayList; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; - import techreborn.tiles.TileMachineBase; import techreborn.util.Inventory; import techreborn.util.ItemUtils; +import java.util.ArrayList; + /** * Use this in your tile entity to craft things */ public class RecipeCrafter { - /** - * This is the recipe type to use - */ - public String recipeName; + /** + * This is the recipe type to use + */ + public String recipeName; - /** - * This is the parent tile - */ - public TileMachineBase parentTile; + /** + * This is the parent tile + */ + public TileMachineBase parentTile; - /** - * This is the place to use the power from - */ - public BasicSink energy; + /** + * This is the place to use the power from + */ + public BasicSink energy; - /** - * This is the amount of inputs that the setRecipe has - */ - public int inputs; + /** + * This is the amount of inputs that the setRecipe has + */ + public int inputs; - /** - * This is the amount of outputs that the recipe has - */ - public int outputs; + /** + * This is the amount of outputs that the recipe has + */ + public int outputs; - /** - * This is the inventory to use for the crafting - */ - public Inventory inventory; + /** + * This is the inventory to use for the crafting + */ + public Inventory inventory; - /** - * This is the list of the slots that the crafting logic should look for the input item stacks. - */ - public int[] inputSlots; + /** + * This is the list of the slots that the crafting logic should look for the input item stacks. + */ + public int[] inputSlots; - /** - * This is the list for the slots that the crafting logic should look fot the output item stacks. - */ - public int[] outputSlots; + /** + * This is the list for the slots that the crafting logic should look fot the output item stacks. + */ + public int[] outputSlots; - /** - * This is the constructor, not a lot to say here :P - * - * @param recipeName - * @param parentTile - * @param energy - * @param inputs - * @param outputs - * @param inventory - * @param inputSlots - * @param outputSlots - */ - public RecipeCrafter(String recipeName, TileMachineBase parentTile, BasicSink energy, int inputs, int outputs, Inventory inventory, int[] inputSlots, int[] outputSlots) { - this.recipeName = recipeName; - this.parentTile = parentTile; - this.energy = energy; - this.inputs = inputs; - this.outputs = outputs; - this.inventory = inventory; - this.inputSlots = inputSlots; - this.outputSlots = outputSlots; - } + /** + * This is the constructor, not a lot to say here :P + * + * @param recipeName + * @param parentTile + * @param energy + * @param inputs + * @param outputs + * @param inventory + * @param inputSlots + * @param outputSlots + */ + public RecipeCrafter(String recipeName, TileMachineBase parentTile, BasicSink energy, int inputs, int outputs, Inventory inventory, int[] inputSlots, int[] outputSlots) { + this.recipeName = recipeName; + this.parentTile = parentTile; + this.energy = energy; + this.inputs = inputs; + this.outputs = outputs; + this.inventory = inventory; + this.inputSlots = inputSlots; + this.outputSlots = outputSlots; + } - public IBaseRecipeType currentRecipe; - public int currentTickTime = 0; + public IBaseRecipeType currentRecipe; + public int currentTickTime = 0; double lastEnergy; - /** - * Call this on the tile tick - */ - public void updateEntity() { - if (currentRecipe == null) {//It will now look for new recipes. - for (IBaseRecipeType recipe : RecipeHanderer.getRecipeClassFromName(recipeName)) { - if(recipe.canCraft(parentTile) && hasAllInputs(recipe)){//This checks to see if it has all of the inputs - boolean canGiveInvAll = true; - for (int i = 0; i < recipe.getOutputs().size(); i++) {//This checks to see if it can fit all of the outputs - if (!canFitStack(recipe.getOutputs().get(i), outputSlots[i])) { - canGiveInvAll = false; - } - } - if(canGiveInvAll){ - currentRecipe = recipe;//Sets the current recipe then syncs - parentTile.needsSync = true; - } - } - } - if(lastEnergy != energy.getEnergyStored()){ + /** + * Call this on the tile tick + */ + public void updateEntity() { + if (currentRecipe == null) {//It will now look for new recipes. + for (IBaseRecipeType recipe : RecipeHanderer.getRecipeClassFromName(recipeName)) { + if (recipe.canCraft(parentTile) && hasAllInputs(recipe)) {//This checks to see if it has all of the inputs + boolean canGiveInvAll = true; + for (int i = 0; i < recipe.getOutputs().size(); i++) {//This checks to see if it can fit all of the outputs + if (!canFitStack(recipe.getOutputs().get(i), outputSlots[i])) { + canGiveInvAll = false; + } + } + if (canGiveInvAll) { + currentRecipe = recipe;//Sets the current recipe then syncs + parentTile.needsSync = true; + } + } + } + if (lastEnergy != energy.getEnergyStored()) { parentTile.needsSync = true; } - } else { - if(!hasAllInputs()){//If it doesn't have all the inputs reset - currentRecipe = null; - currentTickTime = 0; - parentTile.needsSync = true; - } - if (currentRecipe != null && currentTickTime >= currentRecipe.tickTime()) {//If it has reached the recipe tick time - boolean canGiveInvAll = true; - for (int i = 0; i < currentRecipe.getOutputs().size(); i++) {//Checks to see if it can fit the output - if (!canFitStack(currentRecipe.getOutputs().get(i), outputSlots[i])) { - canGiveInvAll = false; - } - } - ArrayList filledSlots = new ArrayList();//The slots that have been filled - if (canGiveInvAll && currentRecipe.onCraft(parentTile)) { - for (int i = 0; i < currentRecipe.getOutputs().size(); i++) { - if (!filledSlots.contains(outputSlots[i])) {//checks it has not been filled - fitStack(currentRecipe.getOutputs().get(i), outputSlots[i]);//fills the slot with the output stack - filledSlots.add(outputSlots[i]); - } - } - useAllInputs();//this uses all the inputs - currentRecipe = null;//resets - currentTickTime = 0; - //Force sync after craft + } else { + if (!hasAllInputs()) {//If it doesn't have all the inputs reset + currentRecipe = null; + currentTickTime = 0; + parentTile.needsSync = true; + } + if (currentRecipe != null && currentTickTime >= currentRecipe.tickTime()) {//If it has reached the recipe tick time + boolean canGiveInvAll = true; + for (int i = 0; i < currentRecipe.getOutputs().size(); i++) {//Checks to see if it can fit the output + if (!canFitStack(currentRecipe.getOutputs().get(i), outputSlots[i])) { + canGiveInvAll = false; + } + } + ArrayList filledSlots = new ArrayList();//The slots that have been filled + if (canGiveInvAll && currentRecipe.onCraft(parentTile)) { + for (int i = 0; i < currentRecipe.getOutputs().size(); i++) { + if (!filledSlots.contains(outputSlots[i])) {//checks it has not been filled + fitStack(currentRecipe.getOutputs().get(i), outputSlots[i]);//fills the slot with the output stack + filledSlots.add(outputSlots[i]); + } + } + useAllInputs();//this uses all the inputs + currentRecipe = null;//resets + currentTickTime = 0; + //Force sync after craft parentTile.syncWithAll(); parentTile.needsSync = false; parentTile.ticksSinceLastSync = 0; - } - } else if (currentRecipe != null && currentTickTime < currentRecipe.tickTime()) { - if (energy.canUseEnergy(currentRecipe.euPerTick())) {//This checks to see if it can use the power - if(!parentTile.getWorldObj().isRemote){//remove the power on the server side only - this.energy.setEnergyStored(this.energy.getEnergyStored() - currentRecipe.euPerTick()); - } - currentTickTime++;//increase the ticktime - parentTile.needsSync = true; - } - } - } + } + } else if (currentRecipe != null && currentTickTime < currentRecipe.tickTime()) { + if (energy.canUseEnergy(currentRecipe.euPerTick())) {//This checks to see if it can use the power + if (!parentTile.getWorldObj().isRemote) {//remove the power on the server side only + this.energy.setEnergyStored(this.energy.getEnergyStored() - currentRecipe.euPerTick()); + } + currentTickTime++;//increase the ticktime + parentTile.needsSync = true; + } + } + } lastEnergy = energy.getEnergyStored(); - } + } - public boolean hasAllInputs(){ - if(currentRecipe == null){ - return false; - } - for(ItemStack input : currentRecipe.getInputs()){ - Boolean hasItem = false; - for(int inputSlot : inputSlots){//Checks to see if it can find the input - if(ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, true) && inventory.getStackInSlot(inputSlot).stackSize >= input.stackSize){ - hasItem = true; - } - } - if(!hasItem) - return false; - } - return true; - } + public boolean hasAllInputs() { + if (currentRecipe == null) { + return false; + } + for (ItemStack input : currentRecipe.getInputs()) { + Boolean hasItem = false; + for (int inputSlot : inputSlots) {//Checks to see if it can find the input + if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, true) && inventory.getStackInSlot(inputSlot).stackSize >= input.stackSize) { + hasItem = true; + } + } + if (!hasItem) + return false; + } + return true; + } - public boolean hasAllInputs(IBaseRecipeType recipeType){ - if(recipeType == null){ - return false; - } - for(ItemStack input : recipeType.getInputs()){ - Boolean hasItem = false; - for(int inputslot : inputSlots){ - if(ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true, true)){ - hasItem = true; - } - } - if(!hasItem) - return false; - } - return true; - } + public boolean hasAllInputs(IBaseRecipeType recipeType) { + if (recipeType == null) { + return false; + } + for (ItemStack input : recipeType.getInputs()) { + Boolean hasItem = false; + for (int inputslot : inputSlots) { + if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true, true)) { + hasItem = true; + } + } + if (!hasItem) + return false; + } + return true; + } - public void useAllInputs(){ - if(currentRecipe == null){ - return; - } - for(ItemStack input : currentRecipe.getInputs()){ - for(int inputSlot : inputSlots){//Uses all of the inputs - if(ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, true)){ - inventory.decrStackSize(inputSlot, input.stackSize); - } - } - } - } + public void useAllInputs() { + if (currentRecipe == null) { + return; + } + for (ItemStack input : currentRecipe.getInputs()) { + for (int inputSlot : inputSlots) {//Uses all of the inputs + if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, true)) { + inventory.decrStackSize(inputSlot, input.stackSize); + } + } + } + } - public boolean canFitStack(ItemStack stack, int slot) {//Checks to see if it can fit the stack - if (stack == null) { - return true; - } - if (inventory.getStackInSlot(slot) == null) { - return true; - } - if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, true)) { - if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) { - return true; - } - } - return false; - } + public boolean canFitStack(ItemStack stack, int slot) {//Checks to see if it can fit the stack + if (stack == null) { + return true; + } + if (inventory.getStackInSlot(slot) == null) { + return true; + } + if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, true)) { + if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) { + return true; + } + } + return false; + } - public void fitStack(ItemStack stack, int slot) {//This fits a stack into a slot - if (stack == null) { - return; - } - if (inventory.getStackInSlot(slot) == null) {//If the slot is empty set the contents - inventory.setInventorySlotContents(slot, stack); - return; - } - if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, true)) {//If the slot has stuff in - if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) {//Check to see if it fits - ItemStack newStack = stack.copy(); - newStack.stackSize = inventory.getStackInSlot(slot).stackSize + stack.stackSize;//Sets the new stack size - inventory.setInventorySlotContents(slot, newStack); - } - } - } + public void fitStack(ItemStack stack, int slot) {//This fits a stack into a slot + if (stack == null) { + return; + } + if (inventory.getStackInSlot(slot) == null) {//If the slot is empty set the contents + inventory.setInventorySlotContents(slot, stack); + return; + } + if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, true)) {//If the slot has stuff in + if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) {//Check to see if it fits + ItemStack newStack = stack.copy(); + newStack.stackSize = inventory.getStackInSlot(slot).stackSize + stack.stackSize;//Sets the new stack size + inventory.setInventorySlotContents(slot, newStack); + } + } + } - public void readFromNBT(NBTTagCompound tag) { - NBTTagCompound data = tag.getCompoundTag("Crater"); + public void readFromNBT(NBTTagCompound tag) { + NBTTagCompound data = tag.getCompoundTag("Crater"); - currentTickTime = data.getInteger("currentTickTime"); - } + currentTickTime = data.getInteger("currentTickTime"); + } - public void writeToNBT(NBTTagCompound tag) { + public void writeToNBT(NBTTagCompound tag) { - NBTTagCompound data = new NBTTagCompound(); + NBTTagCompound data = new NBTTagCompound(); - data.setDouble("currentTickTime", currentTickTime); + data.setDouble("currentTickTime", currentTickTime); - tag.setTag("Crater", data); - } + tag.setTag("Crater", data); + } - public boolean isActive(){ - return currentRecipe != null && currentTickTime != 0; - } + public boolean isActive() { + return currentRecipe != null && currentTickTime != 0; + } } diff --git a/src/main/java/techreborn/api/recipe/RecipeHanderer.java b/src/main/java/techreborn/api/recipe/RecipeHanderer.java index a00a37e5d..513424320 100644 --- a/src/main/java/techreborn/api/recipe/RecipeHanderer.java +++ b/src/main/java/techreborn/api/recipe/RecipeHanderer.java @@ -1,51 +1,51 @@ package techreborn.api.recipe; -import net.minecraft.item.ItemStack; - import java.util.ArrayList; import java.util.List; public class RecipeHanderer { - /** - * This is the array list of all of the recipes for all of the machines - */ - public static ArrayList recipeList = new ArrayList(); + /** + * This is the array list of all of the recipes for all of the machines + */ + public static ArrayList recipeList = new ArrayList(); - /** - * This is a backedup clone of the master recipeList - */ - public static ArrayList recipeListBackup = new ArrayList(); + /** + * This is a backedup clone of the master recipeList + */ + public static ArrayList recipeListBackup = new ArrayList(); - /** - * Use this to get all of the recipes form a recipe name - * @param name the name that the recipe was resisted as. - * @return A list of all the recipes of a given name. - */ - public static List getRecipeClassFromName(String name){ - List baseRecipeList = new ArrayList(); - for(IBaseRecipeType baseRecipe : recipeList){ - if(baseRecipe.getRecipeName().equals(name)){ - baseRecipeList.add(baseRecipe); - } - } - return baseRecipeList; - } + /** + * Use this to get all of the recipes form a recipe name + * + * @param name the name that the recipe was resisted as. + * @return A list of all the recipes of a given name. + */ + public static List getRecipeClassFromName(String name) { + List baseRecipeList = new ArrayList(); + for (IBaseRecipeType baseRecipe : recipeList) { + if (baseRecipe.getRecipeName().equals(name)) { + baseRecipeList.add(baseRecipe); + } + } + return baseRecipeList; + } - /** - * Add a recipe to the system - * @param recipe The recipe to add to the system. - */ - public static void addRecipe(IBaseRecipeType recipe){ - if(recipe == null){ - return; - } - if(recipeList.contains(recipe)){ - return; - } - recipeList.add(recipe); - } + /** + * Add a recipe to the system + * + * @param recipe The recipe to add to the system. + */ + public static void addRecipe(IBaseRecipeType recipe) { + if (recipe == null) { + return; + } + if (recipeList.contains(recipe)) { + return; + } + recipeList.add(recipe); + } } \ No newline at end of file diff --git a/src/main/java/techreborn/api/recipe/machines/AlloySmelterRecipe.java b/src/main/java/techreborn/api/recipe/machines/AlloySmelterRecipe.java index 2453bc1d5..b393a6f2c 100644 --- a/src/main/java/techreborn/api/recipe/machines/AlloySmelterRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/AlloySmelterRecipe.java @@ -5,14 +5,13 @@ import techreborn.api.recipe.BaseRecipe; public class AlloySmelterRecipe extends BaseRecipe { - public AlloySmelterRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) - { - super("alloySmelterRecipe", tickTime, euPerTick); - if(input1 != null) - inputs.add(input1); - if(input2 != null) - inputs.add(input2); - if(output1 != null) - outputs.add(output1); - } + public AlloySmelterRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) { + super("alloySmelterRecipe", tickTime, euPerTick); + if (input1 != null) + inputs.add(input1); + if (input2 != null) + inputs.add(input2); + if (output1 != null) + outputs.add(output1); + } } diff --git a/src/main/java/techreborn/api/recipe/machines/AssemblingMachineRecipe.java b/src/main/java/techreborn/api/recipe/machines/AssemblingMachineRecipe.java index 314373184..42dfb359e 100644 --- a/src/main/java/techreborn/api/recipe/machines/AssemblingMachineRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/AssemblingMachineRecipe.java @@ -5,14 +5,13 @@ import techreborn.api.recipe.BaseRecipe; public class AssemblingMachineRecipe extends BaseRecipe { - public AssemblingMachineRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) - { - super("assemblingMachineRecipe", tickTime, euPerTick); - if(input1 != null) - inputs.add(input1); - if(input2 != null) - inputs.add(input2); - if(output1 != null) - outputs.add(output1); - } + public AssemblingMachineRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) { + super("assemblingMachineRecipe", tickTime, euPerTick); + if (input1 != null) + inputs.add(input1); + if (input2 != null) + inputs.add(input2); + if (output1 != null) + outputs.add(output1); + } } diff --git a/src/main/java/techreborn/api/recipe/machines/CentrifugeRecipe.java b/src/main/java/techreborn/api/recipe/machines/CentrifugeRecipe.java index 49c7fe486..c9cb107dd 100644 --- a/src/main/java/techreborn/api/recipe/machines/CentrifugeRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/CentrifugeRecipe.java @@ -5,20 +5,19 @@ import techreborn.api.recipe.BaseRecipe; public class CentrifugeRecipe extends BaseRecipe { - public CentrifugeRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) - { - super("centrifugeRecipe", tickTime, euPerTick); - if(input1 != null) - inputs.add(input1); - if(input2 != null) - inputs.add(input2); - if(output1 != null) - outputs.add(output1); - if(output2 != null) - outputs.add(output2); - if(output3 != null) - outputs.add(output3); - if(output4 != null) - outputs.add(output4); - } + public CentrifugeRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) { + super("centrifugeRecipe", tickTime, euPerTick); + if (input1 != null) + inputs.add(input1); + if (input2 != null) + inputs.add(input2); + if (output1 != null) + outputs.add(output1); + if (output2 != null) + outputs.add(output2); + if (output3 != null) + outputs.add(output3); + if (output4 != null) + outputs.add(output4); + } } diff --git a/src/main/java/techreborn/api/recipe/machines/ChemicalReactorRecipe.java b/src/main/java/techreborn/api/recipe/machines/ChemicalReactorRecipe.java index 665a5d45c..b1b72ef9f 100644 --- a/src/main/java/techreborn/api/recipe/machines/ChemicalReactorRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/ChemicalReactorRecipe.java @@ -5,14 +5,13 @@ import techreborn.api.recipe.BaseRecipe; public class ChemicalReactorRecipe extends BaseRecipe { - public ChemicalReactorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) - { - super("chemicalReactorRecipe", tickTime, euPerTick); - if(input1 != null) - inputs.add(input1); - if(input2 != null) - inputs.add(input2); - if(output1 != null) - outputs.add(output1); - } + public ChemicalReactorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) { + super("chemicalReactorRecipe", tickTime, euPerTick); + if (input1 != null) + inputs.add(input1); + if (input2 != null) + inputs.add(input2); + if (output1 != null) + outputs.add(output1); + } } diff --git a/src/main/java/techreborn/api/recipe/machines/GrinderRecipe.java b/src/main/java/techreborn/api/recipe/machines/GrinderRecipe.java index 315da417f..bfbd9f4ea 100644 --- a/src/main/java/techreborn/api/recipe/machines/GrinderRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/GrinderRecipe.java @@ -9,58 +9,63 @@ import techreborn.tiles.TileGrinder; public class GrinderRecipe extends BaseRecipe { - public FluidStack fluidStack; + public FluidStack fluidStack; - public GrinderRecipe(ItemStack input1, FluidStack fluidStack, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) - { - super("grinderRecipe", tickTime, euPerTick); - if(input1 != null) - inputs.add(input1); - if(output1 != null) - outputs.add(output1); - if(output2 != null) - outputs.add(output2); - if(output3 != null) - outputs.add(output3); - if(output4 != null) - outputs.add(output4); - this.fluidStack = fluidStack; - } + public GrinderRecipe(ItemStack input1, FluidStack fluidStack, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) { + super("grinderRecipe", tickTime, euPerTick); + if (input1 != null) + inputs.add(input1); + if (output1 != null) + outputs.add(output1); + if (output2 != null) + outputs.add(output2); + if (output3 != null) + outputs.add(output3); + if (output4 != null) + outputs.add(output4); + this.fluidStack = fluidStack; + } - @Override - public boolean canCraft(TileEntity tile) { - if(tile instanceof TileGrinder){ - TileGrinder grinder = (TileGrinder) tile; - if(grinder.tank.getFluid() == null){ - return false; - } - if(grinder.tank.getFluid().getFluidID() == fluidStack.getFluidID()){ - if(grinder.tank.getFluidAmount() >= fluidStack.amount){ - return true; - } - } - } - return false; - } + @Override + public boolean canCraft(TileEntity tile) { + if (fluidStack == null) { + return true; + } + if (tile instanceof TileGrinder) { + TileGrinder grinder = (TileGrinder) tile; + if (grinder.tank.getFluid() == null) { + return false; + } + if (grinder.tank.getFluid().getFluidID() == fluidStack.getFluidID()) { + if (grinder.tank.getFluidAmount() >= fluidStack.amount) { + return true; + } + } + } + return false; + } - @Override - public boolean onCraft(TileEntity tile) { - if(tile instanceof TileGrinder) { - TileGrinder grinder = (TileGrinder) tile; - if(grinder.tank.getFluid() == null){ - return false; - } - if(grinder.tank.getFluid().getFluidID() == fluidStack.getFluidID()){ - if(grinder.tank.getFluidAmount() >= fluidStack.amount){ - if(grinder.tank.getFluidAmount() > 0){ - grinder.tank.setFluid(new FluidStack(fluidStack.getFluid(), grinder.tank.getFluidAmount() - fluidStack.amount)); - } else { - grinder.tank.setFluid(null); - } - return true; - } - } - } - return false; - } + @Override + public boolean onCraft(TileEntity tile) { + if (fluidStack == null) { + return true; + } + if (tile instanceof TileGrinder) { + TileGrinder grinder = (TileGrinder) tile; + if (grinder.tank.getFluid() == null) { + return false; + } + if (grinder.tank.getFluid().getFluidID() == fluidStack.getFluidID()) { + if (grinder.tank.getFluidAmount() >= fluidStack.amount) { + if (grinder.tank.getFluidAmount() > 0) { + grinder.tank.setFluid(new FluidStack(fluidStack.getFluid(), grinder.tank.getFluidAmount() - fluidStack.amount)); + } else { + grinder.tank.setFluid(null); + } + return true; + } + } + } + return false; + } } diff --git a/src/main/java/techreborn/api/recipe/machines/ImplosionCompressorRecipe.java b/src/main/java/techreborn/api/recipe/machines/ImplosionCompressorRecipe.java index 520508308..258f60205 100644 --- a/src/main/java/techreborn/api/recipe/machines/ImplosionCompressorRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/ImplosionCompressorRecipe.java @@ -5,15 +5,15 @@ import techreborn.api.recipe.BaseRecipe; public class ImplosionCompressorRecipe extends BaseRecipe { - public ImplosionCompressorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tickTime, int euPerTick) { - super("implosionCompressorRecipe", tickTime, euPerTick); - if(input1 != null) - inputs.add(input1); - if(input2 != null) - inputs.add(input2); - if(output1 != null) - outputs.add(output1); - if(output2 != null) - outputs.add(output2); - } + public ImplosionCompressorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tickTime, int euPerTick) { + super("implosionCompressorRecipe", tickTime, euPerTick); + if (input1 != null) + inputs.add(input1); + if (input2 != null) + inputs.add(input2); + if (output1 != null) + outputs.add(output1); + if (output2 != null) + outputs.add(output2); + } } diff --git a/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java b/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java index b248aa965..24f90168c 100644 --- a/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java @@ -5,18 +5,17 @@ import techreborn.api.recipe.BaseRecipe; public class IndustrialSawmillRecipe extends BaseRecipe { - public IndustrialSawmillRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, ItemStack output3, int tickTime, int euPerTick) - { - super("industrialSawmillRecipe", tickTime, euPerTick); - if(input1 != null) - inputs.add(input1); - if(input2 != null) - inputs.add(input2); - if(output1 != null) - outputs.add(output1); - if(output2 != null) - outputs.add(output2); - if(output3 != null) - outputs.add(output3); - } + public IndustrialSawmillRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, ItemStack output3, int tickTime, int euPerTick) { + super("industrialSawmillRecipe", tickTime, euPerTick); + if (input1 != null) + inputs.add(input1); + if (input2 != null) + inputs.add(input2); + if (output1 != null) + outputs.add(output1); + if (output2 != null) + outputs.add(output2); + if (output3 != null) + outputs.add(output3); + } } diff --git a/src/main/java/techreborn/api/recipe/machines/LatheRecipe.java b/src/main/java/techreborn/api/recipe/machines/LatheRecipe.java index 1ec79de6d..84ccd2501 100644 --- a/src/main/java/techreborn/api/recipe/machines/LatheRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/LatheRecipe.java @@ -5,12 +5,11 @@ import techreborn.api.recipe.BaseRecipe; public class LatheRecipe extends BaseRecipe { - public LatheRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick) - { - super("latheRecipe", tickTime, euPerTick); - if(input1 != null) - inputs.add(input1); - if(output1 != null) - outputs.add(output1); - } + public LatheRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick) { + super("latheRecipe", tickTime, euPerTick); + if (input1 != null) + inputs.add(input1); + if (output1 != null) + outputs.add(output1); + } } diff --git a/src/main/java/techreborn/api/recipe/machines/PlateCuttingMachineRecipe.java b/src/main/java/techreborn/api/recipe/machines/PlateCuttingMachineRecipe.java index 6e3f387e5..ec5d094bb 100644 --- a/src/main/java/techreborn/api/recipe/machines/PlateCuttingMachineRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/PlateCuttingMachineRecipe.java @@ -5,12 +5,11 @@ import techreborn.api.recipe.BaseRecipe; public class PlateCuttingMachineRecipe extends BaseRecipe { - public PlateCuttingMachineRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick) - { - super("plateCuttingMachineRecipe", tickTime, euPerTick); - if(input1 != null) - inputs.add(input1); - if(output1 != null) - outputs.add(output1); - } + public PlateCuttingMachineRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick) { + super("plateCuttingMachineRecipe", tickTime, euPerTick); + if (input1 != null) + inputs.add(input1); + if (output1 != null) + outputs.add(output1); + } } diff --git a/src/main/java/techreborn/api/recipe/machines/package-info.java b/src/main/java/techreborn/api/recipe/machines/package-info.java index 81a0c8efe..18834422e 100644 --- a/src/main/java/techreborn/api/recipe/machines/package-info.java +++ b/src/main/java/techreborn/api/recipe/machines/package-info.java @@ -1,5 +1,4 @@ -@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") -package techreborn.api.recipe.machines; +@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.recipe.machines; import cpw.mods.fml.common.API; diff --git a/src/main/java/techreborn/api/recipe/package-info.java b/src/main/java/techreborn/api/recipe/package-info.java index 7acc7ab23..683159b73 100644 --- a/src/main/java/techreborn/api/recipe/package-info.java +++ b/src/main/java/techreborn/api/recipe/package-info.java @@ -1,5 +1,4 @@ -@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") -package techreborn.api.recipe; +@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.recipe; import cpw.mods.fml.common.API; diff --git a/src/main/java/techreborn/compat/nei/BlastFurnaceRecipeHandler.java b/src/main/java/techreborn/compat/nei/BlastFurnaceRecipeHandler.java index 9ad15c360..a17b02520 100644 --- a/src/main/java/techreborn/compat/nei/BlastFurnaceRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/BlastFurnaceRecipeHandler.java @@ -1,186 +1,158 @@ package techreborn.compat.nei; -import java.awt.Point; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.item.ItemStack; - -import org.lwjgl.opengl.GL11; - -import techreborn.api.BlastFurnaceRecipe; -import techreborn.api.TechRebornAPI; -import techreborn.client.gui.GuiBlastFurnace; -import techreborn.config.ConfigTechReborn; import codechicken.lib.gui.GuiDraw; import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.TemplateRecipeHandler; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; +import techreborn.api.BlastFurnaceRecipe; +import techreborn.api.TechRebornAPI; +import techreborn.client.gui.GuiBlastFurnace; +import techreborn.config.ConfigTechReborn; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; /** * Created by mark on 29/04/15. */ public class BlastFurnaceRecipeHandler extends TemplateRecipeHandler { - public class CachedBlastFurnaceRecipe extends CachedRecipe { + public class CachedBlastFurnaceRecipe extends CachedRecipe { - private List input = new ArrayList(); - private List outputs = new ArrayList(); - public Point focus; - public BlastFurnaceRecipe centrifugeRecipie; + private List input = new ArrayList(); + private List outputs = new ArrayList(); + public Point focus; + public BlastFurnaceRecipe centrifugeRecipie; - public CachedBlastFurnaceRecipe(BlastFurnaceRecipe recipie) - { - this.centrifugeRecipie = recipie; - int offset = 4; - PositionedStack pStack = new PositionedStack( - recipie.getInput1(), 56 - offset, 25 - offset); + public CachedBlastFurnaceRecipe(BlastFurnaceRecipe recipie) { + this.centrifugeRecipie = recipie; + int offset = 4; + PositionedStack pStack = new PositionedStack( + recipie.getInput1(), 56 - offset, 25 - offset); - pStack.setMaxSize(1); - this.input.add(pStack); + pStack.setMaxSize(1); + this.input.add(pStack); - PositionedStack pStack2 = new PositionedStack( - recipie.getInput2(), 56 - offset, 43 - offset); + PositionedStack pStack2 = new PositionedStack( + recipie.getInput2(), 56 - offset, 43 - offset); - pStack.setMaxSize(1); - this.input.add(pStack2); + pStack.setMaxSize(1); + this.input.add(pStack2); - if (recipie.getOutput1() != null) - { - this.outputs.add(new PositionedStack(recipie.getOutput1(), - 116 - offset, 35 - offset)); - } - if (recipie.getOutput2() != null) - { - this.outputs.add(new PositionedStack(recipie.getOutput2(), - 116 - offset, 53 - offset)); - } - } + if (recipie.getOutput1() != null) { + this.outputs.add(new PositionedStack(recipie.getOutput1(), + 116 - offset, 35 - offset)); + } + if (recipie.getOutput2() != null) { + this.outputs.add(new PositionedStack(recipie.getOutput2(), + 116 - offset, 53 - offset)); + } + } - @Override - public List getIngredients() - { - return this.getCycledIngredients(cycleticks / 20, this.input); - } + @Override + public List getIngredients() { + return this.getCycledIngredients(cycleticks / 20, this.input); + } - @Override - public List getOtherStacks() - { - return this.outputs; - } + @Override + public List getOtherStacks() { + return this.outputs; + } - @Override - public PositionedStack getResult() - { - return null; - } - } + @Override + public PositionedStack getResult() { + return null; + } + } - @Override - public String getRecipeName() - { - return "Blast Furnace"; - } + @Override + public String getRecipeName() { + return "Blast Furnace"; + } - @Override - public String getGuiTexture() - { - return "techreborn:textures/gui/industrial_blast_furnace.png"; - } + @Override + public String getGuiTexture() { + return "techreborn:textures/gui/industrial_blast_furnace.png"; + } - @Override - public Class getGuiClass() - { - return GuiBlastFurnace.class; - } + @Override + public Class getGuiClass() { + return GuiBlastFurnace.class; + } - @Override - public void drawBackground(int recipeIndex) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78); - GuiDraw.drawTooltipBox(10, 80, 145, 50); - GuiDraw.drawString("Info:", 14, 84, -1); - CachedRecipe recipe = arecipes.get(recipeIndex); - if (recipe instanceof CachedBlastFurnaceRecipe) - { - CachedBlastFurnaceRecipe centrifugeRecipie = (CachedBlastFurnaceRecipe) recipe; - GuiDraw.drawString( - "EU needed: " - + (ConfigTechReborn.CentrifugeInputTick * centrifugeRecipie.centrifugeRecipie - .getTickTime()), 14, 94, -1); - GuiDraw.drawString("Ticks to smelt: " - + centrifugeRecipie.centrifugeRecipie.getTickTime(), 14, - 104, -1); - GuiDraw.drawString("Time to smelt: " - + centrifugeRecipie.centrifugeRecipie.getTickTime() / 20 - + " seconds", 14, 114, -1); - } - } + @Override + public void drawBackground(int recipeIndex) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78); + GuiDraw.drawTooltipBox(10, 80, 145, 50); + GuiDraw.drawString("Info:", 14, 84, -1); + CachedRecipe recipe = arecipes.get(recipeIndex); + if (recipe instanceof CachedBlastFurnaceRecipe) { + CachedBlastFurnaceRecipe centrifugeRecipie = (CachedBlastFurnaceRecipe) recipe; + GuiDraw.drawString( + "EU needed: " + + (ConfigTechReborn.CentrifugeInputTick * centrifugeRecipie.centrifugeRecipie + .getTickTime()), 14, 94, -1); + GuiDraw.drawString("Ticks to smelt: " + + centrifugeRecipie.centrifugeRecipie.getTickTime(), 14, + 104, -1); + GuiDraw.drawString("Time to smelt: " + + centrifugeRecipie.centrifugeRecipie.getTickTime() / 20 + + " seconds", 14, 114, -1); + } + } - @Override - public int recipiesPerPage() - { - return 1; - } + @Override + public int recipiesPerPage() { + return 1; + } - @Override - public void loadTransferRects() - { - this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( - new Rectangle(0, 0, 20, 20), "tr.blast", new Object[0])); - } + @Override + public void loadTransferRects() { + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(0, 0, 20, 20), "tr.blast", new Object[0])); + } - public void loadCraftingRecipes(String outputId, Object... results) - { - if (outputId.equals("tr.blast")) - { - for (BlastFurnaceRecipe centrifugeRecipie : TechRebornAPI.blastFurnaceRecipes) - { - addCached(centrifugeRecipie); - } - } else - { - super.loadCraftingRecipes(outputId, results); - } - } + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("tr.blast")) { + for (BlastFurnaceRecipe centrifugeRecipie : TechRebornAPI.blastFurnaceRecipes) { + addCached(centrifugeRecipie); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) - { - for (BlastFurnaceRecipe centrifugeRecipie : TechRebornAPI.blastFurnaceRecipes) - { - if (NEIServerUtils.areStacksSameTypeCrafting( - centrifugeRecipie.getOutput1(), result)) - { - addCached(centrifugeRecipie); - } - if (NEIServerUtils.areStacksSameTypeCrafting( - centrifugeRecipie.getOutput2(), result)) - { - addCached(centrifugeRecipie); - } - } - } + @Override + public void loadCraftingRecipes(ItemStack result) { + for (BlastFurnaceRecipe centrifugeRecipie : TechRebornAPI.blastFurnaceRecipes) { + if (NEIServerUtils.areStacksSameTypeCrafting( + centrifugeRecipie.getOutput1(), result)) { + addCached(centrifugeRecipie); + } + if (NEIServerUtils.areStacksSameTypeCrafting( + centrifugeRecipie.getOutput2(), result)) { + addCached(centrifugeRecipie); + } + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for (BlastFurnaceRecipe centrifugeRecipie : TechRebornAPI.blastFurnaceRecipes) - { - if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getInput1(), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getInput2(), ingredient)) - { - addCached(centrifugeRecipie); - } - } - } + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (BlastFurnaceRecipe centrifugeRecipie : TechRebornAPI.blastFurnaceRecipes) { + if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getInput1(), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getInput2(), ingredient)) { + addCached(centrifugeRecipie); + } + } + } - private void addCached(BlastFurnaceRecipe recipie) - { - this.arecipes.add(new CachedBlastFurnaceRecipe(recipie)); - } + private void addCached(BlastFurnaceRecipe recipie) { + this.arecipes.add(new CachedBlastFurnaceRecipe(recipie)); + } } \ No newline at end of file diff --git a/src/main/java/techreborn/compat/nei/NEIConfig.java b/src/main/java/techreborn/compat/nei/NEIConfig.java index 8e70da2af..84ef8c665 100644 --- a/src/main/java/techreborn/compat/nei/NEIConfig.java +++ b/src/main/java/techreborn/compat/nei/NEIConfig.java @@ -1,70 +1,62 @@ package techreborn.compat.nei; -import techreborn.compat.nei.recipes.AlloySmelterRecipeHandler; -import techreborn.compat.nei.recipes.AssemblingMachineRecipeHandler; -import techreborn.compat.nei.recipes.CentrifugeRecipeHandler; -import techreborn.compat.nei.recipes.ChemicalReactorRecipeHandler; -import techreborn.compat.nei.recipes.ImplosionCompressorRecipeHandler; -import techreborn.compat.nei.recipes.IndustrialSawmillRecipeHandler; -import techreborn.compat.nei.recipes.LatheRecipeHandler; -import techreborn.compat.nei.recipes.PlateCuttingMachineRecipeHandler; -import techreborn.lib.ModInfo; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; +import techreborn.compat.nei.recipes.*; +import techreborn.lib.ModInfo; public class NEIConfig implements IConfigureNEI { - @Override - public String getName() - { - return ModInfo.MOD_ID; - } + @Override + public String getName() { + return ModInfo.MOD_ID; + } + + @Override + public String getVersion() { + return ModInfo.MOD_VERSION; + } - @Override - public String getVersion() - { - return ModInfo.MOD_VERSION; - } public static BlastFurnaceRecipeHandler blastFurnaceRecipeHandle; - @Override - public void loadConfig() { + @Override + public void loadConfig() { ShapedRollingMachineHandler shapedRollingMachineHandler = new ShapedRollingMachineHandler(); ShapelessRollingMachineHandler shapelessRollingMachineHandler = new ShapelessRollingMachineHandler(); NEIConfig.blastFurnaceRecipeHandle = new BlastFurnaceRecipeHandler(); - - ImplosionCompressorRecipeHandler implosion = new ImplosionCompressorRecipeHandler(); - API.registerUsageHandler(implosion); - API.registerRecipeHandler(implosion); - - AlloySmelterRecipeHandler alloy = new AlloySmelterRecipeHandler(); - API.registerUsageHandler(alloy); - API.registerRecipeHandler(alloy); - - AssemblingMachineRecipeHandler assembling = new AssemblingMachineRecipeHandler(); - API.registerUsageHandler(assembling); - API.registerRecipeHandler(assembling); - - LatheRecipeHandler lathe = new LatheRecipeHandler(); - API.registerUsageHandler(lathe); - API.registerRecipeHandler(lathe); - - IndustrialSawmillRecipeHandler sawmill = new IndustrialSawmillRecipeHandler(); - API.registerUsageHandler(sawmill); - API.registerRecipeHandler(sawmill); - - PlateCuttingMachineRecipeHandler plate = new PlateCuttingMachineRecipeHandler(); - API.registerUsageHandler(plate); - API.registerRecipeHandler(plate); - - ChemicalReactorRecipeHandler chem = new ChemicalReactorRecipeHandler(); - API.registerUsageHandler(chem); - API.registerRecipeHandler(chem); - - CentrifugeRecipeHandler cent = new CentrifugeRecipeHandler(); - API.registerUsageHandler(cent); - API.registerRecipeHandler(cent); + + ImplosionCompressorRecipeHandler implosion = new ImplosionCompressorRecipeHandler(); + API.registerUsageHandler(implosion); + API.registerRecipeHandler(implosion); + + AlloySmelterRecipeHandler alloy = new AlloySmelterRecipeHandler(); + API.registerUsageHandler(alloy); + API.registerRecipeHandler(alloy); + + AssemblingMachineRecipeHandler assembling = new AssemblingMachineRecipeHandler(); + API.registerUsageHandler(assembling); + API.registerRecipeHandler(assembling); + + LatheRecipeHandler lathe = new LatheRecipeHandler(); + API.registerUsageHandler(lathe); + API.registerRecipeHandler(lathe); + + IndustrialSawmillRecipeHandler sawmill = new IndustrialSawmillRecipeHandler(); + API.registerUsageHandler(sawmill); + API.registerRecipeHandler(sawmill); + + PlateCuttingMachineRecipeHandler plate = new PlateCuttingMachineRecipeHandler(); + API.registerUsageHandler(plate); + API.registerRecipeHandler(plate); + + ChemicalReactorRecipeHandler chem = new ChemicalReactorRecipeHandler(); + API.registerUsageHandler(chem); + API.registerRecipeHandler(chem); + + CentrifugeRecipeHandler cent = new CentrifugeRecipeHandler(); + API.registerUsageHandler(cent); + API.registerRecipeHandler(cent); API.registerUsageHandler(shapedRollingMachineHandler); API.registerRecipeHandler(shapedRollingMachineHandler); diff --git a/src/main/java/techreborn/compat/nei/ShapedRollingMachineHandler.java b/src/main/java/techreborn/compat/nei/ShapedRollingMachineHandler.java index 534065395..43e179903 100644 --- a/src/main/java/techreborn/compat/nei/ShapedRollingMachineHandler.java +++ b/src/main/java/techreborn/compat/nei/ShapedRollingMachineHandler.java @@ -1,9 +1,8 @@ //Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapedRecipeHandler.java package techreborn.compat.nei; -import java.awt.Rectangle; -import java.util.List; - +import codechicken.nei.NEIServerUtils; +import codechicken.nei.recipe.ShapedRecipeHandler; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -11,110 +10,97 @@ import net.minecraft.item.crafting.ShapedRecipes; import net.minecraftforge.oredict.ShapedOreRecipe; import techreborn.api.RollingMachineRecipe; import techreborn.client.gui.GuiRollingMachine; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.recipe.ShapedRecipeHandler; + +import java.awt.*; +import java.util.List; public class ShapedRollingMachineHandler extends ShapedRecipeHandler { - @Override - public Class getGuiClass() - { - return GuiRollingMachine.class; - } + @Override + public Class getGuiClass() { + return GuiRollingMachine.class; + } - @Override - public void loadTransferRects() - { - this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, - 18), "rollingcrafting", new Object[0])); - } + @Override + public void loadTransferRects() { + this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, + 18), "rollingcrafting", new Object[0])); + } - @Override - public String getRecipeName() - { - return "rollingcrafting"; - } + @Override + public String getRecipeName() { + return "rollingcrafting"; + } - @Override - public String getOverlayIdentifier() - { - return "rollingcrafting"; - } + @Override + public String getOverlayIdentifier() { + return "rollingcrafting"; + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if (outputId.equals("rollingcrafting") - && getClass() == ShapedRollingMachineHandler.class) - { - for (IRecipe irecipe : (List) RollingMachineRecipe.instance - .getRecipeList()) - { - CachedShapedRecipe recipe = null; - if (irecipe instanceof ShapedRecipes) - recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); - else if (irecipe instanceof ShapedOreRecipe) - recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("rollingcrafting") + && getClass() == ShapedRollingMachineHandler.class) { + for (IRecipe irecipe : (List) RollingMachineRecipe.instance + .getRecipeList()) { + CachedShapedRecipe recipe = null; + if (irecipe instanceof ShapedRecipes) + recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); + else if (irecipe instanceof ShapedOreRecipe) + recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - recipe.computeVisuals(); - arecipes.add(recipe); - } - } else - { - super.loadCraftingRecipes(outputId, results); - } - } + recipe.computeVisuals(); + arecipes.add(recipe); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) - { - for (IRecipe irecipe : (List) RollingMachineRecipe.instance - .getRecipeList()) - { - if (NEIServerUtils.areStacksSameTypeCrafting( - irecipe.getRecipeOutput(), result)) - { - CachedShapedRecipe recipe = null; - if (irecipe instanceof ShapedRecipes) - recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); - else if (irecipe instanceof ShapedOreRecipe) - recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); + @Override + public void loadCraftingRecipes(ItemStack result) { + for (IRecipe irecipe : (List) RollingMachineRecipe.instance + .getRecipeList()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getRecipeOutput(), result)) { + CachedShapedRecipe recipe = null; + if (irecipe instanceof ShapedRecipes) + recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); + else if (irecipe instanceof ShapedOreRecipe) + recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - recipe.computeVisuals(); - arecipes.add(recipe); - } - } - } + recipe.computeVisuals(); + arecipes.add(recipe); + } + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for (IRecipe irecipe : (List) RollingMachineRecipe.instance - .getRecipeList()) - { - CachedShapedRecipe recipe = null; - if (irecipe instanceof ShapedRecipes) - recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); - else if (irecipe instanceof ShapedOreRecipe) - recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (IRecipe irecipe : (List) RollingMachineRecipe.instance + .getRecipeList()) { + CachedShapedRecipe recipe = null; + if (irecipe instanceof ShapedRecipes) + recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); + else if (irecipe instanceof ShapedOreRecipe) + recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); - if (recipe == null - || !recipe.contains(recipe.ingredients, - ingredient.getItem())) - continue; + if (recipe == null + || !recipe.contains(recipe.ingredients, + ingredient.getItem())) + continue; - recipe.computeVisuals(); - if (recipe.contains(recipe.ingredients, ingredient)) - { - recipe.setIngredientPermutation(recipe.ingredients, ingredient); - arecipes.add(recipe); - } - } - } + recipe.computeVisuals(); + if (recipe.contains(recipe.ingredients, ingredient)) { + recipe.setIngredientPermutation(recipe.ingredients, ingredient); + arecipes.add(recipe); + } + } + } } diff --git a/src/main/java/techreborn/compat/nei/ShapelessRollingMachineHandler.java b/src/main/java/techreborn/compat/nei/ShapelessRollingMachineHandler.java index 0d565715f..1ed427ef6 100644 --- a/src/main/java/techreborn/compat/nei/ShapelessRollingMachineHandler.java +++ b/src/main/java/techreborn/compat/nei/ShapelessRollingMachineHandler.java @@ -1,9 +1,8 @@ //Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapelessRecipeHandler.java package techreborn.compat.nei; -import java.awt.Rectangle; -import java.util.List; - +import codechicken.nei.NEIServerUtils; +import codechicken.nei.recipe.ShapelessRecipeHandler; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -11,116 +10,102 @@ import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraftforge.oredict.ShapelessOreRecipe; import techreborn.api.RollingMachineRecipe; import techreborn.client.gui.GuiRollingMachine; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.recipe.ShapelessRecipeHandler; + +import java.awt.*; +import java.util.List; public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler { - @Override - public Class getGuiClass() - { - return GuiRollingMachine.class; - } + @Override + public Class getGuiClass() { + return GuiRollingMachine.class; + } - public String getRecipeName() - { - return "Shapeless Rolling Machine"; - } + public String getRecipeName() { + return "Shapeless Rolling Machine"; + } - @Override - public void loadTransferRects() - { - transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), - "rollingcraftingnoshape")); - } + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), + "rollingcraftingnoshape")); + } - @Override - public String getOverlayIdentifier() - { - return "rollingcraftingnoshape"; - } + @Override + public String getOverlayIdentifier() { + return "rollingcraftingnoshape"; + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if (outputId.equals("rollingcraftingnoshape") - && getClass() == ShapelessRollingMachineHandler.class) - { - List allrecipes = RollingMachineRecipe.instance - .getRecipeList(); - for (IRecipe irecipe : allrecipes) - { - CachedShapelessRecipe recipe = null; - if (irecipe instanceof ShapelessRecipes) - recipe = shapelessRecipe((ShapelessRecipes) irecipe); - else if (irecipe instanceof ShapelessOreRecipe) - recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("rollingcraftingnoshape") + && getClass() == ShapelessRollingMachineHandler.class) { + List allrecipes = RollingMachineRecipe.instance + .getRecipeList(); + for (IRecipe irecipe : allrecipes) { + CachedShapelessRecipe recipe = null; + if (irecipe instanceof ShapelessRecipes) + recipe = shapelessRecipe((ShapelessRecipes) irecipe); + else if (irecipe instanceof ShapelessOreRecipe) + recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - arecipes.add(recipe); - } - } else - { - super.loadCraftingRecipes(outputId, results); - } - } + arecipes.add(recipe); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) - { - List allrecipes = RollingMachineRecipe.instance - .getRecipeList(); - for (IRecipe irecipe : allrecipes) - { - if (NEIServerUtils.areStacksSameTypeCrafting( - irecipe.getRecipeOutput(), result)) - { - CachedShapelessRecipe recipe = null; - if (irecipe instanceof ShapelessRecipes) - recipe = shapelessRecipe((ShapelessRecipes) irecipe); - else if (irecipe instanceof ShapelessOreRecipe) - recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); + @Override + public void loadCraftingRecipes(ItemStack result) { + List allrecipes = RollingMachineRecipe.instance + .getRecipeList(); + for (IRecipe irecipe : allrecipes) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getRecipeOutput(), result)) { + CachedShapelessRecipe recipe = null; + if (irecipe instanceof ShapelessRecipes) + recipe = shapelessRecipe((ShapelessRecipes) irecipe); + else if (irecipe instanceof ShapelessOreRecipe) + recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - arecipes.add(recipe); - } - } - } + arecipes.add(recipe); + } + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - List allrecipes = RollingMachineRecipe.instance - .getRecipeList(); - for (IRecipe irecipe : allrecipes) - { - CachedShapelessRecipe recipe = null; - if (irecipe instanceof ShapelessRecipes) - recipe = shapelessRecipe((ShapelessRecipes) irecipe); - else if (irecipe instanceof ShapelessOreRecipe) - recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); + @Override + public void loadUsageRecipes(ItemStack ingredient) { + List allrecipes = RollingMachineRecipe.instance + .getRecipeList(); + for (IRecipe irecipe : allrecipes) { + CachedShapelessRecipe recipe = null; + if (irecipe instanceof ShapelessRecipes) + recipe = shapelessRecipe((ShapelessRecipes) irecipe); + else if (irecipe instanceof ShapelessOreRecipe) + recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - if (recipe.contains(recipe.ingredients, ingredient)) - { - recipe.setIngredientPermutation(recipe.ingredients, ingredient); - arecipes.add(recipe); - } - } - } + if (recipe.contains(recipe.ingredients, ingredient)) { + recipe.setIngredientPermutation(recipe.ingredients, ingredient); + arecipes.add(recipe); + } + } + } - private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) - { - if (recipe.recipeItems == null) - return null; + private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) { + if (recipe.recipeItems == null) + return null; - return new CachedShapelessRecipe(recipe.recipeItems, - recipe.getRecipeOutput()); - } + return new CachedShapelessRecipe(recipe.recipeItems, + recipe.getRecipeOutput()); + } } diff --git a/src/main/java/techreborn/compat/nei/recipes/AlloySmelterRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/AlloySmelterRecipeHandler.java index 38875cf04..d353b954b 100644 --- a/src/main/java/techreborn/compat/nei/recipes/AlloySmelterRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/AlloySmelterRecipeHandler.java @@ -1,44 +1,44 @@ package techreborn.compat.nei.recipes; -import java.util.List; - +import codechicken.nei.PositionedStack; import net.minecraft.client.gui.inventory.GuiContainer; import techreborn.api.recipe.IBaseRecipeType; import techreborn.client.gui.GuiAlloySmelter; import techreborn.util.ItemUtils; -import codechicken.nei.PositionedStack; + +import java.util.List; public class AlloySmelterRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe { - @Override - public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { - int offset = 4; - PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 47 - offset, 17 - offset); - input.add(pStack); + @Override + public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { + int offset = 4; + PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 47 - offset, 17 - offset); + input.add(pStack); - PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset); - input.add(pStack2); + PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset); + input.add(pStack2); - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); - outputs.add(pStack3); - } + PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); + outputs.add(pStack3); + } - @Override - public String getRecipeName() { - return "alloySmelterRecipe"; - } + @Override + public String getRecipeName() { + return "alloySmelterRecipe"; + } - @Override - public String getGuiTexture() { - return "techreborn:textures/gui/electric_alloy_furnace.png"; - } + @Override + public String getGuiTexture() { + return "techreborn:textures/gui/electric_alloy_furnace.png"; + } - @Override - public Class getGuiClass() { - return GuiAlloySmelter.class; - } + @Override + public Class getGuiClass() { + return GuiAlloySmelter.class; + } - @Override - public INeiBaseRecipe getNeiBaseRecipe() { - return this; - } + @Override + public INeiBaseRecipe getNeiBaseRecipe() { + return this; + } } diff --git a/src/main/java/techreborn/compat/nei/recipes/AssemblingMachineRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/AssemblingMachineRecipeHandler.java index bb6ccfb2c..dd0e00c4c 100644 --- a/src/main/java/techreborn/compat/nei/recipes/AssemblingMachineRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/AssemblingMachineRecipeHandler.java @@ -1,44 +1,50 @@ package techreborn.compat.nei.recipes; -import java.util.List; - +import codechicken.nei.PositionedStack; import net.minecraft.client.gui.inventory.GuiContainer; import techreborn.api.recipe.IBaseRecipeType; import techreborn.client.gui.GuiAssemblingMachine; import techreborn.util.ItemUtils; -import codechicken.nei.PositionedStack; + +import java.util.List; public class AssemblingMachineRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe { - @Override - public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { - int offset = 4; - PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 47 - offset, 17 - offset); - input.add(pStack); + @Override + public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { + int offset = 4; + if (recipeType.getInputs().size() > 0) { + PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 47 - offset, 17 - offset); + input.add(pStack); + } + if (recipeType.getInputs().size() > 1) { + PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset); + input.add(pStack2); + } - PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset); - input.add(pStack2); + if (recipeType.getOutputs().size() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); + outputs.add(pStack3); + } - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); - outputs.add(pStack3); - } + } - @Override - public String getRecipeName() { - return "assemblingMachineRecipe"; - } + @Override + public String getRecipeName() { + return "assemblingMachineRecipe"; + } - @Override - public String getGuiTexture() { - return "techreborn:textures/gui/assembling_machine.png"; - } + @Override + public String getGuiTexture() { + return "techreborn:textures/gui/assembling_machine.png"; + } - @Override - public Class getGuiClass() { - return GuiAssemblingMachine.class; - } + @Override + public Class getGuiClass() { + return GuiAssemblingMachine.class; + } - @Override - public INeiBaseRecipe getNeiBaseRecipe() { - return this; - } + @Override + public INeiBaseRecipe getNeiBaseRecipe() { + return this; + } } diff --git a/src/main/java/techreborn/compat/nei/recipes/CentrifugeRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/CentrifugeRecipeHandler.java index 0a0f27af1..965a1c7da 100644 --- a/src/main/java/techreborn/compat/nei/recipes/CentrifugeRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/CentrifugeRecipeHandler.java @@ -1,53 +1,64 @@ package techreborn.compat.nei.recipes; -import java.util.List; - +import codechicken.nei.PositionedStack; import net.minecraft.client.gui.inventory.GuiContainer; import techreborn.api.recipe.IBaseRecipeType; import techreborn.client.gui.GuiCentrifuge; import techreborn.util.ItemUtils; -import codechicken.nei.PositionedStack; + +import java.util.List; public class CentrifugeRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe { - @Override - public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { - int offset = 4; - PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 80 - offset, 35 - offset); - input.add(pStack); + @Override + public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { + int offset = 4; + if (recipeType.getInputs().size() > 0) { + PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 80 - offset, 35 - offset); + input.add(pStack); + } + if (recipeType.getInputs().size() > 1) { + PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 50 - offset, 5 - offset); + input.add(pStack2); + } - PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 50 - offset, 5 - offset); - input.add(pStack2); + if (recipeType.getOutputs().size() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 80 - offset, 5 - offset); + outputs.add(pStack3); + } - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 80 - offset, 5 - offset); - outputs.add(pStack3); - - PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 110 - offset, 35 - offset); - outputs.add(pStack4); - - PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 80 - offset, 65 - offset); - outputs.add(pStack5); - - PositionedStack pStack6 = new PositionedStack(recipeType.getOutputs().get(3), 50 - offset, 35 - offset); - outputs.add(pStack6); - } + if (recipeType.getOutputs().size() > 1) { + PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 110 - offset, 35 - offset); + outputs.add(pStack4); + } - @Override - public String getRecipeName() { - return "centrifugeRecipe"; - } + if (recipeType.getOutputs().size() > 2) { + PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 80 - offset, 65 - offset); + outputs.add(pStack5); + } - @Override - public String getGuiTexture() { - return "techreborn:textures/gui/industrial_centrifuge.png"; - } + if (recipeType.getOutputs().size() > 3) { + PositionedStack pStack6 = new PositionedStack(recipeType.getOutputs().get(3), 50 - offset, 35 - offset); + outputs.add(pStack6); + } + } - @Override - public Class getGuiClass() { - return GuiCentrifuge.class; - } + @Override + public String getRecipeName() { + return "centrifugeRecipe"; + } - @Override - public INeiBaseRecipe getNeiBaseRecipe() { - return this; - } + @Override + public String getGuiTexture() { + return "techreborn:textures/gui/industrial_centrifuge.png"; + } + + @Override + public Class getGuiClass() { + return GuiCentrifuge.class; + } + + @Override + public INeiBaseRecipe getNeiBaseRecipe() { + return this; + } } diff --git a/src/main/java/techreborn/compat/nei/recipes/ChemicalReactorRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/ChemicalReactorRecipeHandler.java index 6b277b49e..ce2493e96 100644 --- a/src/main/java/techreborn/compat/nei/recipes/ChemicalReactorRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/ChemicalReactorRecipeHandler.java @@ -1,44 +1,50 @@ package techreborn.compat.nei.recipes; -import java.util.List; - +import codechicken.nei.PositionedStack; import net.minecraft.client.gui.inventory.GuiContainer; import techreborn.api.recipe.IBaseRecipeType; import techreborn.client.gui.GuiChemicalReactor; import techreborn.util.ItemUtils; -import codechicken.nei.PositionedStack; + +import java.util.List; public class ChemicalReactorRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe { - @Override - public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { - int offset = 4; - PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 70 - offset, 21 - offset); - input.add(pStack); + @Override + public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { + int offset = 4; + if (recipeType.getInputs().size() > 0) { + PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 70 - offset, 21 - offset); + input.add(pStack); + } - PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 90 - offset, 21 - offset); - input.add(pStack2); + if (recipeType.getInputs().size() > 1) { + PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 90 - offset, 21 - offset); + input.add(pStack2); + } - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 80 - offset, 51 - offset); - outputs.add(pStack3); - } + if (recipeType.getOutputs().size() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 80 - offset, 51 - offset); + outputs.add(pStack3); + } + } - @Override - public String getRecipeName() { - return "chemicalReactorRecipe"; - } + @Override + public String getRecipeName() { + return "chemicalReactorRecipe"; + } - @Override - public String getGuiTexture() { - return "techreborn:textures/gui/chemical_reactor.png"; - } + @Override + public String getGuiTexture() { + return "techreborn:textures/gui/chemical_reactor.png"; + } - @Override - public Class getGuiClass() { - return GuiChemicalReactor.class; - } + @Override + public Class getGuiClass() { + return GuiChemicalReactor.class; + } - @Override - public INeiBaseRecipe getNeiBaseRecipe() { - return this; - } + @Override + public INeiBaseRecipe getNeiBaseRecipe() { + return this; + } } diff --git a/src/main/java/techreborn/compat/nei/recipes/GenericRecipeHander.java b/src/main/java/techreborn/compat/nei/recipes/GenericRecipeHander.java index 934fb7aca..44be5b992 100644 --- a/src/main/java/techreborn/compat/nei/recipes/GenericRecipeHander.java +++ b/src/main/java/techreborn/compat/nei/recipes/GenericRecipeHander.java @@ -1,164 +1,139 @@ package techreborn.compat.nei.recipes; -import java.awt.Point; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; - +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; - import org.lwjgl.opengl.GL11; - import techreborn.api.recipe.IBaseRecipeType; import techreborn.api.recipe.RecipeHanderer; import techreborn.config.ConfigTechReborn; import techreborn.util.ItemUtils; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; public abstract class GenericRecipeHander extends TemplateRecipeHandler { - public INeiBaseRecipe getNeiBaseRecipe(){ - return null; - } + public INeiBaseRecipe getNeiBaseRecipe() { + return null; + } - public class CachedGenericRecipe extends CachedRecipe { + public class CachedGenericRecipe extends CachedRecipe { - private List input = new ArrayList(); - private List outputs = new ArrayList(); - public Point focus; - public IBaseRecipeType recipie; - public INeiBaseRecipe neiBaseRecipe; + private List input = new ArrayList(); + private List outputs = new ArrayList(); + public Point focus; + public IBaseRecipeType recipie; + public INeiBaseRecipe neiBaseRecipe; - public CachedGenericRecipe(IBaseRecipeType recipe, INeiBaseRecipe neiBaseRecipe) - { - this.recipie = recipe; - this.neiBaseRecipe = neiBaseRecipe; - neiBaseRecipe.addPositionedStacks(input, outputs, recipe); - } + public CachedGenericRecipe(IBaseRecipeType recipe, INeiBaseRecipe neiBaseRecipe) { + this.recipie = recipe; + this.neiBaseRecipe = neiBaseRecipe; + neiBaseRecipe.addPositionedStacks(input, outputs, recipe); + } - @Override - public List getIngredients() - { - return this.getCycledIngredients(cycleticks / 20, this.input); - } + @Override + public List getIngredients() { + return this.getCycledIngredients(cycleticks / 20, this.input); + } - @Override - public List getOtherStacks() - { - return this.outputs; - } + @Override + public List getOtherStacks() { + return this.outputs; + } - @Override - public PositionedStack getResult() - { - return null; - } - } + @Override + public PositionedStack getResult() { + return null; + } + } - @Override - public String getRecipeName() - { - return getNeiBaseRecipe().getRecipeName(); - } + @Override + public String getRecipeName() { + return getNeiBaseRecipe().getRecipeName(); + } - @Override - public String getGuiTexture() - { - return getNeiBaseRecipe().getGuiTexture(); - } + @Override + public String getGuiTexture() { + return getNeiBaseRecipe().getGuiTexture(); + } - @Override - public Class getGuiClass() - { - return getNeiBaseRecipe().getGuiClass(); - } + @Override + public Class getGuiClass() { + return getNeiBaseRecipe().getGuiClass(); + } - @Override - public void drawBackground(int recipeIndex) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78); - GuiDraw.drawTooltipBox(10, 80, 145, 50); - GuiDraw.drawString("Info:", 14, 84, -1); - CachedRecipe recipe = arecipes.get(recipeIndex); - if (recipe instanceof CachedGenericRecipe) - { - CachedGenericRecipe genericRecipe = (CachedGenericRecipe) recipe; - GuiDraw.drawString( - "EU needed: " - + (ConfigTechReborn.CentrifugeInputTick * genericRecipe.recipie - .tickTime()), 14, 94, -1); - GuiDraw.drawString("Ticks to smelt: " - + genericRecipe.recipie.tickTime(), 14, - 104, -1); - GuiDraw.drawString("Time to smelt: " - + genericRecipe.recipie.tickTime() / 20 - + " seconds", 14, 114, -1); - } + @Override + public void drawBackground(int recipeIndex) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78); + GuiDraw.drawTooltipBox(10, 80, 145, 50); + GuiDraw.drawString("Info:", 14, 84, -1); + CachedRecipe recipe = arecipes.get(recipeIndex); + if (recipe instanceof CachedGenericRecipe) { + CachedGenericRecipe genericRecipe = (CachedGenericRecipe) recipe; + GuiDraw.drawString( + "EU needed: " + + (ConfigTechReborn.CentrifugeInputTick * genericRecipe.recipie + .tickTime()), 14, 94, -1); + GuiDraw.drawString("Ticks to smelt: " + + genericRecipe.recipie.tickTime(), 14, + 104, -1); + GuiDraw.drawString("Time to smelt: " + + genericRecipe.recipie.tickTime() / 20 + + " seconds", 14, 114, -1); + } - } + } - @Override - public int recipiesPerPage() - { - return 1; - } + @Override + public int recipiesPerPage() { + return 1; + } - public void loadTransferRects() - { - this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( - new Rectangle(0, 0, 20, 20), getNeiBaseRecipe().getRecipeName(), new Object[0])); - } + public void loadTransferRects() { + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(0, 0, 20, 20), getNeiBaseRecipe().getRecipeName(), new Object[0])); + } - public void loadCraftingRecipes(String outputId, Object... results) - { - if (outputId.equals(getNeiBaseRecipe().getRecipeName())) - { - for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) - { - addCached(recipeType); - } - } else - { - super.loadCraftingRecipes(outputId, results); - } - } + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getNeiBaseRecipe().getRecipeName())) { + for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) { + addCached(recipeType); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) - { - for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) - { - for(ItemStack output : recipeType.getOutputs()){ - if (ItemUtils.isItemEqual(output, result, true, false, true)) - { - addCached(recipeType); - } - } - } - } + @Override + public void loadCraftingRecipes(ItemStack result) { + for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) { + for (ItemStack output : recipeType.getOutputs()) { + if (ItemUtils.isItemEqual(output, result, true, false, true)) { + addCached(recipeType); + } + } + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) - { - for(ItemStack input : recipeType.getInputs()){ - if (ItemUtils.isItemEqual(ingredient, input, true, false, true)) - { - addCached(recipeType); - } - } - } - } + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) { + for (ItemStack input : recipeType.getInputs()) { + if (ItemUtils.isItemEqual(ingredient, input, true, false, true)) { + addCached(recipeType); + } + } + } + } - private void addCached(IBaseRecipeType recipie) - { - this.arecipes.add(new CachedGenericRecipe(recipie, getNeiBaseRecipe())); - } + private void addCached(IBaseRecipeType recipie) { + this.arecipes.add(new CachedGenericRecipe(recipie, getNeiBaseRecipe())); + } } \ No newline at end of file diff --git a/src/main/java/techreborn/compat/nei/recipes/INeiBaseRecipe.java b/src/main/java/techreborn/compat/nei/recipes/INeiBaseRecipe.java index 583822564..31651bf6c 100644 --- a/src/main/java/techreborn/compat/nei/recipes/INeiBaseRecipe.java +++ b/src/main/java/techreborn/compat/nei/recipes/INeiBaseRecipe.java @@ -1,38 +1,36 @@ package techreborn.compat.nei.recipes; -import java.util.List; - +import codechicken.nei.PositionedStack; import net.minecraft.client.gui.inventory.GuiContainer; import techreborn.api.recipe.IBaseRecipeType; -import codechicken.nei.PositionedStack; + +import java.util.List; /** * Use this to make your neiHandler */ public interface INeiBaseRecipe { - /** - * Add the inputs and the outputs - * @param input add the input stacks to this - * @param outputs add this output stacks to this - */ - public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType); + /** + * Add the inputs and the outputs + * + * @param input add the input stacks to this + * @param outputs add this output stacks to this + */ + public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType); - /** - * - * @return the recipe name that is used for the recipe - */ - public String getRecipeName(); + /** + * @return the recipe name that is used for the recipe + */ + public String getRecipeName(); - /** - * - * @return the guiTexture location - */ - public String getGuiTexture(); + /** + * @return the guiTexture location + */ + public String getGuiTexture(); - /** - * - * @return the gui class for the recipe - */ - public Class getGuiClass(); + /** + * @return the gui class for the recipe + */ + public Class getGuiClass(); } diff --git a/src/main/java/techreborn/compat/nei/recipes/ImplosionCompressorRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/ImplosionCompressorRecipeHandler.java index 94ae9acf2..8242e1306 100644 --- a/src/main/java/techreborn/compat/nei/recipes/ImplosionCompressorRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/ImplosionCompressorRecipeHandler.java @@ -1,55 +1,55 @@ package techreborn.compat.nei.recipes; -import java.util.List; - +import codechicken.nei.PositionedStack; import net.minecraft.client.gui.inventory.GuiContainer; import techreborn.api.recipe.IBaseRecipeType; import techreborn.client.gui.GuiImplosionCompressor; import techreborn.util.ItemUtils; -import codechicken.nei.PositionedStack; + +import java.util.List; public class ImplosionCompressorRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe { - @Override - public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { - int offset = 4; - if(recipeType.getInputs().size() > 0) { + @Override + public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { + int offset = 4; + if (recipeType.getInputs().size() > 0) { PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 34 - offset, 16 - offset); input.add(pStack); } - if(recipeType.getInputs().size() > 1){ + if (recipeType.getInputs().size() > 1) { PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 34 - offset, 34 - offset); input.add(pStack2); } - if(recipeType.getOutputs().size() > 0) { + if (recipeType.getOutputs().size() > 0) { PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 86 - offset, 25 - offset); outputs.add(pStack3); } - if(recipeType.getOutputs().size() > 1) { + if (recipeType.getOutputs().size() > 1) { PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 104 - offset, 25 - offset); outputs.add(pStack4); } - } + } - @Override - public String getRecipeName() { - return "implosionCompressorRecipe"; - } + @Override + public String getRecipeName() { + return "implosionCompressorRecipe"; + } - @Override - public String getGuiTexture() { - return "techreborn:textures/gui/implosion_compressor.png"; - } + @Override + public String getGuiTexture() { + return "techreborn:textures/gui/implosion_compressor.png"; + } - @Override - public Class getGuiClass() { - return GuiImplosionCompressor.class; - } + @Override + public Class getGuiClass() { + return GuiImplosionCompressor.class; + } - @Override - public INeiBaseRecipe getNeiBaseRecipe() { - return this; - } + @Override + public INeiBaseRecipe getNeiBaseRecipe() { + return this; + } } diff --git a/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java index d60cb682a..ac07b8ddc 100644 --- a/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java @@ -1,50 +1,60 @@ package techreborn.compat.nei.recipes; -import java.util.List; - +import codechicken.nei.PositionedStack; import net.minecraft.client.gui.inventory.GuiContainer; import techreborn.api.recipe.IBaseRecipeType; import techreborn.client.gui.GuiIndustrialSawmill; import techreborn.util.ItemUtils; -import codechicken.nei.PositionedStack; + +import java.util.List; public class IndustrialSawmillRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe { - @Override - public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { - int offset = 4; - PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 32 - offset, 26 - offset); - input.add(pStack); + @Override + public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { + int offset = 4; + if (recipeType.getInputs().size() > 0) { + PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 32 - offset, 26 - offset); + input.add(pStack); + } - PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 32 - offset, 44 - offset); - input.add(pStack2); + if (recipeType.getInputs().size() > 1) { + PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 32 - offset, 44 - offset); + input.add(pStack2); + } - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 84 - offset, 35 - offset); - outputs.add(pStack3); - - PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 102 - offset, 35 - offset); - outputs.add(pStack4); - - PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 120 - offset, 35 - offset); - outputs.add(pStack5); - } + if (recipeType.getOutputs().size() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 84 - offset, 35 - offset); + outputs.add(pStack3); + } - @Override - public String getRecipeName() { - return "industrialSawmillRecipe"; - } + if (recipeType.getOutputs().size() > 1) { + PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 102 - offset, 35 - offset); + outputs.add(pStack4); + } - @Override - public String getGuiTexture() { - return "techreborn:textures/gui/industrial_sawmill.png"; - } + if (recipeType.getOutputs().size() > 2) { + PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 120 - offset, 35 - offset); + outputs.add(pStack5); + } + } - @Override - public Class getGuiClass() { - return GuiIndustrialSawmill.class; - } + @Override + public String getRecipeName() { + return "industrialSawmillRecipe"; + } - @Override - public INeiBaseRecipe getNeiBaseRecipe() { - return this; - } + @Override + public String getGuiTexture() { + return "techreborn:textures/gui/industrial_sawmill.png"; + } + + @Override + public Class getGuiClass() { + return GuiIndustrialSawmill.class; + } + + @Override + public INeiBaseRecipe getNeiBaseRecipe() { + return this; + } } diff --git a/src/main/java/techreborn/compat/nei/recipes/LatheRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/LatheRecipeHandler.java index 4c878b097..8b246c315 100644 --- a/src/main/java/techreborn/compat/nei/recipes/LatheRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/LatheRecipeHandler.java @@ -1,41 +1,45 @@ package techreborn.compat.nei.recipes; -import java.util.List; - +import codechicken.nei.PositionedStack; import net.minecraft.client.gui.inventory.GuiContainer; import techreborn.api.recipe.IBaseRecipeType; import techreborn.client.gui.GuiLathe; import techreborn.util.ItemUtils; -import codechicken.nei.PositionedStack; + +import java.util.List; public class LatheRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe { - @Override - public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { - int offset = 4; - PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 56 - offset, 17 - offset); - input.add(pStack); + @Override + public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { + int offset = 4; + if (recipeType.getInputs().size() > 0) { + PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 56 - offset, 17 - offset); + input.add(pStack); + } - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); - outputs.add(pStack3); - } + if (recipeType.getOutputs().size() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); + outputs.add(pStack3); + } + } - @Override - public String getRecipeName() { - return "latheRecipe"; - } + @Override + public String getRecipeName() { + return "latheRecipe"; + } - @Override - public String getGuiTexture() { - return "techreborn:textures/gui/lathe.png"; - } + @Override + public String getGuiTexture() { + return "techreborn:textures/gui/lathe.png"; + } - @Override - public Class getGuiClass() { - return GuiLathe.class; - } + @Override + public Class getGuiClass() { + return GuiLathe.class; + } - @Override - public INeiBaseRecipe getNeiBaseRecipe() { - return this; - } + @Override + public INeiBaseRecipe getNeiBaseRecipe() { + return this; + } } diff --git a/src/main/java/techreborn/compat/nei/recipes/PlateCuttingMachineRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/PlateCuttingMachineRecipeHandler.java index b5faf4236..d03253ad2 100644 --- a/src/main/java/techreborn/compat/nei/recipes/PlateCuttingMachineRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/PlateCuttingMachineRecipeHandler.java @@ -1,41 +1,44 @@ package techreborn.compat.nei.recipes; -import java.util.List; - +import codechicken.nei.PositionedStack; import net.minecraft.client.gui.inventory.GuiContainer; import techreborn.api.recipe.IBaseRecipeType; import techreborn.client.gui.GuiPlateCuttingMachine; import techreborn.util.ItemUtils; -import codechicken.nei.PositionedStack; + +import java.util.List; public class PlateCuttingMachineRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe { - @Override - public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { - int offset = 4; - PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 56 - offset, 17 - offset); - input.add(pStack); + @Override + public void addPositionedStacks(List input, List outputs, IBaseRecipeType recipeType) { + int offset = 4; + if (recipeType.getInputs().size() > 0) { + PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 56 - offset, 17 - offset); + input.add(pStack); + } + if (recipeType.getOutputs().size() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); + outputs.add(pStack3); + } + } - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); - outputs.add(pStack3); - } + @Override + public String getRecipeName() { + return "plateCuttingMachineRecipe"; + } - @Override - public String getRecipeName() { - return "plateCuttingMachineRecipe"; - } + @Override + public String getGuiTexture() { + return "techreborn:textures/gui/plate_cutting_machine.png"; + } - @Override - public String getGuiTexture() { - return "techreborn:textures/gui/plate_cutting_machine.png"; - } + @Override + public Class getGuiClass() { + return GuiPlateCuttingMachine.class; + } - @Override - public Class getGuiClass() { - return GuiPlateCuttingMachine.class; - } - - @Override - public INeiBaseRecipe getNeiBaseRecipe() { - return this; - } + @Override + public INeiBaseRecipe getNeiBaseRecipe() { + return this; + } }