Random Chest Loots [Structures]

5 posts / 0 new
Last post
Offline
Last seen: 1 year 1 month ago
Joined: 10/21/2015 - 17:58
Gems: 0
Random Chest Loots [Structures]

Hello Guys,

 

I was looking for a week how to make the Chest (in my Structures I created) with random Loots.

I tried:
-Realising it with Worldedit (doesnt work)

-Coding (dosent work*for me*)

........

I created a Structure wich is a smal House with a Chest inside...

now my Question How can I do  the Chest with random Items.

 

 



codyfilms's picture
Offline
Last seen: 1 month 18 hours ago
Joined: 03/11/2015 - 05:16
Gems: 56
recopy the house multiple

recopy the house multiple timesin mcedit or what ever you have, and add them each as a structure and you'll get "random" items. The works tidious but it pays off :)

good luck!

Offline
Last seen: 1 year 1 month ago
Joined: 10/21/2015 - 17:58
Gems: 0
Hey, thanks for youre answer

Hey, thanks for youre answer but it isnt copy the Items inside the chest is there any trick?

Offline
Last seen: 1 year 1 month ago
Joined: 10/21/2015 - 17:58
Gems: 0
Edit: Ist there any way to

Edit: Ist there any way to bind a Script for random chests ?

Nuparu00's picture
Offline
Last seen: 13 hours 52 min ago
Joined: 08/27/2013 - 18:03
Gems: 272
Find line like this:

Find line like this:

 world.setBlockState(new BlockPos(i, j, k), Blocks.chest.getDefaultState(), 3);

And change it to the this. Please dont forget to the change i , j , k coordinates to yours!

world.setBlockState(new BlockPos(i, j, k), Blocks.chest.getDefaultState());
TileEntityChest chest = (TileEntityChest) world.getTileEntity(new BlockPos(i, j, k));
 

And under this line add:

chest.setInventorySlotContents(0, new ItemStack(NAME OF THE ITEM, AMOUNT));

If you want random amout of item , your code be like this:

 

chest.setInventorySlotContents(0, new ItemStack(NAME OF THE ITEM, (int)(Math.random()*MAX STACK SIZE))));

Make sure that you have this import:

import java.util.Random;

 

That's all. I hope that it helps you.