From def8cb53558d4f06805009c7cc82292f3b683088 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 18 Nov 2017 20:37:14 +0000 Subject: [PATCH] Fix dupe bug, Fixes https://github.com/TechReborn/TechReborn/issues/1342 --- .../techreborn/tiles/TileRollingMachine.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/techreborn/tiles/TileRollingMachine.java b/src/main/java/techreborn/tiles/TileRollingMachine.java index c932e7101..9f4eeee8b 100644 --- a/src/main/java/techreborn/tiles/TileRollingMachine.java +++ b/src/main/java/techreborn/tiles/TileRollingMachine.java @@ -114,7 +114,7 @@ public class TileRollingMachine extends TilePowerAcceptor boolean hasCrafted = false; if (this.inventory.getStackInSlot(outputSlot) == ItemStack.EMPTY) { this.inventory.setInventorySlotContents(outputSlot, this.currentRecipe); - this.tickTime = -1; + this.tickTime = 0; hasCrafted = true; } else { if (this.inventory.getStackInSlot(outputSlot).getCount() + this.currentRecipe.getCount() <= this.currentRecipe @@ -122,7 +122,7 @@ public class TileRollingMachine extends TilePowerAcceptor final ItemStack stack = this.inventory.getStackInSlot(outputSlot); stack.setCount(stack.getCount() + this.currentRecipe.getCount()); this.inventory.setInventorySlotContents(outputSlot, stack); - this.tickTime = -1; + this.tickTime = 0; hasCrafted = true; } } @@ -136,13 +136,13 @@ public class TileRollingMachine extends TilePowerAcceptor } } if (!this.currentRecipe.isEmpty()) { - if (this.canUseEnergy(energyPerTick) && this.tickTime < TileRollingMachine.runTime) { + if (this.canUseEnergy(energyPerTick) && this.tickTime < TileRollingMachine.runTime && canMake()) { this.useEnergy(energyPerTick); this.tickTime++; } } if (this.currentRecipe.isEmpty()) { - this.tickTime = -1; + this.tickTime = 0; } } else { this.currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world); @@ -155,7 +155,15 @@ public class TileRollingMachine extends TilePowerAcceptor } public boolean canMake() { - return RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world) != null; + ItemStack stack = RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world); + if(stack.isEmpty()){ + return false; + } + ItemStack output = getStackInSlot(outputSlot); + if(output.isEmpty()){ + return true; + } + return ItemUtils.isItemEqual(stack, output, true, true); } @Override