Skip to content

Instantly share code, notes, and snippets.

@nijikokun
Created December 1, 2010 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nijikokun/724243 to your computer and use it in GitHub Desktop.
Save nijikokun/724243 to your computer and use it in GitHub Desktop.
hasItems hMod
public boolean hasItems(Player player, int item, int amount) {
hm[] items = player.getInventory().getArray();
int len = items.length;
int counter = 0;
for (int i = 0; i < len; i++) {
hm current = items[i];
// Avoid infinite stacks
if (current == null || current.a <= 0) {
continue;
}
if (current.c != item) {
continue;
}
counter += item.a;
}
return (counter > amount || counter == amount) ? true : false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment