make only coffee machine and coal generator return their container item

This commit is contained in:
Ellpeck 2016-12-01 18:20:37 +01:00
parent 142b5d394f
commit 2cc5d02814
3 changed files with 13 additions and 4 deletions

View file

@ -79,7 +79,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
this.maxBurnTime = burnTime; this.maxBurnTime = burnTime;
this.currentBurnTime = burnTime; this.currentBurnTime = burnTime;
this.slots[0] = StackUtil.addStackSize(this.slots[0], -1); this.slots[0] = StackUtil.addStackSize(this.slots[0], -1, true);
} }
if(flag != this.currentBurnTime > 0){ if(flag != this.currentBurnTime > 0){

View file

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

View file

@ -50,8 +50,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{
@ -63,6 +67,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);
}
} }