1.21.11 fixes (if >=1.21 { stuff)
This commit is contained in:
+2
-1
@@ -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 = [
|
||||
|
||||
+2
-2
@@ -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<String, Boolean> lightspeed$existenceByResource = Maps.newConcurrentMap();
|
||||
|
||||
//? if >=26.2 {
|
||||
//? if >=1.21 {
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void initReturnInjected(PackLocationInfo location, CallbackInfo ci) {
|
||||
if (GlobalCache.isEnabled)
|
||||
|
||||
+8
@@ -39,14 +39,22 @@ import java.util.List;
|
||||
//?}
|
||||
public abstract class DelegatingResourcePackMixin {
|
||||
@Shadow
|
||||
//? if >=1.21 {
|
||||
protected abstract List<PackResources> getCandidatePacks(PackType type, Identifier location);
|
||||
//?} else {
|
||||
/*protected abstract List<PackResources> 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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> cir) {
|
||||
*///?}
|
||||
if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup)
|
||||
return;
|
||||
IoSupplier<InputStream> result = GlobalCache.findFirstResource(getCandidatePacks(type, location), type, location);
|
||||
|
||||
+26
@@ -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<ResourceMetadata> lightspeed$createStackMetadataFinder(Identifier location, int index);
|
||||
|
||||
@@ -55,11 +56,24 @@ public abstract class FallbackResourceManagerMixin {
|
||||
private static Resource lightspeed$createResource(PackResources pack, Identifier location,
|
||||
IoSupplier<InputStream> resource,
|
||||
IoSupplier<ResourceMetadata> metadata) {
|
||||
//?} else {
|
||||
/*@Invoker("createStackMetadataFinder")
|
||||
protected abstract IoSupplier<ResourceMetadata> lightspeed$createStackMetadataFinder(ResourceLocation location, int index);
|
||||
|
||||
@Invoker("createResource")
|
||||
private static Resource lightspeed$createResource(PackResources pack, ResourceLocation location,
|
||||
IoSupplier<InputStream> resource,
|
||||
IoSupplier<ResourceMetadata> metadata) {
|
||||
*///?}
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
|
||||
//? if >=1.21 {
|
||||
private void getResourceHeadInjected(Identifier location, CallbackInfoReturnable<Optional<Resource>> cir) {
|
||||
//?} else {
|
||||
/*private void getResourceHeadInjected(ResourceLocation location, CallbackInfoReturnable<Optional<Resource>> 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<Resource> lightspeed$searchSafeSegment(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Resource> lightspeed$searchSafeSegment(List<IndexedPack> segment, ResourceLocation location) {
|
||||
*///?}
|
||||
if (segment.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -150,7 +168,11 @@ public abstract class FallbackResourceManagerMixin {
|
||||
}
|
||||
|
||||
@Unique
|
||||
//? if >=1.21 {
|
||||
private Optional<Optional<Resource>> lightspeed$searchIndexedSegment(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Optional<Resource>> lightspeed$searchIndexedSegment(List<IndexedPack> 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<Resource> lightspeed$searchSafeSegmentSequential(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Resource> lightspeed$searchSafeSegmentSequential(List<IndexedPack> segment, ResourceLocation location) {
|
||||
*///?}
|
||||
for (IndexedPack indexedPack : segment) {
|
||||
IoSupplier<InputStream> supplier = indexedPack.pack().getResource(this.type, location);
|
||||
if (supplier != null) {
|
||||
|
||||
+4
-8
@@ -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<InputStream> lightspeed$openResource(PackType packType, Identifier location) {
|
||||
private IoSupplier<InputStream> lightspeed$openResource(PackType packType, ResourceLocation location) {
|
||||
return () -> {
|
||||
ZipFile zip = lightspeed$getOpenZipFile();
|
||||
if (zip == null) {
|
||||
|
||||
+24
@@ -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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> 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<String> 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<InputStream> lightspeed$openResource(PackType type, Identifier location) {
|
||||
//?} else {
|
||||
/*private IoSupplier<InputStream> 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();
|
||||
|
||||
+8
@@ -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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> 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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceReturnInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> cir) {
|
||||
*///?}
|
||||
if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence)
|
||||
return;
|
||||
|
||||
|
||||
+2
-2
@@ -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<String, Boolean> lightspeed$existenceByResource = Maps.newConcurrentMap();
|
||||
|
||||
//? if >=26.2 {
|
||||
//? if >=1.21 {
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void initReturnInjected(PackLocationInfo location, CallbackInfo ci) {
|
||||
if (GlobalCache.isEnabled)
|
||||
|
||||
+8
@@ -39,14 +39,22 @@ import java.util.List;
|
||||
//?}
|
||||
public abstract class DelegatingResourcePackMixin {
|
||||
@Shadow
|
||||
//? if >=1.21 {
|
||||
protected abstract List<PackResources> getCandidatePacks(PackType type, Identifier location);
|
||||
//?} else {
|
||||
/*protected abstract List<PackResources> 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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> cir) {
|
||||
*///?}
|
||||
if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup)
|
||||
return;
|
||||
IoSupplier<InputStream> result = GlobalCache.findFirstResource(getCandidatePacks(type, location), type, location);
|
||||
|
||||
+26
@@ -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<ResourceMetadata> lightspeed$createStackMetadataFinder(Identifier location, int index);
|
||||
|
||||
@@ -55,11 +56,24 @@ public abstract class FallbackResourceManagerMixin {
|
||||
private static Resource lightspeed$createResource(PackResources pack, Identifier location,
|
||||
IoSupplier<InputStream> resource,
|
||||
IoSupplier<ResourceMetadata> metadata) {
|
||||
//?} else {
|
||||
/*@Invoker("createStackMetadataFinder")
|
||||
protected abstract IoSupplier<ResourceMetadata> lightspeed$createStackMetadataFinder(ResourceLocation location, int index);
|
||||
|
||||
@Invoker("createResource")
|
||||
private static Resource lightspeed$createResource(PackResources pack, ResourceLocation location,
|
||||
IoSupplier<InputStream> resource,
|
||||
IoSupplier<ResourceMetadata> metadata) {
|
||||
*///?}
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
|
||||
//? if >=1.21 {
|
||||
private void getResourceHeadInjected(Identifier location, CallbackInfoReturnable<Optional<Resource>> cir) {
|
||||
//?} else {
|
||||
/*private void getResourceHeadInjected(ResourceLocation location, CallbackInfoReturnable<Optional<Resource>> 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<Resource> lightspeed$searchSafeSegment(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Resource> lightspeed$searchSafeSegment(List<IndexedPack> segment, ResourceLocation location) {
|
||||
*///?}
|
||||
if (segment.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -150,7 +168,11 @@ public abstract class FallbackResourceManagerMixin {
|
||||
}
|
||||
|
||||
@Unique
|
||||
//? if >=1.21 {
|
||||
private Optional<Optional<Resource>> lightspeed$searchIndexedSegment(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Optional<Resource>> lightspeed$searchIndexedSegment(List<IndexedPack> 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<Resource> lightspeed$searchSafeSegmentSequential(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Resource> lightspeed$searchSafeSegmentSequential(List<IndexedPack> segment, ResourceLocation location) {
|
||||
*///?}
|
||||
for (IndexedPack indexedPack : segment) {
|
||||
IoSupplier<InputStream> supplier = indexedPack.pack().getResource(this.type, location);
|
||||
if (supplier != null) {
|
||||
|
||||
+4
-8
@@ -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<InputStream> lightspeed$openResource(PackType packType, Identifier location) {
|
||||
private IoSupplier<InputStream> lightspeed$openResource(PackType packType, ResourceLocation location) {
|
||||
return () -> {
|
||||
ZipFile zip = lightspeed$getOpenZipFile();
|
||||
if (zip == null) {
|
||||
|
||||
+24
@@ -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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> 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<String> 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<InputStream> lightspeed$openResource(PackType type, Identifier location) {
|
||||
//?} else {
|
||||
/*private IoSupplier<InputStream> 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();
|
||||
|
||||
+8
@@ -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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> 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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceReturnInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> cir) {
|
||||
*///?}
|
||||
if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence)
|
||||
return;
|
||||
|
||||
|
||||
+2
-2
@@ -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<String, Boolean> lightspeed$existenceByResource = Maps.newConcurrentMap();
|
||||
|
||||
//? if >=26.2 {
|
||||
//? if >=1.21 {
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void initReturnInjected(PackLocationInfo location, CallbackInfo ci) {
|
||||
if (GlobalCache.isEnabled)
|
||||
|
||||
+8
@@ -39,14 +39,22 @@ import java.util.List;
|
||||
//?}
|
||||
public abstract class DelegatingResourcePackMixin {
|
||||
@Shadow
|
||||
//? if >=1.21 {
|
||||
protected abstract List<PackResources> getCandidatePacks(PackType type, Identifier location);
|
||||
//?} else {
|
||||
/*protected abstract List<PackResources> 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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> cir) {
|
||||
*///?}
|
||||
if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup)
|
||||
return;
|
||||
IoSupplier<InputStream> result = GlobalCache.findFirstResource(getCandidatePacks(type, location), type, location);
|
||||
|
||||
+26
@@ -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<ResourceMetadata> lightspeed$createStackMetadataFinder(Identifier location, int index);
|
||||
|
||||
@@ -55,11 +56,24 @@ public abstract class FallbackResourceManagerMixin {
|
||||
private static Resource lightspeed$createResource(PackResources pack, Identifier location,
|
||||
IoSupplier<InputStream> resource,
|
||||
IoSupplier<ResourceMetadata> metadata) {
|
||||
//?} else {
|
||||
/*@Invoker("createStackMetadataFinder")
|
||||
protected abstract IoSupplier<ResourceMetadata> lightspeed$createStackMetadataFinder(ResourceLocation location, int index);
|
||||
|
||||
@Invoker("createResource")
|
||||
private static Resource lightspeed$createResource(PackResources pack, ResourceLocation location,
|
||||
IoSupplier<InputStream> resource,
|
||||
IoSupplier<ResourceMetadata> metadata) {
|
||||
*///?}
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
|
||||
//? if >=1.21 {
|
||||
private void getResourceHeadInjected(Identifier location, CallbackInfoReturnable<Optional<Resource>> cir) {
|
||||
//?} else {
|
||||
/*private void getResourceHeadInjected(ResourceLocation location, CallbackInfoReturnable<Optional<Resource>> 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<Resource> lightspeed$searchSafeSegment(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Resource> lightspeed$searchSafeSegment(List<IndexedPack> segment, ResourceLocation location) {
|
||||
*///?}
|
||||
if (segment.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -150,7 +168,11 @@ public abstract class FallbackResourceManagerMixin {
|
||||
}
|
||||
|
||||
@Unique
|
||||
//? if >=1.21 {
|
||||
private Optional<Optional<Resource>> lightspeed$searchIndexedSegment(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Optional<Resource>> lightspeed$searchIndexedSegment(List<IndexedPack> 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<Resource> lightspeed$searchSafeSegmentSequential(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Resource> lightspeed$searchSafeSegmentSequential(List<IndexedPack> segment, ResourceLocation location) {
|
||||
*///?}
|
||||
for (IndexedPack indexedPack : segment) {
|
||||
IoSupplier<InputStream> supplier = indexedPack.pack().getResource(this.type, location);
|
||||
if (supplier != null) {
|
||||
|
||||
+4
-8
@@ -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<InputStream> lightspeed$openResource(PackType packType, Identifier location) {
|
||||
private IoSupplier<InputStream> lightspeed$openResource(PackType packType, ResourceLocation location) {
|
||||
return () -> {
|
||||
ZipFile zip = lightspeed$getOpenZipFile();
|
||||
if (zip == null) {
|
||||
|
||||
+24
@@ -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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> 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<String> 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<InputStream> lightspeed$openResource(PackType type, Identifier location) {
|
||||
//?} else {
|
||||
/*private IoSupplier<InputStream> 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();
|
||||
|
||||
+8
@@ -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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> 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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceReturnInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> cir) {
|
||||
*///?}
|
||||
if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence)
|
||||
return;
|
||||
|
||||
|
||||
+2
-2
@@ -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<String, Boolean> lightspeed$existenceByResource = Maps.newConcurrentMap();
|
||||
|
||||
//? if >=26.2 {
|
||||
//? if >=1.21 {
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void initReturnInjected(PackLocationInfo location, CallbackInfo ci) {
|
||||
if (GlobalCache.isEnabled)
|
||||
|
||||
@@ -39,14 +39,22 @@ import java.util.List;
|
||||
//?}
|
||||
public abstract class DelegatingResourcePackMixin {
|
||||
@Shadow
|
||||
//? if >=1.21 {
|
||||
protected abstract List<PackResources> getCandidatePacks(PackType type, Identifier location);
|
||||
//?} else {
|
||||
/*protected abstract List<PackResources> 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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> cir) {
|
||||
*///?}
|
||||
if (!GlobalCache.isEnabled || !GlobalCache.shouldParallelizeResourcePackLookup)
|
||||
return;
|
||||
IoSupplier<InputStream> result = GlobalCache.findFirstResource(getCandidatePacks(type, location), type, location);
|
||||
|
||||
+26
@@ -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<ResourceMetadata> lightspeed$createStackMetadataFinder(Identifier location, int index);
|
||||
|
||||
@@ -55,11 +56,24 @@ public abstract class FallbackResourceManagerMixin {
|
||||
private static Resource lightspeed$createResource(PackResources pack, Identifier location,
|
||||
IoSupplier<InputStream> resource,
|
||||
IoSupplier<ResourceMetadata> metadata) {
|
||||
//?} else {
|
||||
/*@Invoker("createStackMetadataFinder")
|
||||
protected abstract IoSupplier<ResourceMetadata> lightspeed$createStackMetadataFinder(ResourceLocation location, int index);
|
||||
|
||||
@Invoker("createResource")
|
||||
private static Resource lightspeed$createResource(PackResources pack, ResourceLocation location,
|
||||
IoSupplier<InputStream> resource,
|
||||
IoSupplier<ResourceMetadata> metadata) {
|
||||
*///?}
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
|
||||
//? if >=1.21 {
|
||||
private void getResourceHeadInjected(Identifier location, CallbackInfoReturnable<Optional<Resource>> cir) {
|
||||
//?} else {
|
||||
/*private void getResourceHeadInjected(ResourceLocation location, CallbackInfoReturnable<Optional<Resource>> 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<Resource> lightspeed$searchSafeSegment(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Resource> lightspeed$searchSafeSegment(List<IndexedPack> segment, ResourceLocation location) {
|
||||
*///?}
|
||||
if (segment.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -150,7 +168,11 @@ public abstract class FallbackResourceManagerMixin {
|
||||
}
|
||||
|
||||
@Unique
|
||||
//? if >=1.21 {
|
||||
private Optional<Optional<Resource>> lightspeed$searchIndexedSegment(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Optional<Resource>> lightspeed$searchIndexedSegment(List<IndexedPack> 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<Resource> lightspeed$searchSafeSegmentSequential(List<IndexedPack> segment, Identifier location) {
|
||||
//?} else {
|
||||
/*private Optional<Resource> lightspeed$searchSafeSegmentSequential(List<IndexedPack> segment, ResourceLocation location) {
|
||||
*///?}
|
||||
for (IndexedPack indexedPack : segment) {
|
||||
IoSupplier<InputStream> supplier = indexedPack.pack().getResource(this.type, location);
|
||||
if (supplier != null) {
|
||||
|
||||
@@ -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<InputStream> lightspeed$openResource(PackType packType, Identifier location) {
|
||||
private IoSupplier<InputStream> lightspeed$openResource(PackType packType, ResourceLocation location) {
|
||||
return () -> {
|
||||
ZipFile zip = lightspeed$getOpenZipFile();
|
||||
if (zip == null) {
|
||||
|
||||
@@ -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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType type, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> 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<String> 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<InputStream> lightspeed$openResource(PackType type, Identifier location) {
|
||||
//?} else {
|
||||
/*private IoSupplier<InputStream> 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();
|
||||
|
||||
@@ -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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceHeadInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> 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<IoSupplier<InputStream>> cir) {
|
||||
//?} else {
|
||||
/*public void getResourceReturnInjected(PackType packType, ResourceLocation location, CallbackInfoReturnable<IoSupplier<InputStream>> cir) {
|
||||
*///?}
|
||||
if (!GlobalCache.isEnabled || !GlobalCache.shouldCacheResourceExistence)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user