InventoryAdaptor playerHand = new AdaptorPlayerHand( player );
WrapperInvSlot slotInv = new PatternInvSlot( inv.server );
IInventory theSlot = slotInv.getWrapper( slot );
InventoryAdaptor interfaceSlot = new AdaptorIInventory( theSlot );
switch (action)
{
case PICKUP_OR_SET_DOWN:
if ( hasItemInHand )
{
ItemStack inSlot = theSlot.getStackInSlot( 0 );
if ( inSlot == null )
player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) );
else
{
inSlot = inSlot.copy();
ItemStack inHand = player.inventory.getItemStack().copy();
theSlot.setInventorySlotContents( 0, null );
player.inventory.setItemStack( null );
player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) );
if ( player.inventory.getItemStack() == null )
player.inventory.setItemStack( inSlot );
else
{
player.inventory.setItemStack( inHand );
theSlot.setInventorySlotContents( 0, inSlot );
}
}
}
else
{
IInventory mySlot = slotInv.getWrapper( slot );
mySlot.setInventorySlotContents( 0, playerHand.addItems( mySlot.getStackInSlot( 0 ) ) );
}
break;
case SPLIT_OR_PLACE_SINGLE:
if ( hasItemInHand )
{
ItemStack extra = playerHand.removeItems( 1, null, null );
if ( extra != null )
extra = interfaceSlot.addItems( extra );
if ( extra != null )
playerHand.addItems( extra );
}
else if ( is != null )
{
ItemStack extra = interfaceSlot.removeItems( (is.stackSize + 1) / 2, null, null );
if ( extra != null )
extra = playerHand.addItems( extra );
if ( extra != null )
interfaceSlot.addItems( extra );
}
break;
case SHIFT_CLICK: