Ok so i have the falling chest fixed but now i have a prob with setting random items in it. heres my code for that atm Code:java @EventHandler public void checkBlock(EntityChangeBlockEvent e) { if(e.getEntity() instanceof FallingBlock) { FallingBlock fblock = (FallingBlock) e.getEntity(); if(fblock.getMaterial() == Material.CHEST) { e.getBlock().setType(Material.CHEST); if(e.getBlock().getType() == Material.CHEST) { Chest chest = (Chest) e.getBlock().getState(); Random random = new Random(); for (int i = 0; i < 27; i++) { Integer num = Integer.valueOf(random.nextInt(801)); if ((num.intValue() == 1) || (num.intValue() == 2)) { Integer num2 = Integer.valueOf(random.nextInt(5)); if (num2.intValue() == 1) { new ItemStack(Material.DIAMOND_SWORD); } else if (num2.intValue() == 2) { new ItemStack(Material.DIAMOND_BOOTS); } else if (num2.intValue() == 3) { new ItemStack(Material.DIAMOND_LEGGINGS); } else if (num2.intValue() == 4) { new ItemStack(Material.DIAMOND_CHESTPLATE); } else if (num2.intValue() == 5) { new ItemStack(Material.DIAMOND_HELMET); } } else if (num.intValue() == 6) { new ItemStack(Material.IRON_SWORD); } else if (num.intValue() == 7) { new ItemStack(Material.IRON_BOOTS); } else if (num.intValue() == 8) { new ItemStack(Material.IRON_LEGGINGS); } else if (num.intValue() == 9) { new ItemStack(Material.IRON_CHESTPLATE); } else if (num.intValue() == 10) { new ItemStack(Material.IRON_HELMET); } else if ((num.intValue() == 12) || (num.intValue() == 13)) { new ItemStack(Material.GOLD_SWORD); } else if ((num.intValue() == 14) || (num.intValue() == 15)) { new ItemStack(Material.GOLD_BOOTS); } else if ((num.intValue() == 11) || (num.intValue() == 16)) { new ItemStack(Material.GOLD_LEGGINGS); } else if ((num.intValue() == 17) || (num.intValue() == 19)) { new ItemStack(Material.GOLD_CHESTPLATE); } else if ((num.intValue() == 20) || (num.intValue() == 18)) { new ItemStack(Material.GOLD_HELMET); } else if ((num.intValue() == 22) || (num.intValue() == 23)) { new ItemStack(Material.STONE_SWORD); } else if ((num.intValue() == 24) || (num.intValue() == 25)) { new ItemStack(Material.CHAINMAIL_BOOTS); } else if ((num.intValue() == 21) || (num.intValue() == 26)) { new ItemStack(Material.CHAINMAIL_LEGGINGS); } else if ((num.intValue() == 27) || (num.intValue() == 29)) { new ItemStack(Material.CHAINMAIL_CHESTPLATE); } else if ((num.intValue() == 30) || (num.intValue() == 28)) { new ItemStack(Material.CHAINMAIL_HELMET); } else if ((num.intValue() == 34) || (num.intValue() == 35)) { new ItemStack(Material.LEATHER_BOOTS); } else if ((num.intValue() == 31) || (num.intValue() == 36)) { new ItemStack(Material.LEATHER_LEGGINGS); } else if ((num.intValue() == 37) || (num.intValue() == 39)) { new ItemStack(Material.LEATHER_CHESTPLATE); } else if ((num.intValue() == 40) || (num.intValue() == 38)) { new ItemStack(Material.LEATHER_HELMET); } else if ((num.intValue() == 32) || (num.intValue() == 33) || (num.intValue() == 44) || (num.intValue() == 43) || (num.intValue() == 42) || (num.intValue() == 41) || (num.intValue() == 45)) { new ItemStack(Material.WOOD_SWORD); } else if ((num.intValue() == 50) || (num.intValue() == 46)) { new ItemStack(Material.COOKED_BEEF, 6); } else if ((num.intValue() == 51) || (num.intValue() == 47)) { new ItemStack(Material.COOKED_FISH, 4); } else if ((num.intValue() == 52) || (num.intValue() == 754) || (num.intValue() == 536)) { new ItemStack(Material.BAKED_POTATO, 7); } else if (num.intValue() == 53) { new ItemStack(Material.APPLE, 11); } else if (num.intValue() == 54) { new ItemStack(Material.COOKED_BEEF, 2); } else if ((num.intValue() == 55) || (num.intValue() == 56)) { new ItemStack(Material.COOKED_BEEF, 3); } else if ((num.intValue() == 57) || (num.intValue() == 58)) { new ItemStack(Material.POTATO_ITEM, 1); } else if ((num.intValue() == 59) || (num.intValue() == 60)) { if (num.intValue() == 59) { new ItemStack(Material.RAW_FISH, 6); } else { new ItemStack(Material.RAW_FISH, 3); } } else if ((num.intValue() == 61) || (num.intValue() == 62)) { new ItemStack(Material.RAW_CHICKEN, 2); } else if ((num.intValue() == 63) || (num.intValue() == 64) || (num.intValue() == 65)) { new ItemStack(Material.RAW_BEEF, 4); } else if (num.intValue() == 66) { new ItemStack(Material.GOLDEN_APPLE); } else if (num.intValue() == 67) { new ItemStack(Material.GOLDEN_APPLE, 2); } else if ((num.intValue() == 68) || (num.intValue() == 69)) { new ItemStack(Material.COOKED_CHICKEN, 3); } else if ((num.intValue() == 70) || (num.intValue() == 71)) { new ItemStack(Material.COOKED_CHICKEN); } else if ((num.intValue() == 72) || (num.intValue() == 73)) { new ItemStack(Material.BOW); } else if ((num.intValue() == 74) || (num.intValue() == 75) || (num.intValue() == 76)) { new ItemStack(Material.ARROW, random.nextInt(25)); } else if ((num.intValue() == 76) || (num.intValue() == 77)) { new ItemStack(Material.EXP_BOTTLE, random.nextInt(22)); } else if ((num.intValue() == 100) || (num.intValue() == 101)) { new ItemStack(Material.WOOD_AXE); } else if (num.intValue() == 102) { new ItemStack(Material.STONE_AXE); } else if (num.intValue() == 103) { new ItemStack(Material.GOLD_AXE); } else if (num.intValue() == 104) { new ItemStack(Material.IRON_AXE); } else if (num.intValue() == 105) { new ItemStack(Material.ENDER_PEARL, random.nextInt(3)); } else if ((num.intValue() == 107) || (num.intValue() == 108)) { new ItemStack(Material.BOWL); } else if (num.intValue() == 109) { new ItemStack(Material.BOWL, 2); } } chest.update(); e.setCancelled(true); } } } } } Can any one tell me whats wrong. And also when i tested this the chest had no items in it.
5scb8 Just saying.. you can't make chests fall and make them look like chests. When they are a falling block, they look like a regular wood block.
ik idc. It still spawns the chest on the ground so its all good You mean something like this chest.getInventory().setContents(arg0); EDIT by Moderator: merged posts, please use the edit button instead of double posting.
5scb8 You create an ItemStack but never do anything with it. Where you have the new ItemStack(whatever), put that in chest.getInventory().add or something like that inside the if statement.