From c2f04bc77f19fd839c60a8df3aada733b465653c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 2 Nov 2016 21:15:28 +0100 Subject: [PATCH] Made the reconstructor reconstruct even if it can't change the entire stack --- .../mod/misc/MethodHandler.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/MethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/MethodHandler.java index d3d0b820b..f0337f192 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/MethodHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/MethodHandler.java @@ -183,17 +183,29 @@ public class MethodHandler implements IMethodHandler{ if(!item.isDead && stack != null){ List recipes = LensRecipeHandler.getRecipesFor(stack); for(LensConversionRecipe recipe : recipes){ - if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse*stack.stackSize){ - ItemStack outputCopy = recipe.outputStack.copy(); - outputCopy.stackSize = stack.stackSize; + if(recipe != null && recipe.type == tile.getLens()){ + int itemsPossible = Math.min(tile.getEnergy()/recipe.energyUse, stack.stackSize); - item.setDead(); + if(itemsPossible > 0){ + item.setDead(); - EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy); - tile.getWorldObject().spawnEntityInWorld(newItem); + if(stack.stackSize > 0){ + ItemStack stackCopy = stack.copy(); + stackCopy.stackSize-=itemsPossible; - tile.extractEnergy(recipe.energyUse*stack.stackSize); - break; + EntityItem inputLeft = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, stackCopy); + tile.getWorldObject().spawnEntityInWorld(inputLeft); + } + + ItemStack outputCopy = recipe.outputStack.copy(); + outputCopy.stackSize = itemsPossible; + + EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy); + tile.getWorldObject().spawnEntityInWorld(newItem); + + tile.extractEnergy(recipe.energyUse*itemsPossible); + break; + } } } }