LootTable 5.46.0
A vanilla loot table (Java Edition data), rolled exactly like vanilla: the same random calls in the same order, so a table rolled with the same seed gives the same items as Java Edition (in Java item terms; see LootItemConverter for what PocketMine can represent).
Typical use: $table = LootTables::get("minecraft:chests/simple_dungeon"); $items = $table->generate(LootContext::create()); //PocketMine items $table->fillInventory($inventory, LootContext::seeded($seed)); //a container, like an unpacked vanilla chest
Properties
$id
public readonly string $id$randomSequence
public readonly ?string $randomSequence$type
public readonly string $typeMethods
__construct()
public function __construct(string $id, string $type, array $pools, ?\Closure $function, \pocketmine\loot\LootData $data, ?string $randomSequence)fill()
public function fill(int $size, array $occupiedSlots, \pocketmine\loot\LootContext $context) : arrayLootTable.fill(): rolls the table and spreads the items over the empty slots of a container of $size slots like vanilla (shuffled empty slots, stacks split at random to fill more slots).
fillInventory()
public function fillInventory(\pocketmine\inventory\Inventory $inventory, \pocketmine\loot\LootContext $context) : voidFills an inventory like a vanilla container with this loot table (fill()). Items PocketMine cannot represent leave their slot empty.
generate()
public function generate(\pocketmine\loot\LootContext $context) : arrayRolls the table and converts the stacks to PocketMine items (stacks PocketMine cannot represent are dropped).
getRandomItems()
public function getRandomItems(\pocketmine\loot\LootContext $context) : arrayLootTable.getRandomItems(): the rolled stacks, oversized stacks split to the item's max stack size. May contain empty stacks.
getRandomItemsRaw()
public function getRandomItemsRaw(\pocketmine\loot\LootContext $context, \Closure $output) : voidLootTable.getRandomItemsRaw(): the rolled stacks, before splitting oversized stacks.
shuffle()
public static function shuffle(array &$list, \pocketmine\loot\LootContext $context) : voidUtil.shuffle()
