Made crafter not randomly create stacks with 0 items in them

Closes #127
This commit is contained in:
Ellpeck 2016-06-17 13:03:57 +02:00
parent f97ba2d31c
commit bfd5311512

View file

@ -50,44 +50,55 @@ public class ContainerCrafter extends Container{
} }
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){ public ItemStack transferStackInSlot(EntityPlayer player, int index){
ItemStack stack = null; ItemStack itemstack = null;
Slot theSlot = this.inventorySlots.get(slot); Slot slot = this.inventorySlots.get(index);
if(theSlot != null && theSlot.getHasStack()){ if(slot != null && slot.getHasStack()){
ItemStack savedStack = theSlot.getStack(); ItemStack itemstack1 = slot.getStack();
stack = savedStack.copy(); itemstack = itemstack1.copy();
if(slot == 0){ if(index == 0){
if(!this.mergeItemStack(savedStack, 10, 46, true)){ if(!this.mergeItemStack(itemstack1, 10, 46, true)){
return null;
}
theSlot.onSlotChange(savedStack, stack);
}
else if(slot >= 10 && slot < 37 && !this.mergeItemStack(savedStack, 37, 46, false)){
return null;
}
else if(slot >= 37 && slot < 46 && !this.mergeItemStack(savedStack, 10, 37, false)){
return null;
}
else if(!this.mergeItemStack(savedStack, 10, 46, false)){
return null; return null;
} }
if(savedStack.stackSize <= 0){ slot.onSlotChange(itemstack1, itemstack);
theSlot.putStack(null); }
else if(index >= 10 && index < 37){
if(!this.mergeItemStack(itemstack1, 37, 46, false)){
return null;
}
}
else if(index >= 37 && index < 46){
if(!this.mergeItemStack(itemstack1, 10, 37, false)){
return null;
}
}
else if(!this.mergeItemStack(itemstack1, 10, 46, false)){
return null;
}
if(itemstack1.stackSize <= 0){
slot.putStack(null);
} }
else{ else{
theSlot.onSlotChanged(); slot.onSlotChanged();
} }
if(savedStack.stackSize == stack.stackSize){ if(itemstack1.stackSize == itemstack.stackSize){
return null; return null;
} }
theSlot.onPickupFromSlot(player, savedStack); slot.onPickupFromSlot(player, itemstack1);
} }
return stack;
return itemstack;
}
@Override
public boolean canMergeSlot(ItemStack stack, Slot slotIn){
return slotIn.inventory != this.craftResult && super.canMergeSlot(stack, slotIn);
} }
@Override @Override