Posted August 2, 201411 yr Hi, I need help with Chests. I have generation that spawns chest and all working great. Now my problem is that i dont want my chest to get RANDOM items inside of it i want 3 items no more not less and not random 3 items, that i want to have inside. My current code: ( set for random, i dont know how to change it that 3 items that i want to spawn inside ) par1World.setBlock(x +5, y -6, z +5, Blocks.chest, 0, 2); TileEntityChest bigchest1 = (TileEntityChest)par1World.getTileEntity(par3 +5, par4 -6, par5 +5); if(bigchest1 != null) { for(int i = 0; i< par2Random.nextInt(bigchest1.getSizeInventory()); i++) { bigchest1.setInventorySlotContents(par2Random.nextInt(bigchest1.getSizeInventory()), pickRandomItemChest(par2Random)); } private ItemStack pickRandomItemChest(Random rand) { int i = rand.nextInt(3); if(i == 0) { return new ItemStack(Items.coal, rand.nextInt(30)); } if(i == 1) { return new ItemStack(Items.diamond, 1); } if(i == 2) { return new ItemStack(Items.emerald, 1); } return new ItemStack(Items.gold_ingot, 1); }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.