mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-05 19:47:00 -04:00
Fix #2091: multiple mods adding to the same tag not working
This commit is contained in:
parent
b7627c4f54
commit
583ee89038
3 changed files with 28 additions and 3 deletions
fabric-resource-loader-v0/src/main
java/net/fabricmc/fabric
resources
|
@ -118,7 +118,7 @@ public abstract class GroupResourcePack implements ResourcePack {
|
|||
return this.namespacedPacks.keySet();
|
||||
}
|
||||
|
||||
public void appendResources(NamespaceResourceManagerAccessor manager, Identifier id, List<class_7083> resources) throws IOException {
|
||||
public void appendResources(NamespaceResourceManagerAccessor manager, Identifier id, List<class_7083> resources) {
|
||||
List<ModResourcePack> packs = this.namespacedPacks.get(id.getNamespace());
|
||||
|
||||
if (packs == null) {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.resource.loader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -35,6 +34,9 @@ import net.minecraft.util.Identifier;
|
|||
|
||||
import net.fabricmc.fabric.impl.resource.loader.GroupResourcePack;
|
||||
|
||||
/**
|
||||
* Patches getAllResources and method_41265 to work with GroupResourcePack.
|
||||
*/
|
||||
@Mixin(NamespaceResourceManager.class)
|
||||
public class NamespaceResourceManagerMixin {
|
||||
private final ThreadLocal<List<class_7083>> fabric$getAllResources$resources = new ThreadLocal<>();
|
||||
|
@ -58,7 +60,7 @@ public class NamespaceResourceManagerMixin {
|
|||
target = "Lnet/minecraft/resource/ResourcePack;contains(Lnet/minecraft/resource/ResourceType;Lnet/minecraft/util/Identifier;)Z"
|
||||
)
|
||||
)
|
||||
private boolean onResourceAdd(ResourcePack pack, ResourceType type, Identifier id) throws IOException {
|
||||
private boolean onResourceAdd(ResourcePack pack, ResourceType type, Identifier id) {
|
||||
if (pack instanceof GroupResourcePack) {
|
||||
((GroupResourcePack) pack).appendResources((NamespaceResourceManagerAccessor) this, id, this.fabric$getAllResources$resources.get());
|
||||
|
||||
|
@ -67,4 +69,25 @@ public class NamespaceResourceManagerMixin {
|
|||
|
||||
return pack.contains(type, id);
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "method_41258",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/List;add(Ljava/lang/Object;)Z"
|
||||
),
|
||||
allow = 1
|
||||
)
|
||||
private boolean onResourceAdd(List<NamespaceResourceManager.class_7083> entries, Object entryObject) {
|
||||
// Required due to type erasure of List.add
|
||||
NamespaceResourceManager.class_7083 entry = (NamespaceResourceManager.class_7083) entryObject;
|
||||
ResourcePack pack = entry.field_37286;
|
||||
|
||||
if (pack instanceof GroupResourcePack grp) {
|
||||
grp.appendResources((NamespaceResourceManagerAccessor) this, entry.field_37284, entries);
|
||||
return true;
|
||||
}
|
||||
|
||||
return entries.add(entry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
accessWidener v2 named
|
||||
|
||||
accessible method net/minecraft/resource/NamespaceResourceManager$class_7083 <init> (Lnet/minecraft/resource/NamespaceResourceManager;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/resource/ResourcePack;)V
|
||||
accessible field net/minecraft/resource/NamespaceResourceManager$class_7083 field_37284 Lnet/minecraft/util/Identifier;
|
||||
accessible field net/minecraft/resource/NamespaceResourceManager$class_7083 field_37286 Lnet/minecraft/resource/ResourcePack;
|
||||
|
|
Loading…
Add table
Reference in a new issue