Fabric API

Fabric API

106M Downloads

Data generation is run before vanilla tags are populated

Shnupbups opened this issue ยท 2 comments

commented

Data generation is run before vanilla tags are populated, which causes any tag provider that attempts to create a tag that contains a vanilla tag to crash.

For example, say we want a tag example:custom_tag that contains #minecraft:small_flowers. This:

getOrCreateTagBuilder(TagFactory.ITEM.create(new Identifier("example", "custom_tag"))).addTag(ItemTags.SMALL_FLOWERS);

would crash with java.lang.IllegalArgumentException: Couldn't define tag example:custom_tag as it is missing following references: #minecraft:small_flowers (from vanilla).

This can be mitigated by adding to the vanilla tag yourself, but that's not ideal. For example, this:

getOrCreateTagBuilder(ItemTags.SMALL_FLOWERS).add(Items.POPPY);
getOrCreateTagBuilder(TagFactory.ITEM.create(new Identifier("example", "custom_tag"))).addTag(ItemTags.SMALL_FLOWERS);

will work without crashing - but it will leave your mod with an otherwise unnecessary minecraft:small_flowers item tag file.

commented

I understand that due to tags being a data resource, and thus bound to worlds, that it may not be easy to fix this issue - but some way of maybe populating them with the default values beforehand would be nice?

commented

In AbstractTagProvider#run and Tag$TagEntry#canAdd it looks like it checks whether there's a builder for the tag entry present. The fix should be easy enough, we just need to extend TagEntry and override canAdd to always return true.