diff --git a/build.gradle.shared b/build.gradle.shared index a1fd54b..14fd93c 100644 --- a/build.gradle.shared +++ b/build.gradle.shared @@ -200,8 +200,9 @@ if (loader != null && !loader.isEmpty()) { } def isPre26_2 = mcVersion.startsWith("1.") || mcVersion.startsWith("26.1") + def isPre1_21 = mcVersion.startsWith("1.20") replaceProperties["blockmodel_mixin_entry"] = isPre26_2 ? '\n "model.BlockModelMixin",' : '' - replaceProperties["filepackresources_mixin_entry"] = isPre26_2 ? '\n "resources.FilePackResourcesMixin",' : '' + replaceProperties["filepackresources_mixin_entry"] = isPre1_21 ? '\n "resources.FilePackResourcesMixin",' : '' inputs.properties(replaceProperties) def metaFiles = [ diff --git a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java index 3cca128..cbde33e 100644 --- a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java +++ b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java @@ -4,7 +4,7 @@ import com.ccr4ft3r.lightspeed.cache.GlobalCache; import com.ccr4ft3r.lightspeed.interfaces.IPackResources; import com.google.common.collect.Maps; import net.minecraft.server.packs.AbstractPackResources; -//? if >=26.2 { +//? if >=1.21 { import net.minecraft.server.packs.PackLocationInfo; //?} import org.spongepowered.asm.mixin.Mixin; @@ -21,7 +21,7 @@ public abstract class AbstractPackResourcesMixin implements IPackResources { @Unique private Map lightspeed$existenceByResource = Maps.newConcurrentMap(); - //? if >=26.2 { +//? if >=1.21 { @Inject(method = "", at = @At("RETURN")) public void initReturnInjected(PackLocationInfo location, CallbackInfo ci) { if (GlobalCache.isEnabled) diff --git a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java index 73f3351..30f69bb 100644 --- a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java +++ b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java @@ -39,14 +39,22 @@ import java.util.List; //?} public abstract class DelegatingResourcePackMixin { @Shadow + //? if >=1.21 { protected abstract List getCandidatePacks(PackType type, Identifier location); + //?} else { + /*protected abstract List getCandidatePacks(PackType type, ResourceLocation location); + *///?} //? if >=1.21 { @Inject(method = "getResource(Lnet/minecraft/server/packs/PackType;Lnet/minecraft/resources/Identifier;)Lnet/minecraft/server/packs/resources/IoSupplier;", at = @At(value = "HEAD"), cancellable = true) //?} else { /*@Inject(method = "getResource(Lnet/minecraft/server/packs/PackType;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/server/packs/resources/IoSupplier;", at = @At(value = "HEAD"), cancellable = true) *///?} + //? if >=1.21 { public void getResourceHeadInjected(PackType type, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup) return; IoSupplier result = GlobalCache.findFirstResource(getCandidatePacks(type, location), type, location); diff --git a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java index db7a2dd..0e3bb42 100644 --- a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java +++ b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java @@ -48,6 +48,7 @@ public abstract class FallbackResourceManagerMixin { @Shadow @Final public List fallbacks; @Shadow @Final private PackType type; + //? if >=1.21 { @Invoker("createStackMetadataFinder") protected abstract IoSupplier lightspeed$createStackMetadataFinder(Identifier location, int index); @@ -55,11 +56,24 @@ public abstract class FallbackResourceManagerMixin { private static Resource lightspeed$createResource(PackResources pack, Identifier location, IoSupplier resource, IoSupplier metadata) { + //?} else { + /*@Invoker("createStackMetadataFinder") + protected abstract IoSupplier lightspeed$createStackMetadataFinder(ResourceLocation location, int index); + + @Invoker("createResource") + private static Resource lightspeed$createResource(PackResources pack, ResourceLocation location, + IoSupplier resource, + IoSupplier metadata) { + *///?} throw new AssertionError(); } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { private void getResourceHeadInjected(Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*private void getResourceHeadInjected(ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup || this.fallbacks.size() <= 1) { return; } @@ -102,7 +116,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional lightspeed$searchSafeSegment(List segment, Identifier location) { + //?} else { + /*private Optional lightspeed$searchSafeSegment(List segment, ResourceLocation location) { + *///?} if (segment.isEmpty()) { return null; } @@ -150,7 +168,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional> lightspeed$searchIndexedSegment(List segment, Identifier location) { + //?} else { + /*private Optional> lightspeed$searchIndexedSegment(List segment, ResourceLocation location) { + *///?} for (IndexedPack indexedPack : segment) { if (!(indexedPack.pack() instanceof IPathResourcePack indexedPackResources)) { return Optional.empty(); @@ -173,7 +195,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional lightspeed$searchSafeSegmentSequential(List segment, Identifier location) { + //?} else { + /*private Optional lightspeed$searchSafeSegmentSequential(List segment, ResourceLocation location) { + *///?} for (IndexedPack indexedPack : segment) { IoSupplier supplier = indexedPack.pack().getResource(this.type, location); if (supplier != null) { diff --git a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java index c496eef..3b67e13 100644 --- a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java +++ b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java @@ -1,15 +1,11 @@ -//? if <26.2 { +//? if <1.21 { package com.ccr4ft3r.lightspeed.mixin.resources; import com.ccr4ft3r.lightspeed.cache.GlobalCache; import com.ccr4ft3r.lightspeed.compat.FusionPackCompat; import com.ccr4ft3r.lightspeed.interfaces.IPackResources; import com.google.common.collect.Maps; -//? if >=1.21 { -import net.minecraft.resources.Identifier; -//?} else { -/*import net.minecraft.resources.ResourceLocation; -*///?} +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.FilePackResources; import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; @@ -75,7 +71,7 @@ public abstract class FilePackResourcesMixin implements IPackResources { .filter(entry -> entry.startsWith(s1)) .forEach(entry -> { String s3 = entry.substring(s.length()); - Identifier resourcelocation = Identifier.tryBuild(namespace, s3); + ResourceLocation resourcelocation = ResourceLocation.tryBuild(namespace, s3); if (resourcelocation != null) { resourceOutput.accept(resourcelocation, lightspeed$openResource(packType, resourcelocation)); } @@ -107,7 +103,7 @@ public abstract class FilePackResourcesMixin implements IPackResources { } @Unique - private IoSupplier lightspeed$openResource(PackType packType, Identifier location) { + private IoSupplier lightspeed$openResource(PackType packType, ResourceLocation location) { return () -> { ZipFile zip = lightspeed$getOpenZipFile(); if (zip == null) { diff --git a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java index a05b6d7..acda7ad 100644 --- a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java +++ b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java @@ -181,7 +181,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { public void getResourceHeadInjected(PackType type, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheWalkedPaths || FusionPackCompat.hasOverrides(this)) { return; } @@ -223,7 +227,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } String resourcePath = cachedPath.replace(candidate.getFileSystem().getSeparator(), "/"); + //? if >=1.21 { Identifier location = Identifier.tryBuild(namespace, resourcePath); + //?} else { + /*ResourceLocation location = ResourceLocation.tryBuild(namespace, resourcePath); + *///?} if (location == null) { //? if <1.21 { /* Util.logAndPauseIfInIde(String.format(Locale.ROOT, "Invalid path in pack: %s:%s, ignoring", namespace, resourcePath)); @@ -309,7 +317,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Override + //? if >=1.21 { public Boolean lightspeed$hasIndexedResource(PackType type, Identifier location) { + //?} else { + /*public Boolean lightspeed$hasIndexedResource(PackType type, ResourceLocation location) { + *///?} PackType effectiveType = lightspeed$effectiveType(type, location); List cachedPaths = lightspeed$getCachedFilePaths(effectiveType, location.getNamespace()); if (cachedPaths == null) { @@ -503,7 +515,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Unique + //? if >=1.21 { private IoSupplier lightspeed$openResource(PackType type, Identifier location) { + //?} else { + /*private IoSupplier lightspeed$openResource(PackType type, ResourceLocation location) { + *///?} PackType effectiveType = lightspeed$effectiveType(type, location); return () -> Files.newInputStream(resolve(lightspeed$getPathParts(effectiveType, location))); } @@ -514,12 +530,20 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Unique + //? if >=1.21 { private static PackType lightspeed$effectiveType(PackType type, Identifier location) { + //?} else { + /*private static PackType lightspeed$effectiveType(PackType type, ResourceLocation location) { + *///?} return location.getPath().startsWith("lang/") ? PackType.CLIENT_RESOURCES : type; } @Unique + //? if >=1.21 { private static String[] lightspeed$getPathParts(PackType type, Identifier location) { + //?} else { + /*private static String[] lightspeed$getPathParts(PackType type, ResourceLocation location) { + *///?} String[] resourceParts = location.getPath().split("/"); String[] paths = new String[resourceParts.length + 2]; paths[0] = type.getDirectory(); diff --git a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java index a47f3a9..9c29966 100644 --- a/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java +++ b/fabric/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java @@ -58,7 +58,11 @@ public abstract class VanillaPackResourcesMixin implements IPackResources { } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { public void getResourceHeadInjected(PackType packType, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence) return; @@ -70,7 +74,11 @@ public abstract class VanillaPackResourcesMixin implements IPackResources { } @Inject(method = "getResource", at = @At("RETURN")) + //? if >=1.21 { public void getResourceReturnInjected(PackType packType, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceReturnInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence) return; diff --git a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java index 3cca128..cbde33e 100644 --- a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java +++ b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java @@ -4,7 +4,7 @@ import com.ccr4ft3r.lightspeed.cache.GlobalCache; import com.ccr4ft3r.lightspeed.interfaces.IPackResources; import com.google.common.collect.Maps; import net.minecraft.server.packs.AbstractPackResources; -//? if >=26.2 { +//? if >=1.21 { import net.minecraft.server.packs.PackLocationInfo; //?} import org.spongepowered.asm.mixin.Mixin; @@ -21,7 +21,7 @@ public abstract class AbstractPackResourcesMixin implements IPackResources { @Unique private Map lightspeed$existenceByResource = Maps.newConcurrentMap(); - //? if >=26.2 { +//? if >=1.21 { @Inject(method = "", at = @At("RETURN")) public void initReturnInjected(PackLocationInfo location, CallbackInfo ci) { if (GlobalCache.isEnabled) diff --git a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java index 73f3351..30f69bb 100644 --- a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java +++ b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java @@ -39,14 +39,22 @@ import java.util.List; //?} public abstract class DelegatingResourcePackMixin { @Shadow + //? if >=1.21 { protected abstract List getCandidatePacks(PackType type, Identifier location); + //?} else { + /*protected abstract List getCandidatePacks(PackType type, ResourceLocation location); + *///?} //? if >=1.21 { @Inject(method = "getResource(Lnet/minecraft/server/packs/PackType;Lnet/minecraft/resources/Identifier;)Lnet/minecraft/server/packs/resources/IoSupplier;", at = @At(value = "HEAD"), cancellable = true) //?} else { /*@Inject(method = "getResource(Lnet/minecraft/server/packs/PackType;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/server/packs/resources/IoSupplier;", at = @At(value = "HEAD"), cancellable = true) *///?} + //? if >=1.21 { public void getResourceHeadInjected(PackType type, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup) return; IoSupplier result = GlobalCache.findFirstResource(getCandidatePacks(type, location), type, location); diff --git a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java index db7a2dd..0e3bb42 100644 --- a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java +++ b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java @@ -48,6 +48,7 @@ public abstract class FallbackResourceManagerMixin { @Shadow @Final public List fallbacks; @Shadow @Final private PackType type; + //? if >=1.21 { @Invoker("createStackMetadataFinder") protected abstract IoSupplier lightspeed$createStackMetadataFinder(Identifier location, int index); @@ -55,11 +56,24 @@ public abstract class FallbackResourceManagerMixin { private static Resource lightspeed$createResource(PackResources pack, Identifier location, IoSupplier resource, IoSupplier metadata) { + //?} else { + /*@Invoker("createStackMetadataFinder") + protected abstract IoSupplier lightspeed$createStackMetadataFinder(ResourceLocation location, int index); + + @Invoker("createResource") + private static Resource lightspeed$createResource(PackResources pack, ResourceLocation location, + IoSupplier resource, + IoSupplier metadata) { + *///?} throw new AssertionError(); } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { private void getResourceHeadInjected(Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*private void getResourceHeadInjected(ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup || this.fallbacks.size() <= 1) { return; } @@ -102,7 +116,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional lightspeed$searchSafeSegment(List segment, Identifier location) { + //?} else { + /*private Optional lightspeed$searchSafeSegment(List segment, ResourceLocation location) { + *///?} if (segment.isEmpty()) { return null; } @@ -150,7 +168,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional> lightspeed$searchIndexedSegment(List segment, Identifier location) { + //?} else { + /*private Optional> lightspeed$searchIndexedSegment(List segment, ResourceLocation location) { + *///?} for (IndexedPack indexedPack : segment) { if (!(indexedPack.pack() instanceof IPathResourcePack indexedPackResources)) { return Optional.empty(); @@ -173,7 +195,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional lightspeed$searchSafeSegmentSequential(List segment, Identifier location) { + //?} else { + /*private Optional lightspeed$searchSafeSegmentSequential(List segment, ResourceLocation location) { + *///?} for (IndexedPack indexedPack : segment) { IoSupplier supplier = indexedPack.pack().getResource(this.type, location); if (supplier != null) { diff --git a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java index c496eef..3b67e13 100644 --- a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java +++ b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java @@ -1,15 +1,11 @@ -//? if <26.2 { +//? if <1.21 { package com.ccr4ft3r.lightspeed.mixin.resources; import com.ccr4ft3r.lightspeed.cache.GlobalCache; import com.ccr4ft3r.lightspeed.compat.FusionPackCompat; import com.ccr4ft3r.lightspeed.interfaces.IPackResources; import com.google.common.collect.Maps; -//? if >=1.21 { -import net.minecraft.resources.Identifier; -//?} else { -/*import net.minecraft.resources.ResourceLocation; -*///?} +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.FilePackResources; import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; @@ -75,7 +71,7 @@ public abstract class FilePackResourcesMixin implements IPackResources { .filter(entry -> entry.startsWith(s1)) .forEach(entry -> { String s3 = entry.substring(s.length()); - Identifier resourcelocation = Identifier.tryBuild(namespace, s3); + ResourceLocation resourcelocation = ResourceLocation.tryBuild(namespace, s3); if (resourcelocation != null) { resourceOutput.accept(resourcelocation, lightspeed$openResource(packType, resourcelocation)); } @@ -107,7 +103,7 @@ public abstract class FilePackResourcesMixin implements IPackResources { } @Unique - private IoSupplier lightspeed$openResource(PackType packType, Identifier location) { + private IoSupplier lightspeed$openResource(PackType packType, ResourceLocation location) { return () -> { ZipFile zip = lightspeed$getOpenZipFile(); if (zip == null) { diff --git a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java index a05b6d7..acda7ad 100644 --- a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java +++ b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java @@ -181,7 +181,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { public void getResourceHeadInjected(PackType type, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheWalkedPaths || FusionPackCompat.hasOverrides(this)) { return; } @@ -223,7 +227,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } String resourcePath = cachedPath.replace(candidate.getFileSystem().getSeparator(), "/"); + //? if >=1.21 { Identifier location = Identifier.tryBuild(namespace, resourcePath); + //?} else { + /*ResourceLocation location = ResourceLocation.tryBuild(namespace, resourcePath); + *///?} if (location == null) { //? if <1.21 { /* Util.logAndPauseIfInIde(String.format(Locale.ROOT, "Invalid path in pack: %s:%s, ignoring", namespace, resourcePath)); @@ -309,7 +317,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Override + //? if >=1.21 { public Boolean lightspeed$hasIndexedResource(PackType type, Identifier location) { + //?} else { + /*public Boolean lightspeed$hasIndexedResource(PackType type, ResourceLocation location) { + *///?} PackType effectiveType = lightspeed$effectiveType(type, location); List cachedPaths = lightspeed$getCachedFilePaths(effectiveType, location.getNamespace()); if (cachedPaths == null) { @@ -503,7 +515,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Unique + //? if >=1.21 { private IoSupplier lightspeed$openResource(PackType type, Identifier location) { + //?} else { + /*private IoSupplier lightspeed$openResource(PackType type, ResourceLocation location) { + *///?} PackType effectiveType = lightspeed$effectiveType(type, location); return () -> Files.newInputStream(resolve(lightspeed$getPathParts(effectiveType, location))); } @@ -514,12 +530,20 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Unique + //? if >=1.21 { private static PackType lightspeed$effectiveType(PackType type, Identifier location) { + //?} else { + /*private static PackType lightspeed$effectiveType(PackType type, ResourceLocation location) { + *///?} return location.getPath().startsWith("lang/") ? PackType.CLIENT_RESOURCES : type; } @Unique + //? if >=1.21 { private static String[] lightspeed$getPathParts(PackType type, Identifier location) { + //?} else { + /*private static String[] lightspeed$getPathParts(PackType type, ResourceLocation location) { + *///?} String[] resourceParts = location.getPath().split("/"); String[] paths = new String[resourceParts.length + 2]; paths[0] = type.getDirectory(); diff --git a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java index a47f3a9..9c29966 100644 --- a/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java +++ b/forge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java @@ -58,7 +58,11 @@ public abstract class VanillaPackResourcesMixin implements IPackResources { } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { public void getResourceHeadInjected(PackType packType, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence) return; @@ -70,7 +74,11 @@ public abstract class VanillaPackResourcesMixin implements IPackResources { } @Inject(method = "getResource", at = @At("RETURN")) + //? if >=1.21 { public void getResourceReturnInjected(PackType packType, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceReturnInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence) return; diff --git a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java index 3cca128..cbde33e 100644 --- a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java +++ b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java @@ -4,7 +4,7 @@ import com.ccr4ft3r.lightspeed.cache.GlobalCache; import com.ccr4ft3r.lightspeed.interfaces.IPackResources; import com.google.common.collect.Maps; import net.minecraft.server.packs.AbstractPackResources; -//? if >=26.2 { +//? if >=1.21 { import net.minecraft.server.packs.PackLocationInfo; //?} import org.spongepowered.asm.mixin.Mixin; @@ -21,7 +21,7 @@ public abstract class AbstractPackResourcesMixin implements IPackResources { @Unique private Map lightspeed$existenceByResource = Maps.newConcurrentMap(); - //? if >=26.2 { +//? if >=1.21 { @Inject(method = "", at = @At("RETURN")) public void initReturnInjected(PackLocationInfo location, CallbackInfo ci) { if (GlobalCache.isEnabled) diff --git a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java index 73f3351..30f69bb 100644 --- a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java +++ b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java @@ -39,14 +39,22 @@ import java.util.List; //?} public abstract class DelegatingResourcePackMixin { @Shadow + //? if >=1.21 { protected abstract List getCandidatePacks(PackType type, Identifier location); + //?} else { + /*protected abstract List getCandidatePacks(PackType type, ResourceLocation location); + *///?} //? if >=1.21 { @Inject(method = "getResource(Lnet/minecraft/server/packs/PackType;Lnet/minecraft/resources/Identifier;)Lnet/minecraft/server/packs/resources/IoSupplier;", at = @At(value = "HEAD"), cancellable = true) //?} else { /*@Inject(method = "getResource(Lnet/minecraft/server/packs/PackType;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/server/packs/resources/IoSupplier;", at = @At(value = "HEAD"), cancellable = true) *///?} + //? if >=1.21 { public void getResourceHeadInjected(PackType type, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup) return; IoSupplier result = GlobalCache.findFirstResource(getCandidatePacks(type, location), type, location); diff --git a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java index db7a2dd..0e3bb42 100644 --- a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java +++ b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java @@ -48,6 +48,7 @@ public abstract class FallbackResourceManagerMixin { @Shadow @Final public List fallbacks; @Shadow @Final private PackType type; + //? if >=1.21 { @Invoker("createStackMetadataFinder") protected abstract IoSupplier lightspeed$createStackMetadataFinder(Identifier location, int index); @@ -55,11 +56,24 @@ public abstract class FallbackResourceManagerMixin { private static Resource lightspeed$createResource(PackResources pack, Identifier location, IoSupplier resource, IoSupplier metadata) { + //?} else { + /*@Invoker("createStackMetadataFinder") + protected abstract IoSupplier lightspeed$createStackMetadataFinder(ResourceLocation location, int index); + + @Invoker("createResource") + private static Resource lightspeed$createResource(PackResources pack, ResourceLocation location, + IoSupplier resource, + IoSupplier metadata) { + *///?} throw new AssertionError(); } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { private void getResourceHeadInjected(Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*private void getResourceHeadInjected(ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup || this.fallbacks.size() <= 1) { return; } @@ -102,7 +116,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional lightspeed$searchSafeSegment(List segment, Identifier location) { + //?} else { + /*private Optional lightspeed$searchSafeSegment(List segment, ResourceLocation location) { + *///?} if (segment.isEmpty()) { return null; } @@ -150,7 +168,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional> lightspeed$searchIndexedSegment(List segment, Identifier location) { + //?} else { + /*private Optional> lightspeed$searchIndexedSegment(List segment, ResourceLocation location) { + *///?} for (IndexedPack indexedPack : segment) { if (!(indexedPack.pack() instanceof IPathResourcePack indexedPackResources)) { return Optional.empty(); @@ -173,7 +195,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional lightspeed$searchSafeSegmentSequential(List segment, Identifier location) { + //?} else { + /*private Optional lightspeed$searchSafeSegmentSequential(List segment, ResourceLocation location) { + *///?} for (IndexedPack indexedPack : segment) { IoSupplier supplier = indexedPack.pack().getResource(this.type, location); if (supplier != null) { diff --git a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java index c496eef..3b67e13 100644 --- a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java +++ b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java @@ -1,15 +1,11 @@ -//? if <26.2 { +//? if <1.21 { package com.ccr4ft3r.lightspeed.mixin.resources; import com.ccr4ft3r.lightspeed.cache.GlobalCache; import com.ccr4ft3r.lightspeed.compat.FusionPackCompat; import com.ccr4ft3r.lightspeed.interfaces.IPackResources; import com.google.common.collect.Maps; -//? if >=1.21 { -import net.minecraft.resources.Identifier; -//?} else { -/*import net.minecraft.resources.ResourceLocation; -*///?} +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.FilePackResources; import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; @@ -75,7 +71,7 @@ public abstract class FilePackResourcesMixin implements IPackResources { .filter(entry -> entry.startsWith(s1)) .forEach(entry -> { String s3 = entry.substring(s.length()); - Identifier resourcelocation = Identifier.tryBuild(namespace, s3); + ResourceLocation resourcelocation = ResourceLocation.tryBuild(namespace, s3); if (resourcelocation != null) { resourceOutput.accept(resourcelocation, lightspeed$openResource(packType, resourcelocation)); } @@ -107,7 +103,7 @@ public abstract class FilePackResourcesMixin implements IPackResources { } @Unique - private IoSupplier lightspeed$openResource(PackType packType, Identifier location) { + private IoSupplier lightspeed$openResource(PackType packType, ResourceLocation location) { return () -> { ZipFile zip = lightspeed$getOpenZipFile(); if (zip == null) { diff --git a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java index a05b6d7..acda7ad 100644 --- a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java +++ b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java @@ -181,7 +181,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { public void getResourceHeadInjected(PackType type, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheWalkedPaths || FusionPackCompat.hasOverrides(this)) { return; } @@ -223,7 +227,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } String resourcePath = cachedPath.replace(candidate.getFileSystem().getSeparator(), "/"); + //? if >=1.21 { Identifier location = Identifier.tryBuild(namespace, resourcePath); + //?} else { + /*ResourceLocation location = ResourceLocation.tryBuild(namespace, resourcePath); + *///?} if (location == null) { //? if <1.21 { /* Util.logAndPauseIfInIde(String.format(Locale.ROOT, "Invalid path in pack: %s:%s, ignoring", namespace, resourcePath)); @@ -309,7 +317,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Override + //? if >=1.21 { public Boolean lightspeed$hasIndexedResource(PackType type, Identifier location) { + //?} else { + /*public Boolean lightspeed$hasIndexedResource(PackType type, ResourceLocation location) { + *///?} PackType effectiveType = lightspeed$effectiveType(type, location); List cachedPaths = lightspeed$getCachedFilePaths(effectiveType, location.getNamespace()); if (cachedPaths == null) { @@ -503,7 +515,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Unique + //? if >=1.21 { private IoSupplier lightspeed$openResource(PackType type, Identifier location) { + //?} else { + /*private IoSupplier lightspeed$openResource(PackType type, ResourceLocation location) { + *///?} PackType effectiveType = lightspeed$effectiveType(type, location); return () -> Files.newInputStream(resolve(lightspeed$getPathParts(effectiveType, location))); } @@ -514,12 +530,20 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Unique + //? if >=1.21 { private static PackType lightspeed$effectiveType(PackType type, Identifier location) { + //?} else { + /*private static PackType lightspeed$effectiveType(PackType type, ResourceLocation location) { + *///?} return location.getPath().startsWith("lang/") ? PackType.CLIENT_RESOURCES : type; } @Unique + //? if >=1.21 { private static String[] lightspeed$getPathParts(PackType type, Identifier location) { + //?} else { + /*private static String[] lightspeed$getPathParts(PackType type, ResourceLocation location) { + *///?} String[] resourceParts = location.getPath().split("/"); String[] paths = new String[resourceParts.length + 2]; paths[0] = type.getDirectory(); diff --git a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java index a47f3a9..9c29966 100644 --- a/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java +++ b/neoforge/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java @@ -58,7 +58,11 @@ public abstract class VanillaPackResourcesMixin implements IPackResources { } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { public void getResourceHeadInjected(PackType packType, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence) return; @@ -70,7 +74,11 @@ public abstract class VanillaPackResourcesMixin implements IPackResources { } @Inject(method = "getResource", at = @At("RETURN")) + //? if >=1.21 { public void getResourceReturnInjected(PackType packType, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceReturnInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence) return; diff --git a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java index 3cca128..cbde33e 100644 --- a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java +++ b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/AbstractPackResourcesMixin.java @@ -4,7 +4,7 @@ import com.ccr4ft3r.lightspeed.cache.GlobalCache; import com.ccr4ft3r.lightspeed.interfaces.IPackResources; import com.google.common.collect.Maps; import net.minecraft.server.packs.AbstractPackResources; -//? if >=26.2 { +//? if >=1.21 { import net.minecraft.server.packs.PackLocationInfo; //?} import org.spongepowered.asm.mixin.Mixin; @@ -21,7 +21,7 @@ public abstract class AbstractPackResourcesMixin implements IPackResources { @Unique private Map lightspeed$existenceByResource = Maps.newConcurrentMap(); - //? if >=26.2 { +//? if >=1.21 { @Inject(method = "", at = @At("RETURN")) public void initReturnInjected(PackLocationInfo location, CallbackInfo ci) { if (GlobalCache.isEnabled) diff --git a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java index 73f3351..30f69bb 100644 --- a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java +++ b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/DelegatingResourcePackMixin.java @@ -39,14 +39,22 @@ import java.util.List; //?} public abstract class DelegatingResourcePackMixin { @Shadow + //? if >=1.21 { protected abstract List getCandidatePacks(PackType type, Identifier location); + //?} else { + /*protected abstract List getCandidatePacks(PackType type, ResourceLocation location); + *///?} //? if >=1.21 { @Inject(method = "getResource(Lnet/minecraft/server/packs/PackType;Lnet/minecraft/resources/Identifier;)Lnet/minecraft/server/packs/resources/IoSupplier;", at = @At(value = "HEAD"), cancellable = true) //?} else { /*@Inject(method = "getResource(Lnet/minecraft/server/packs/PackType;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/server/packs/resources/IoSupplier;", at = @At(value = "HEAD"), cancellable = true) *///?} + //? if >=1.21 { public void getResourceHeadInjected(PackType type, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup) return; IoSupplier result = GlobalCache.findFirstResource(getCandidatePacks(type, location), type, location); diff --git a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java index db7a2dd..0e3bb42 100644 --- a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java +++ b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FallbackResourceManagerMixin.java @@ -48,6 +48,7 @@ public abstract class FallbackResourceManagerMixin { @Shadow @Final public List fallbacks; @Shadow @Final private PackType type; + //? if >=1.21 { @Invoker("createStackMetadataFinder") protected abstract IoSupplier lightspeed$createStackMetadataFinder(Identifier location, int index); @@ -55,11 +56,24 @@ public abstract class FallbackResourceManagerMixin { private static Resource lightspeed$createResource(PackResources pack, Identifier location, IoSupplier resource, IoSupplier metadata) { + //?} else { + /*@Invoker("createStackMetadataFinder") + protected abstract IoSupplier lightspeed$createStackMetadataFinder(ResourceLocation location, int index); + + @Invoker("createResource") + private static Resource lightspeed$createResource(PackResources pack, ResourceLocation location, + IoSupplier resource, + IoSupplier metadata) { + *///?} throw new AssertionError(); } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { private void getResourceHeadInjected(Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*private void getResourceHeadInjected(ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup || this.fallbacks.size() <= 1) { return; } @@ -102,7 +116,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional lightspeed$searchSafeSegment(List segment, Identifier location) { + //?} else { + /*private Optional lightspeed$searchSafeSegment(List segment, ResourceLocation location) { + *///?} if (segment.isEmpty()) { return null; } @@ -150,7 +168,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional> lightspeed$searchIndexedSegment(List segment, Identifier location) { + //?} else { + /*private Optional> lightspeed$searchIndexedSegment(List segment, ResourceLocation location) { + *///?} for (IndexedPack indexedPack : segment) { if (!(indexedPack.pack() instanceof IPathResourcePack indexedPackResources)) { return Optional.empty(); @@ -173,7 +195,11 @@ public abstract class FallbackResourceManagerMixin { } @Unique + //? if >=1.21 { private Optional lightspeed$searchSafeSegmentSequential(List segment, Identifier location) { + //?} else { + /*private Optional lightspeed$searchSafeSegmentSequential(List segment, ResourceLocation location) { + *///?} for (IndexedPack indexedPack : segment) { IoSupplier supplier = indexedPack.pack().getResource(this.type, location); if (supplier != null) { diff --git a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java index c496eef..3b67e13 100644 --- a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java +++ b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/FilePackResourcesMixin.java @@ -1,15 +1,11 @@ -//? if <26.2 { +//? if <1.21 { package com.ccr4ft3r.lightspeed.mixin.resources; import com.ccr4ft3r.lightspeed.cache.GlobalCache; import com.ccr4ft3r.lightspeed.compat.FusionPackCompat; import com.ccr4ft3r.lightspeed.interfaces.IPackResources; import com.google.common.collect.Maps; -//? if >=1.21 { -import net.minecraft.resources.Identifier; -//?} else { -/*import net.minecraft.resources.ResourceLocation; -*///?} +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.FilePackResources; import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; @@ -75,7 +71,7 @@ public abstract class FilePackResourcesMixin implements IPackResources { .filter(entry -> entry.startsWith(s1)) .forEach(entry -> { String s3 = entry.substring(s.length()); - Identifier resourcelocation = Identifier.tryBuild(namespace, s3); + ResourceLocation resourcelocation = ResourceLocation.tryBuild(namespace, s3); if (resourcelocation != null) { resourceOutput.accept(resourcelocation, lightspeed$openResource(packType, resourcelocation)); } @@ -107,7 +103,7 @@ public abstract class FilePackResourcesMixin implements IPackResources { } @Unique - private IoSupplier lightspeed$openResource(PackType packType, Identifier location) { + private IoSupplier lightspeed$openResource(PackType packType, ResourceLocation location) { return () -> { ZipFile zip = lightspeed$getOpenZipFile(); if (zip == null) { diff --git a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java index a05b6d7..acda7ad 100644 --- a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java +++ b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/PathResourcePackMixin.java @@ -181,7 +181,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { public void getResourceHeadInjected(PackType type, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheWalkedPaths || FusionPackCompat.hasOverrides(this)) { return; } @@ -223,7 +227,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } String resourcePath = cachedPath.replace(candidate.getFileSystem().getSeparator(), "/"); + //? if >=1.21 { Identifier location = Identifier.tryBuild(namespace, resourcePath); + //?} else { + /*ResourceLocation location = ResourceLocation.tryBuild(namespace, resourcePath); + *///?} if (location == null) { //? if <1.21 { /* Util.logAndPauseIfInIde(String.format(Locale.ROOT, "Invalid path in pack: %s:%s, ignoring", namespace, resourcePath)); @@ -309,7 +317,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Override + //? if >=1.21 { public Boolean lightspeed$hasIndexedResource(PackType type, Identifier location) { + //?} else { + /*public Boolean lightspeed$hasIndexedResource(PackType type, ResourceLocation location) { + *///?} PackType effectiveType = lightspeed$effectiveType(type, location); List cachedPaths = lightspeed$getCachedFilePaths(effectiveType, location.getNamespace()); if (cachedPaths == null) { @@ -503,7 +515,11 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Unique + //? if >=1.21 { private IoSupplier lightspeed$openResource(PackType type, Identifier location) { + //?} else { + /*private IoSupplier lightspeed$openResource(PackType type, ResourceLocation location) { + *///?} PackType effectiveType = lightspeed$effectiveType(type, location); return () -> Files.newInputStream(resolve(lightspeed$getPathParts(effectiveType, location))); } @@ -514,12 +530,20 @@ public abstract class PathResourcePackMixin implements IPathResourcePack, IPackR } @Unique + //? if >=1.21 { private static PackType lightspeed$effectiveType(PackType type, Identifier location) { + //?} else { + /*private static PackType lightspeed$effectiveType(PackType type, ResourceLocation location) { + *///?} return location.getPath().startsWith("lang/") ? PackType.CLIENT_RESOURCES : type; } @Unique + //? if >=1.21 { private static String[] lightspeed$getPathParts(PackType type, Identifier location) { + //?} else { + /*private static String[] lightspeed$getPathParts(PackType type, ResourceLocation location) { + *///?} String[] resourceParts = location.getPath().split("/"); String[] paths = new String[resourceParts.length + 2]; paths[0] = type.getDirectory(); diff --git a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java index a47f3a9..9c29966 100644 --- a/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java +++ b/src/main/java/com/ccr4ft3r/lightspeed/mixin/resources/VanillaPackResourcesMixin.java @@ -58,7 +58,11 @@ public abstract class VanillaPackResourcesMixin implements IPackResources { } @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) + //? if >=1.21 { public void getResourceHeadInjected(PackType packType, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceHeadInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence) return; @@ -70,7 +74,11 @@ public abstract class VanillaPackResourcesMixin implements IPackResources { } @Inject(method = "getResource", at = @At("RETURN")) + //? if >=1.21 { public void getResourceReturnInjected(PackType packType, Identifier location, CallbackInfoReturnable> cir) { + //?} else { + /*public void getResourceReturnInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable> cir) { + *///?} if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence) return;