Created
December 1, 2010 21:16
-
-
Save nijikokun/724243 to your computer and use it in GitHub Desktop.
hasItems hMod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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