Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void fillChest() {
- Material[] items1 = new Material[] { Material.GOLDEN_APPLE, Material.IRON_SWORD, Material.IRON_CHESTPLATE, Material.IRON_SWORD };
- Material[] items2 = new Material[] { Material.APPLE, Material.WOOD_SWORD, Material.LEATHER_CHESTPLATE, Material.BOW, Material.ARROW };
- Random r = new Random();
- int numItems = r.nextInt(5) + 1; // A random number between 1 and 5.
- for (int i = 0; i < numItems; i++) {
- Material material = null;
- if (tier == 1) {
- material = items1[r.nextInt(items1.length)]; // A random Materials from the items1 array.
- }
- else if (tier == 2) {
- material = items2[r.nextInt(items2.length)]; // A random Materials from the items2 array.
- }
- ItemStack item = new ItemStack(material, 1);
- int index;
- do {
- index = r.nextInt(chest.getInventory().getSize());
- } while (chest.getInventory().getItem(index) != null);
- chest.getInventory().setItem(index, item);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement