Как сделать генерацию рандомного лута в сундуках

Версия Minecraft
1.7.10
98
1
Здравствуйте. Мне нужно сделать генерацию рандомного лута в своей структуре.
Добавил структуру с сундуком, как сделать что бы в сундуке генерился лут?
 
Код:
private final ArrayList<ChunkCoordinates> chests = new ArrayList<ChunkCoordinates>();

this.chests.add(new ChunkCoordinates(i + 2, j - 2, k + 3));			
			
			if (!this.chests.isEmpty())
	        {
	            if(par1World.getBlock(this.chests.get(0).posX, this.chests.get(0).posY, this.chests.get(0).posZ) != Blocks.chest) par1World.setBlock(this.chests.get(0).posX, this.chests.get(0).posY, this.chests.get(0).posZ, Blocks.chest, 0, 2);
	            TileEntityChest chest = (TileEntityChest) par1World.getTileEntity(this.chests.get(0).posX, this.chests.get(0).posY, this.chests.get(0).posZ);

	            if (chest != null)
	            {
	                for (int o = 0; o < chest.getSizeInventory(); o++)
	                {
	                    chest.setInventorySlotContents(o, null);
	                }

	                ChestGenHooks info = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST);

	                WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), chest, info.getCount(rand));
	            }

	            this.chests.clear();
	        }
 
BlesseNtumble написал(а):
Код:
private final ArrayList<ChunkCoordinates> chests = new ArrayList<ChunkCoordinates>();

this.chests.add(new ChunkCoordinates(i + 2, j - 2, k + 3)); 
 
 if (!this.chests.isEmpty())
        {
            if(par1World.getBlock(this.chests.get(0).posX, this.chests.get(0).posY, this.chests.get(0).posZ) != Blocks.chest) par1World.setBlock(this.chests.get(0).posX, this.chests.get(0).posY, this.chests.get(0).posZ, Blocks.chest, 0, 2);
            TileEntityChest chest = (TileEntityChest) par1World.getTileEntity(this.chests.get(0).posX, this.chests.get(0).posY, this.chests.get(0).posZ);

            if (chest != null)
            {
                for (int o = 0; o < chest.getSizeInventory(); o++)
                {
                    chest.setInventorySlotContents(o, null);
                }

                ChestGenHooks info = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST);

                WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), chest, info.getCount(rand));
            }

            this.chests.clear();
        }
Эмм...Вообще есть метод уже созданный...
 
Назад
Сверху