mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Made the reconstructor reconstruct even if it can't change the entire stack
This commit is contained in:
parent
ad3bb33d03
commit
c2f04bc77f
1 changed files with 20 additions and 8 deletions
|
@ -183,21 +183,33 @@ 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;
|
|
||||||
|
|
||||||
|
if(itemsPossible > 0){
|
||||||
item.setDead();
|
item.setDead();
|
||||||
|
|
||||||
|
if(stack.stackSize > 0){
|
||||||
|
ItemStack stackCopy = stack.copy();
|
||||||
|
stackCopy.stackSize-=itemsPossible;
|
||||||
|
|
||||||
|
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);
|
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy);
|
||||||
tile.getWorldObject().spawnEntityInWorld(newItem);
|
tile.getWorldObject().spawnEntityInWorld(newItem);
|
||||||
|
|
||||||
tile.extractEnergy(recipe.energyUse*stack.stackSize);
|
tile.extractEnergy(recipe.energyUse*itemsPossible);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue