Skip to content

LootTables 5.46.0 ​

final class · pocketmine\loot\LootTables · source

Vanilla loot tables (Java Edition data from the vanilla data cache, see LootData).

$table = LootTables::get("minecraft:chests/simple_dungeon"); //null if the data or the table is missing $items = $table?->generate(LootContext::create()) ?? [];

The data cache is the one of the vanilla world generator (by default <working directory>/vanilla-worldgen, filled automatically when a vanilla world is created); worlds using another generator can use it too once it exists.

Methods ​

get() ​

php
public static function get(string $name) : ?\pocketmine\loot\LootTable

Returns a loot table by Java id ("minecraft:chests/simple_dungeon", "chests/simple_dungeon") or Bedrock path ("loot_tables/chests/simple_dungeon.json"), or null if it does not exist or the data is not available.

getData() ​

php
public static function getData() : ?\pocketmine\loot\LootData

The loot data, or null if the vanilla data cache has no loot tables (not fetched yet, or an older format).

getDataRoot() ​

php
public static function getDataRoot() : string

isAvailable() ​

php
public static function isAvailable() : bool

setDataRoot() ​

php
public static function setDataRoot(?string $root) : void

Sets the vanilla data cache to read the loot tables from (null: the default one). The vanilla world generator calls this with its data directory.

setDefaultDataRoot() ​

php
public static function setDefaultDataRoot(string $root) : void

Sets the data root only if none was set yet.

toBedrockPath() ​

php
public static function toBedrockPath(string $javaId) : string

Bedrock path of a loot table (what Bedrock stores in the LootTable tag of containers and brushable blocks).

toJavaId() ​

php
public static function toJavaId(string $name) : string

Java id of a loot table given by Java id or Bedrock path.

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