@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotnumber)
{
ItemStack itemstack = null;
Slot slot = (Slot) inventorySlots.get(slotnumber);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (inventory.isItemValidForSlot(0, itemstack1))
{
if (slotnumber >= 0 && slotnumber <= 7)
{
mergeItemStack(itemstack, 8, 43, true);
slot.onSlotChanged();
return null;
} else if (slotnumber >= 8 && slotnumber <= 43)
{
mergeItemStack(itemstack, 0, 7, true);
slot.onSlotChanged();
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack(null);
} else
{
slot.onSlotChanged();
}
} else
{
return null;
}