Fabric API

Fabric API

108M Downloads

Don't break the ordering of ResourcePackProviders

warjort opened this issue ยท 0 comments

commented

What:
The mixin that adds datapacks for mods breaks the ordering of resource pack providers for both datapacks and resourcepacks.

In the vanilla code, it uses this constructor to make an ImmutableSet from the array:
https://guava.dev/releases/19.0/api/docs/src-html/com/google/common/collect/ImmutableSet.html#line.297
This is documented to maintain the order.

The mixin above copies that set into a HashSet effectively randomising the order.

While the main ordering comes from the first/last ordering specified by the resource pack provider,
this does not help when two different providers use the same value. It is the above set's ordering that determines.

Proposed fix:

Change the mixin to use a LinkedHashSet which will maintain the insertion ordering.

My current workaround is to add a Mixin that runs after the Fabric mixin and does just that.

Off Topic: There are a number of mods that rely on the Fabric API making the providers field mutable.
It might be an idea to make it an official api?
e.g.
https://github.com/architectury/architectury-api/blob/1.17/common/src/main/java/dev/architectury/hooks/PackRepositoryHooks.java