Skip to content

LootTableContainerTrait 5.46.0 ​

trait · pocketmine\block\tile\LootTableContainerTrait · source

Lazy container loot (vanilla's RandomizableContainer): a container generated with a loot table and a seed is filled from the table the first time its contents are needed (opened by a player, emptied by a hopper, broken...), with the same items for the same seed. Until then only the table name and the seed are stored.

The seed is a Java long (stored as "LootTableSeedLong"); "LootTableSeed" keeps its low 32 bits, the type Bedrock uses, and is read when the long is missing (worlds from Bedrock).

Methods ​

getLootTable() ​

php
public function getLootTable() : ?string

Returns the loot table that will fill the container (Bedrock path or Java id), or null if it was filled already.

getLootTableSeed() ​

php
public function getLootTableSeed() : int

getPosition() protected ​

php
abstract protected function getPosition() : \pocketmine\world\Position

getRealInventory() ​

php
abstract public function getRealInventory() : \pocketmine\inventory\Inventory

loadLootTable() protected ​

php
protected function loadLootTable(\pocketmine\nbt\tag\CompoundTag $nbt) : void

saveLootTable() protected ​

php
protected function saveLootTable(\pocketmine\nbt\tag\CompoundTag $nbt) : void

setLootTable() ​

php
public function setLootTable(?string $lootTable, int $seed = 0) : void

Sets the loot table that fills the container when it is first used (Bedrock path such as "loot_tables/chests/simple_dungeon.json" or Java id such as "minecraft:chests/simple_dungeon"). A seed of 0 rolls different items each time; any other seed always gives the same items.

unpackLootTable() ​

php
public function unpackLootTable(?\pocketmine\entity\Entity $entity = null) : void

Fills the container from its loot table, if it has one (RandomizableContainer.unpackLootTable()). $entity is the entity using the container (usually the player opening it), if any.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.