Random Chest Loots [Structures]

Started by mona on Wed, 10/21/2015 - 16:54
Last seen on 22:40, 19. Nov 2015
Joined Oct 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Random Chest Loots [Structures]
Wed, 10/21/2015 - 16:54

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.

 

 

Last seen on 18:28, 11. Aug 2018
Joined Mar 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
recopy the house multiple
Wed, 10/28/2015 - 03:04

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!

Last seen on 22:40, 19. Nov 2015
Joined Oct 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Hey, thanks for youre answer
Thu, 11/19/2015 - 22:40

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

Last seen on 22:40, 19. Nov 2015
Joined Oct 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Edit: Ist there any way to
Thu, 11/19/2015 - 22:42

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

Last seen on 00:45, 14. Aug 2018
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
Find line like this:
Thu, 11/19/2015 - 23:24

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.