diff --git a/src/main/java/org/embeddedt/modernfix/mixin/perf/modern_resourcepacks/PathResourcePackMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/perf/modern_resourcepacks/PathResourcePackMixin.java index 7d381d4b..d44f572e 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/perf/modern_resourcepacks/PathResourcePackMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/perf/modern_resourcepacks/PathResourcePackMixin.java @@ -10,6 +10,7 @@ import org.apache.commons.lang3.tuple.Triple; import org.embeddedt.modernfix.ModernFix; import org.embeddedt.modernfix.util.CachedResourcePath; import org.embeddedt.modernfix.util.FileUtil; +import org.embeddedt.modernfix.util.PackTypeHelper; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @@ -83,7 +84,8 @@ public abstract class PathResourcePackMixin { rootListingForNamespaces.put(namespace, Collections.emptyList()); } } - rootListingByNamespaceAndType.put(type, rootListingForNamespaces); + if(PackTypeHelper.isVanillaPackType(type)) + rootListingByNamespaceAndType.put(type, rootListingForNamespaces); } this.rootListingByNamespaceAndType = rootListingByNamespaceAndType; this.containedPaths = containedPaths; @@ -107,6 +109,8 @@ public abstract class PathResourcePackMixin { @Inject(method = "getNamespaces", at = @At("HEAD"), cancellable = true) private void useCacheForNamespaces(PackType type, CallbackInfoReturnable> cir) { + if(!PackTypeHelper.isVanillaPackType(type)) + return; Set cachedNamespaces; synchronized (this.namespacesByType) { cachedNamespaces = this.namespacesByType.get(type); @@ -118,6 +122,8 @@ public abstract class PathResourcePackMixin { @Inject(method = "getNamespaces", at = @At("TAIL")) private void storeCacheForNamespaces(PackType type, CallbackInfoReturnable> cir) { + if(!PackTypeHelper.isVanillaPackType(type)) + return; synchronized (this.namespacesByType) { this.namespacesByType.put(type, cir.getReturnValue()); } @@ -136,6 +142,8 @@ public abstract class PathResourcePackMixin { @Inject(method = "getResources", at = @At("HEAD"), cancellable = true) public void getResources(PackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate filter, CallbackInfoReturnable> cir) { + if(!PackTypeHelper.isVanillaPackType(type)) + return; this.generateResourceCache(); if(!pathIn.endsWith("/")) pathIn = pathIn + "/"; diff --git a/src/main/java/org/embeddedt/modernfix/mixin/perf/modern_resourcepacks/VanillaPackResourcesMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/perf/modern_resourcepacks/VanillaPackResourcesMixin.java index 9cd8f89f..29ed4023 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/perf/modern_resourcepacks/VanillaPackResourcesMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/perf/modern_resourcepacks/VanillaPackResourcesMixin.java @@ -10,6 +10,7 @@ import net.minecraft.server.packs.metadata.pack.PackMetadataSection; import org.apache.commons.lang3.tuple.Pair; import org.embeddedt.modernfix.FileWalker; import org.embeddedt.modernfix.util.FileUtil; +import org.embeddedt.modernfix.util.PackTypeHelper; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @@ -43,6 +44,8 @@ public class VanillaPackResourcesMixin { containedPaths = new HashSet<>(); Joiner slashJoiner = Joiner.on('/'); for(PackType type : PackType.values()) { + if(!PackTypeHelper.isVanillaPackType(type)) + continue; Path root = ROOT_DIR_BY_TYPE.get(type); if(root == null) throw new IllegalStateException("No filesystem for vanilla " + type.name() + " assets"); @@ -72,6 +75,8 @@ public class VanillaPackResourcesMixin { @Inject(method = "hasResource", at = @At(value = "INVOKE", target = "Ljava/lang/Class;getResource(Ljava/lang/String;)Ljava/net/URL;"), cancellable = true) private void useCacheForExistence(PackType type, ResourceLocation location, CallbackInfoReturnable cir) { + if(!PackTypeHelper.isVanillaPackType(type)) + return; cir.setReturnValue(containedPaths.contains(type.getDirectory() + "/" + location.getNamespace() + "/" + FileUtil.normalize(location.getPath()))); } diff --git a/src/main/java/org/embeddedt/modernfix/util/PackTypeHelper.java b/src/main/java/org/embeddedt/modernfix/util/PackTypeHelper.java new file mode 100644 index 00000000..13a76311 --- /dev/null +++ b/src/main/java/org/embeddedt/modernfix/util/PackTypeHelper.java @@ -0,0 +1,9 @@ +package org.embeddedt.modernfix.util; + +import net.minecraft.server.packs.PackType; + +public class PackTypeHelper { + public static boolean isVanillaPackType(PackType type) { + return type == PackType.CLIENT_RESOURCES || type == PackType.SERVER_DATA; + } +}