Skip to content

Instantly share code, notes, and snippets.

@riking
Created April 24, 2013 04:57
Show Gist options
  • Save riking/5449722 to your computer and use it in GitHub Desktop.
Save riking/5449722 to your computer and use it in GitHub Desktop.
if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) {
int toPlace = packet102windowclick.button == 0 ? clickedItem.count : 1;
toPlace = Math.min(toPlace, clickedItem.count - cursor.count);
toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - cursor.count);
toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - cursor.count);
if (toPlace == 1) {
action = InventoryAction.PLACE_ONE;
} else if (toPlace == cursor.count) {
action = InventoryAction.PLACE_ALL;
} else if (toPlace <= 0) {
action = InventoryAction.NOTHING;
} else {
action = InventoryAction.PLACE_SOME;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment