Make only the coffee machine and coal generator return their container item

Closes #426
This commit is contained in:
Ellpeck 2016-12-01 18:07:42 +01:00
parent 7c0c366e43
commit cfd6506eb3
3 changed files with 12 additions and 4 deletions

View file

@ -80,7 +80,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
this.maxBurnTime = burnTime; this.maxBurnTime = burnTime;
this.currentBurnTime = burnTime; this.currentBurnTime = burnTime;
this.slots.set(0, StackUtil.addStackSize(this.slots.get(0), -1)); this.slots.set(0, StackUtil.addStackSize(this.slots.get(0), -1, true));
} }
if(flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()){ if(flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()){

View file

@ -157,7 +157,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.slots.get(i)); CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.slots.get(i));
if(ingredient != null){ if(ingredient != null){
if(ingredient.effect(output)){ if(ingredient.effect(output)){
this.slots.set(i, StackUtil.addStackSize(this.slots.get(i), -1)); this.slots.set(i, StackUtil.addStackSize(this.slots.get(i), -1, true));
} }
} }
} }

View file

@ -51,8 +51,12 @@ public final class StackUtil{
} }
public static ItemStack setStackSize(ItemStack stack, int size){ public static ItemStack setStackSize(ItemStack stack, int size){
return setStackSize(stack, size, false);
}
public static ItemStack setStackSize(ItemStack stack, int size, boolean containerOnEmpty){
if(size <= 0){ if(size <= 0){
if(isValid(stack)){ if(isValid(stack) && containerOnEmpty){
return stack.getItem().getContainerItem(stack); return stack.getItem().getContainerItem(stack);
} }
else{ else{
@ -64,7 +68,11 @@ public final class StackUtil{
} }
public static ItemStack addStackSize(ItemStack stack, int size){ public static ItemStack addStackSize(ItemStack stack, int size){
return setStackSize(stack, getStackSize(stack)+size); return addStackSize(stack, size, false);
}
public static ItemStack addStackSize(ItemStack stack, int size, boolean containerOnEmpty){
return setStackSize(stack, getStackSize(stack)+size, containerOnEmpty);
} }
public static boolean isIInvEmpty(NonNullList<ItemStack> slots){ public static boolean isIInvEmpty(NonNullList<ItemStack> slots){