diff --git a/src/main/java/lykrast/prodigytech/common/tileentity/TileAtomicReshaper.java b/src/main/java/lykrast/prodigytech/common/tileentity/TileAtomicReshaper.java index aa26676..7834de7 100644 --- a/src/main/java/lykrast/prodigytech/common/tileentity/TileAtomicReshaper.java +++ b/src/main/java/lykrast/prodigytech/common/tileentity/TileAtomicReshaper.java @@ -57,7 +57,12 @@ private int canSmeltPrimordium() private AtomicReshaperRecipe cachedRecipe; private void updateCachedRecipe() { if (cachedRecipe == null) cachedRecipe = AtomicReshaperManager.INSTANCE.findRecipe(getStackInSlot(1)); - else if (!cachedRecipe.isValidInput(getStackInSlot(1))) cachedRecipe = AtomicReshaperManager.INSTANCE.findRecipe(getStackInSlot(1)); + else if (!cachedRecipe.isValidInput(getStackInSlot(1))) { + cachedRecipe = AtomicReshaperManager.INSTANCE.findRecipe(getStackInSlot(1)); + //Recipe became invalid, restart the process + processTimeMax = 0; + processTime = 0; + } } private boolean canProcess() diff --git a/src/main/java/lykrast/prodigytech/common/tileentity/TileFoodEnricher.java b/src/main/java/lykrast/prodigytech/common/tileentity/TileFoodEnricher.java index 4910073..407f0f8 100644 --- a/src/main/java/lykrast/prodigytech/common/tileentity/TileFoodEnricher.java +++ b/src/main/java/lykrast/prodigytech/common/tileentity/TileFoodEnricher.java @@ -50,10 +50,27 @@ public String getName() { return super.getName() + "food_enricher"; } - private ItemStack cachedResult; + private ItemStack cachedResult, lastInput = ItemStack.EMPTY; private void updateCachedResult() { ItemStack input = getStackInSlot(0); - if (input.isEmpty()) cachedResult = null; + //No input + if (input.isEmpty()) { + cachedResult = null; + lastInput = ItemStack.EMPTY; + } + //No cached input, let it slide + else if (lastInput.isEmpty()) { + lastInput = input; + cachedResult = enrich(input); + } + //Input changed + else if (input != lastInput) { + lastInput = input; + cachedResult = enrich(input); + processTimeMax = 0; + processTime = 0; + } + //Missing the cache else if (cachedResult == null) cachedResult = enrich(input); } diff --git a/src/main/java/lykrast/prodigytech/common/tileentity/TileFoodPurifier.java b/src/main/java/lykrast/prodigytech/common/tileentity/TileFoodPurifier.java index 70b9d13..21d0da9 100644 --- a/src/main/java/lykrast/prodigytech/common/tileentity/TileFoodPurifier.java +++ b/src/main/java/lykrast/prodigytech/common/tileentity/TileFoodPurifier.java @@ -32,10 +32,27 @@ public String getName() { return super.getName() + "food_purifier"; } - private ItemStack cachedResult; + private ItemStack cachedResult, lastInput = ItemStack.EMPTY; private void updateCachedResult() { ItemStack input = getStackInSlot(0); - if (input.isEmpty()) cachedResult = null; + //No input + if (input.isEmpty()) { + cachedResult = null; + lastInput = ItemStack.EMPTY; + } + //No cached input, let it slide + else if (lastInput.isEmpty()) { + lastInput = input; + cachedResult = ItemFoodPurified.make(input); + } + //Input changed + else if (input != lastInput) { + lastInput = input; + cachedResult = ItemFoodPurified.make(input); + processTimeMax = 0; + processTime = 0; + } + //Missing the cache else if (cachedResult == null) cachedResult = ItemFoodPurified.make(input); } diff --git a/src/main/java/lykrast/prodigytech/common/tileentity/TileFuelProcessor.java b/src/main/java/lykrast/prodigytech/common/tileentity/TileFuelProcessor.java index 8a5b92f..ade8056 100644 --- a/src/main/java/lykrast/prodigytech/common/tileentity/TileFuelProcessor.java +++ b/src/main/java/lykrast/prodigytech/common/tileentity/TileFuelProcessor.java @@ -48,11 +48,31 @@ public String getName() { return super.getName() + "fuel_processor"; } + private ItemStack lastInput = ItemStack.EMPTY; + private void updateCachedResult() { + ItemStack input = getStackInSlot(0); + //No input + if (input.isEmpty()) { + lastInput = ItemStack.EMPTY; + } + //No cached input, let it slide + else if (lastInput.isEmpty()) { + lastInput = input; + } + //Input changed + else if (input != lastInput) { + lastInput = input; + processTimeMax = 0; + processTime = 0; + } + } + @SuppressWarnings("deprecation") @Override protected boolean canProcess() { if (getStackInSlot(0).isEmpty() || hotAir.getInAirTemperature() < 80) return false; - + + updateCachedResult(); //Assume that if something was inserted it is valid input //And that whatever is in the output slot is a Fuel Pellet if there's something ItemStack curOutput = getStackInSlot(1); @@ -97,6 +117,7 @@ else if (processTime <= 0) { } } else if (processTime >= processTimeMax) { + updateCachedResult(); processTimeMax = 0; processTime = 0; } @@ -123,6 +144,7 @@ private void smelt() { else curOutput.grow(amount); input.shrink(1); + updateCachedResult(); } @Override diff --git a/src/main/java/lykrast/prodigytech/common/tileentity/TileHotAirMachineSecondaryManaged.java b/src/main/java/lykrast/prodigytech/common/tileentity/TileHotAirMachineSecondaryManaged.java index 5b8df68..87b79b7 100644 --- a/src/main/java/lykrast/prodigytech/common/tileentity/TileHotAirMachineSecondaryManaged.java +++ b/src/main/java/lykrast/prodigytech/common/tileentity/TileHotAirMachineSecondaryManaged.java @@ -30,7 +30,12 @@ protected IItemHandlerModifiable createInventoryHandler() { private SimpleRecipeSecondaryOutput cachedRecipe; private void updateCachedRecipe() { if (cachedRecipe == null) cachedRecipe = manager.findRecipe(getStackInSlot(0)); - else if (!cachedRecipe.isValidInput(getStackInSlot(0))) cachedRecipe = manager.findRecipe(getStackInSlot(0)); + else if (!cachedRecipe.isValidInput(getStackInSlot(0))) { + cachedRecipe = manager.findRecipe(getStackInSlot(0)); + //Recipe became invalid, restart the process + processTimeMax = 0; + processTime = 0; + } } @Override diff --git a/src/main/java/lykrast/prodigytech/common/tileentity/TileHotAirMachineSimpleManaged.java b/src/main/java/lykrast/prodigytech/common/tileentity/TileHotAirMachineSimpleManaged.java index 1332819..1660154 100644 --- a/src/main/java/lykrast/prodigytech/common/tileentity/TileHotAirMachineSimpleManaged.java +++ b/src/main/java/lykrast/prodigytech/common/tileentity/TileHotAirMachineSimpleManaged.java @@ -25,7 +25,12 @@ protected boolean isTooCool() { private SimpleRecipe cachedRecipe; private void updateCachedRecipe() { if (cachedRecipe == null) cachedRecipe = manager.findRecipe(getStackInSlot(0)); - else if (!cachedRecipe.isValidInput(getStackInSlot(0))) cachedRecipe = manager.findRecipe(getStackInSlot(0)); + else if (!cachedRecipe.isValidInput(getStackInSlot(0))) { + cachedRecipe = manager.findRecipe(getStackInSlot(0)); + //Recipe became invalid, restart the process + processTimeMax = 0; + processTime = 0; + } } @Override diff --git a/src/main/java/lykrast/prodigytech/common/tileentity/TileMachineInventory.java b/src/main/java/lykrast/prodigytech/common/tileentity/TileMachineInventory.java index fcdd62e..0a6fda6 100644 --- a/src/main/java/lykrast/prodigytech/common/tileentity/TileMachineInventory.java +++ b/src/main/java/lykrast/prodigytech/common/tileentity/TileMachineInventory.java @@ -26,7 +26,7 @@ public TileMachineInventory(int slots) { @Override public ITextComponent getDisplayName() { - return new TextComponentTranslation(this.getName(), new Object[0]); + return new TextComponentTranslation(getName()); } @Override diff --git a/src/main/java/lykrast/prodigytech/common/tileentity/TileSolderer.java b/src/main/java/lykrast/prodigytech/common/tileentity/TileSolderer.java index 737dc0d..853325b 100644 --- a/src/main/java/lykrast/prodigytech/common/tileentity/TileSolderer.java +++ b/src/main/java/lykrast/prodigytech/common/tileentity/TileSolderer.java @@ -63,7 +63,12 @@ private int canSmeltGold() private SoldererRecipe cachedRecipe; private void updateCachedRecipe() { if (cachedRecipe == null) cachedRecipe = SoldererManager.findRecipe(getStackInSlot(0), getStackInSlot(2), gold); - else if (!cachedRecipe.isValidInput(getStackInSlot(0), getStackInSlot(2), gold)) cachedRecipe = SoldererManager.findRecipe(getStackInSlot(0), getStackInSlot(2), gold); + else if (!cachedRecipe.isValidInput(getStackInSlot(0), getStackInSlot(2), gold)) { + cachedRecipe = SoldererManager.findRecipe(getStackInSlot(0), getStackInSlot(2), gold); + //Recipe became invalid, restart the process + processTimeMax = 0; + processTime = 0; + } } private boolean canProcess()