mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-23 08:08:02 -05:00
9e7660c677
- Deprecates all classes and methods that use outdated Yarn names. - Adds FabricLootTable and FabricLootTableBuilder to replace the LootSupplier naming variants. - Deprecates LootEntryTypeRegistry and LootJsonParser as their functionality is exposed in vanilla now. - Adds methods to FabricLootPoolBuilder for working with collections as builder parameters. - FabricLootPool and FabricLootTable/Supplier now return immutable lists instead of modifiable fixed-size ones. Co-authored-by: i509VCB <i509vcb@gmail.com>
29 lines
1.3 KiB
Markdown
29 lines
1.3 KiB
Markdown
# Fabric Loot API (v2)
|
|
|
|
This module includes APIs for modifying and creating loot tables.
|
|
|
|
## [Loot table events](src/main/java/net/fabricmc/fabric/api/loot/v2/LootTableEvents.java)
|
|
|
|
This class provides two events for modifying loot tables.
|
|
|
|
`LootTableEvents.REPLACE` runs first and lets you replace loot tables completely.
|
|
|
|
`LootTableEvents.MODIFY` runs after and lets you modify loot tables, including the ones created in `REPLACE`,
|
|
by adding new loot pools or loot functions to them.
|
|
|
|
### Loot table sources
|
|
|
|
Both events have access to a [loot table source](src/main/java/net/fabricmc/fabric/api/loot/v2/LootTableSource.java)
|
|
that you can use to check where a loot table is loaded from.
|
|
|
|
For example, you can use this to check if a loot table is from a user data pack and
|
|
not modify the user-provided data in your event.
|
|
|
|
## Enhanced loot table and loot pool builders
|
|
|
|
`LootTable.Builder` and `LootPool.Builder` implement
|
|
injected interfaces ([`FabricLootTableBuilder`](src/main/java/net/fabricmc/fabric/api/loot/v2/FabricLootTableBuilder.java)
|
|
and [`FabricLootPoolBuilder`](src/main/java/net/fabricmc/fabric/api/loot/v2/FabricLootPoolBuilder.java))
|
|
which have additional methods for dealing with already-built objects and collections of objects.
|
|
|
|
Those interfaces also have `copyOf` methods for creating copies of existing loot tables/pools as builders.
|