From 0ea07a6a1af97abf1c9f569af26e5dfcc0038bee Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 11 Jun 2015 21:35:05 +0100 Subject: [PATCH] added way to not use ore dic --- .../java/techreborn/api/recipe/BaseRecipe.java | 5 +++++ .../techreborn/api/recipe/IBaseRecipeType.java | 2 ++ .../techreborn/api/recipe/RecipeCrafter.java | 16 ++++++++-------- .../recipe/machines/IndustrialSawmillRecipe.java | 5 +++++ .../recipes/IndustrialSawmillRecipeHandler.java | 4 ++-- src/main/java/techreborn/init/ModRecipes.java | 4 ++++ 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/techreborn/api/recipe/BaseRecipe.java b/src/main/java/techreborn/api/recipe/BaseRecipe.java index 50dae320c..b7a832f4c 100644 --- a/src/main/java/techreborn/api/recipe/BaseRecipe.java +++ b/src/main/java/techreborn/api/recipe/BaseRecipe.java @@ -79,4 +79,9 @@ public abstract class BaseRecipe implements IBaseRecipeType , Cloneable { public Object clone()throws CloneNotSupportedException{ return super.clone(); } + + @Override + public boolean useOreDic() { + return true; + } } diff --git a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java index 3b5f54791..91762ce28 100644 --- a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java +++ b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java @@ -65,4 +65,6 @@ public interface IBaseRecipeType { public boolean onCraft(TileEntity tile); public Object clone()throws CloneNotSupportedException; + + public boolean useOreDic(); } diff --git a/src/main/java/techreborn/api/recipe/RecipeCrafter.java b/src/main/java/techreborn/api/recipe/RecipeCrafter.java index 1af0c1204..1151742e6 100644 --- a/src/main/java/techreborn/api/recipe/RecipeCrafter.java +++ b/src/main/java/techreborn/api/recipe/RecipeCrafter.java @@ -119,7 +119,7 @@ public class RecipeCrafter { 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.getOutputsSize(); i++) {//This checks to see if it can fit all of the outputs - if (!canFitStack(recipe.getOutput(i), outputSlots[i])) { + if (!canFitStack(recipe.getOutput(i), outputSlots[i], recipe.useOreDic())) { canGiveInvAll = false; break; } @@ -144,7 +144,7 @@ public class RecipeCrafter { if (currentRecipe != null && currentTickTime >= currentNeededTicks) {//If it has reached the recipe tick time boolean canGiveInvAll = true; for (int i = 0; i < currentRecipe.getOutputsSize(); i++) {//Checks to see if it can fit the output - if (!canFitStack(currentRecipe.getOutput(i), outputSlots[i])) { + if (!canFitStack(currentRecipe.getOutput(i), outputSlots[i], currentRecipe.useOreDic())) { canGiveInvAll = false; } } @@ -176,7 +176,7 @@ public class RecipeCrafter { 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) { + if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, currentRecipe.useOreDic()) && inventory.getStackInSlot(inputSlot).stackSize >= input.stackSize) { hasItem = true; } } @@ -193,7 +193,7 @@ public class RecipeCrafter { for (ItemStack input : recipeType.getInputs()) { Boolean hasItem = false; for (int inputslot : inputSlots) { - if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true, true) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize) { + if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true, recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize) { hasItem = true; } } @@ -209,7 +209,7 @@ public class RecipeCrafter { } for (ItemStack input : currentRecipe.getInputs()) { for (int inputSlot : inputSlots) {//Uses all of the inputs - if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, true)) { + if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, currentRecipe.useOreDic())) { inventory.decrStackSize(inputSlot, input.stackSize); break; } @@ -217,14 +217,14 @@ public class RecipeCrafter { } } - public boolean canFitStack(ItemStack stack, int slot) {//Checks to see if it can fit the stack + public boolean canFitStack(ItemStack stack, int slot, boolean oreDic) {//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 (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic)) { if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) { return true; } @@ -240,7 +240,7 @@ public class RecipeCrafter { inventory.setInventorySlotContents(slot, stack); return; } - if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, true)) {//If the slot has stuff in + if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, currentRecipe.useOreDic())) {//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 diff --git a/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java b/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java index f14dd7761..e6e88ac0f 100644 --- a/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java @@ -67,4 +67,9 @@ public class IndustrialSawmillRecipe extends BaseRecipe { } return false; } + + @Override + public boolean useOreDic() { + return false; + } } diff --git a/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java index 542a6ee8b..d728c6f2c 100644 --- a/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java @@ -13,12 +13,12 @@ public class IndustrialSawmillRecipeHandler extends GenericRecipeHander implemen 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); + PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 32 - offset, 26 - offset); input.add(pStack); } if (recipeType.getInputs().size() > 1) { - PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 32 - offset, 44 - offset); + PositionedStack pStack2 = new PositionedStack(recipeType.getInputs().get(1), 32 - offset, 44 - offset); input.add(pStack2); } diff --git a/src/main/java/techreborn/init/ModRecipes.java b/src/main/java/techreborn/init/ModRecipes.java index 3540798bd..e92a58037 100644 --- a/src/main/java/techreborn/init/ModRecipes.java +++ b/src/main/java/techreborn/init/ModRecipes.java @@ -4,6 +4,7 @@ import ic2.api.item.IC2Items; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import techreborn.api.BlastFurnaceRecipe; @@ -159,6 +160,9 @@ public class ModRecipes { RecipeHandler.addRecipe(new GrinderRecipe(new ItemStack(ModBlocks.ore, 1, 1), new ItemStack(ModItems.cells, 1, 16), null, IC2Items.getItem("iridiumOre"), new ItemStack(ModItems.smallDusts, 6, 39), new ItemStack(ModItems.dusts, 6, 58), IC2Items.getItem("cell"), 400, 5)); RecipeHandler.addRecipe(new CentrifugeRecipe(new ItemStack(Items.coal), null, new ItemStack(Items.diamond), new ItemStack(Items.emerald), new ItemStack(Items.apple), new ItemStack(Items.arrow), 1, 10)); + + RecipeHandler.addRecipe(new IndustrialSawmillRecipe(new ItemStack(Blocks.log, 1), null, new FluidStack(FluidRegistry.WATER, 1000), new ItemStack(Blocks.planks, 6, 0), ItemDusts.getDustByName("ashes", 1), null, 100, 10)); + LogHelper.info("Machine Recipes Added"); }