Skip to content

Instantly share code, notes, and snippets.

@riking
Created July 7, 2013 18:49
Show Gist options
  • Save riking/5944498 to your computer and use it in GitHub Desktop.
Save riking/5944498 to your computer and use it in GitHub Desktop.
/**
* Get the inventory in this view that contains the given slot.
* @param rawSlot a raw slot number
* @return the inventory with that slot number, or null if not applicable
*/
public final Inventory getInventoryWithSlot(int rawSlot) {
int numInTop = getTopInventory().getSize();
if (rawSlot < 0) {
return null;
} else if (rawSlot < numInTop) {
return getTopInventory();
} else if (rawSlot < numInTop + getBottomInventory().getSize()) {
return getBottomInventory();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment