Skip to content

LootTable 5.46.0 ​

final class · pocketmine\loot\LootTable · source

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 ​

php
public readonly string $id

$randomSequence ​

php
public readonly ?string $randomSequence

$type ​

php
public readonly string $type

Methods ​

__construct() ​

php
public function __construct(string $id, string $type, array $pools, ?\Closure $function, \pocketmine\loot\LootData $data, ?string $randomSequence)

fill() ​

php
public function fill(int $size, array $occupiedSlots, \pocketmine\loot\LootContext $context) : array

LootTable.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() ​

php
public function fillInventory(\pocketmine\inventory\Inventory $inventory, \pocketmine\loot\LootContext $context) : void

Fills an inventory like a vanilla container with this loot table (fill()). Items PocketMine cannot represent leave their slot empty.

generate() ​

php
public function generate(\pocketmine\loot\LootContext $context) : array

Rolls the table and converts the stacks to PocketMine items (stacks PocketMine cannot represent are dropped).

getRandomItems() ​

php
public function getRandomItems(\pocketmine\loot\LootContext $context) : array

LootTable.getRandomItems(): the rolled stacks, oversized stacks split to the item's max stack size. May contain empty stacks.

getRandomItemsRaw() ​

php
public function getRandomItemsRaw(\pocketmine\loot\LootContext $context, \Closure $output) : void

LootTable.getRandomItemsRaw(): the rolled stacks, before splitting oversized stacks.

shuffle() ​

php
public static function shuffle(array &$list, \pocketmine\loot\LootContext $context) : void

Util.shuffle()

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