LootTables 5.46.0
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()
public static function get(string $name) : ?\pocketmine\loot\LootTableReturns 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()
public static function getData() : ?\pocketmine\loot\LootDataThe loot data, or null if the vanilla data cache has no loot tables (not fetched yet, or an older format).
getDataRoot()
public static function getDataRoot() : stringisAvailable()
public static function isAvailable() : boolsetDataRoot()
public static function setDataRoot(?string $root) : voidSets 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()
public static function setDefaultDataRoot(string $root) : voidSets the data root only if none was set yet.
toBedrockPath()
public static function toBedrockPath(string $javaId) : stringBedrock path of a loot table (what Bedrock stores in the LootTable tag of containers and brushable blocks).
toJavaId()
public static function toJavaId(string $name) : stringJava id of a loot table given by Java id or Bedrock path.
