Made the reconstructor reconstruct even if it can't change the entire stack

This commit is contained in:
Ellpeck 2016-11-02 21:15:28 +01:00
parent ad3bb33d03
commit c2f04bc77f

View file

@ -183,17 +183,29 @@ public class MethodHandler implements IMethodHandler{
if(!item.isDead && stack != null){ if(!item.isDead && stack != null){
List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(stack); List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(stack);
for(LensConversionRecipe recipe : recipes){ for(LensConversionRecipe recipe : recipes){
if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse*stack.stackSize){ if(recipe != null && recipe.type == tile.getLens()){
ItemStack outputCopy = recipe.outputStack.copy(); int itemsPossible = Math.min(tile.getEnergy()/recipe.energyUse, stack.stackSize);
outputCopy.stackSize = stack.stackSize;
item.setDead(); if(itemsPossible > 0){
item.setDead();
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy); if(stack.stackSize > 0){
tile.getWorldObject().spawnEntityInWorld(newItem); ItemStack stackCopy = stack.copy();
stackCopy.stackSize-=itemsPossible;
tile.extractEnergy(recipe.energyUse*stack.stackSize); EntityItem inputLeft = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, stackCopy);
break; 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;
}
} }
} }
} }