Fillin' Those Chests With Goodies

It's like Christmas Time and I'm f@%$ing Santa Clause.  I'm bringing you a code snippet to generate chests with items in them. That's right: it's time to open your presents.

//  Create a chest at (i,j,k).
// Get the crate entity
TileEntityChest tileentitychest = (TileEntityChest)world.getBlockTileEntity(i,j,k);
// Generate an item stack of ingot iron and stack up to 4            
ItemStack itemstack = new ItemStack(Item.ingotIron, random.nextInt(4) + 1); 
//  Add that stack to the chest
tileentitychest.setInventorySlotContents(random.nextInt(tileentitychest.getSizeInventory()), itemstack);

What are the results?

No comments:

Post a Comment