{
final double d3 = tile.xCoord + 0.5D - this.posX;
final double d4 = tile.yCoord + 0.5D - this.posY;
final double d5 = tile.zCoord + 0.5D - this.posZ;
final double dSq = d3 * d3 + d4 * d4 + d5 * d5;
TileEntityTreasureChest chest = (TileEntityTreasureChest) tile;
if (dSq < 10000)
{
if (!chest.locked)
{
chest.locked = true;
}
for (int k = 0; k < chest.getSizeInventory(); k++)
{
chest.setInventorySlotContents(k, null);
}
ChestGenHooks info = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST);
// Generate twice, since it's an extra special chest
WeightedRandomChestContent.generateChestContents(this.rand, info.getItems(this.rand), chest, info.getCount(this.rand));
WeightedRandomChestContent.generateChestContents(this.rand, info.getItems(this.rand), chest, info.getCount(this.rand));
ItemStack schematic = this.getGuaranteedLoot(this.rand);
int slot = this.rand.nextInt(chest.getSizeInventory());
chest.setInventorySlotContents(slot, schematic);
break;
}
}
}