return super.slotClick( slotID, buttonPressed, flag, player );
if( isUpdateRequired() )
onContentsChanged();
Slot slot = slotID < 0 ? null : getSlot( slotID );
ItemStack stackInSlot;
ItemStack playerStack;
InventoryPlayer inventoryPlayer = player.inventory;
switch( specialCase ) {
case 1: // clicking on the crafting grid slots:
if( flag == 1 ) { // clear on shift-clicking.
slot.putStack( null );
return null;
}
playerStack = inventoryPlayer.getItemStack();
if( buttonPressed == 0 || playerStack == null ) {
slot.putStack( null );
} else if( buttonPressed == 1 ) {
ItemStack copy = playerStack.copy();
copy.stackSize = 1;
slot.putStack( copy );
}
return null;
case 2: // interacting with the hotkeys:
ItemStack invStack = inventoryPlayer.getStackInSlot( buttonPressed );
if( invStack != null ) {
ItemStack copy = invStack.copy();
copy.stackSize = 1;
slot.putStack( copy );
}
return invStack;
case 4: // pressing the DROP key.
stackInSlot = slot.getStack();
slot.putStack( null );
return stackInSlot;
case 5: // placing the dragged stuff.
handleDragging( slotID, buttonPressed, player.inventory );
this.detectAndSendChanges();
break;
case 6: // double click (clears the crafting grid).
clearCraftingGrid();
this.detectAndSendChanges();
return null;
case 10: // redirect the right click into a left click.
return slotClick( slotID, 0, flag, player );
case 11: // regular clicking on an output slot.
if( !slot.getHasStack() || !slot.canTakeStack( player ) )
return null;
stackInSlot = ((SlotCraft) slot).getCraftedStack();
playerStack = inventoryPlayer.getItemStack();
if( playerStack == null ) { // Full extraction from slot.
inventoryPlayer.setItemStack( stackInSlot );
slot.onPickupFromSlot( player, inventoryPlayer.getItemStack() );
} else {
int sum = stackInSlot.stackSize + playerStack.stackSize;
// Merge into player's hand.
if( Utils.equalsStacks( stackInSlot, playerStack ) && sum <= stackInSlot.getMaxStackSize() ) {
playerStack.stackSize = sum;
slot.onPickupFromSlot( player, inventoryPlayer.getItemStack() );
}
}
slot.onSlotChanged();
return stackInSlot;
case 12: // interacting with the hotkeys
if( !slot.canTakeStack( player ) )
return null;
stackInSlot = ((SlotCraft) slot).getCraftedStack();
if( stackInSlot == null )
return null;
playerStack = inventoryPlayer.getStackInSlot( buttonPressed );
if( playerStack == null ) {
inventoryPlayer.setInventorySlotContents( buttonPressed, stackInSlot );
slot.onPickupFromSlot( player, stackInSlot );
} else {
int indx = inventoryPlayer.getFirstEmptyStack();
if( indx > -1 ) {
inventoryPlayer.setInventorySlotContents( buttonPressed, stackInSlot );
inventoryPlayer.addItemStackToInventory( playerStack );
slot.onPickupFromSlot( player, stackInSlot );
}
}
return stackInSlot;
case 14: // dropping from an output slot.
if( slot.getHasStack() && slot.canTakeStack( player ) ) {
ItemStack itemStack = ((SlotCraft) slot).getCraftedStack();
slot.onPickupFromSlot( player, itemStack );
player.dropPlayerItem( ((SlotCraft) slot).getCraftedStack() );
return itemStack;
}
return null;
}