Jump to content

[1.7.2] Chest - Generation - Filling up the spawned chest with items[HELP NEEDE]


Recommended Posts

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.