Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Still WIP, I'd like more feedback on the feature and its design and the format before finishing the details.
Adds a data pack API to do simple loot table modifications such as adding new pools. The format is similar to the normal loot table JSON format.
Example loot modifier file
This loot modifier adds a pool to builtin green wool loot tables dropping a poisonous potato, and sets the count of all result stacks to 10.{ "target": { "type": "fabric:require_all", "children": [ { "type": "fabric:loot_table_id", "loot_tables": ["minecraft:blocks/green_wool"] }, { "type": "fabric:source", "sources": "any_builtin" } ] }, "pools": [ { "rolls": 1, "entries": [ { "type": "minecraft:item", "name": "minecraft:poisonous_potato" } ], "conditions": [ { "condition": "minecraft:survives_explosion" } ] } ], "functions": [ { "function": "minecraft:set_count", "count": 10 } ] }Cleans up the loot table event mixin (it was processing all loot-related registries...), and moves most of the code out of the mixin
Why?
Loot tables themselves are data pack files, so it makes sense to allow modifying them using more data pack files without having to resort to overriding loot tables or adding code. Modifiers can also be overridden in data packs.
Loot modifiers are intended to be an alternative - possibly the recommended alternative where possible - to
LootTableEvents.MODIFY. There won't be any features that can't be done through Java code in mods.NeoForge has a similar feature called global loot modifiers which is much more complex. As far as I can tell, Fabric API already supports their functionality in the
LootTableEvents.MODIFY_DROPSevent, and I don't think we need data pack support for complex use cases. The loot modifier format can be extended later with new features if desired.TODOs and open questions
Support load conditions for loot table modificationsAutomatically works due to the use ofSimpleJsonResourceReloadListener.scanDirectoryFabricLootTableBuilder.modifyPools)?