diff options
author | Linnea Gräf <nea@nea.moe> | 2025-02-17 20:47:56 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-02-17 20:47:56 +0100 |
commit | 9cce9ddf26b44871e08a1d5d95f39d5e9b99c524 (patch) | |
tree | 2cd249ae647e8860b8db9e2df93144899f1e6a83 /src/main | |
parent | a23ac73272da14c0a126c44580ea45014e05a9ad (diff) | |
download | Firmament-9cce9ddf26b44871e08a1d5d95f39d5e9b99c524.tar.gz Firmament-9cce9ddf26b44871e08a1d5d95f39d5e9b99c524.tar.bz2 Firmament-9cce9ddf26b44871e08a1d5d95f39d5e9b99c524.zip |
fix: Don't crash with newer fabric versions anymore
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java | 24 | ||||
-rw-r--r-- | src/main/kotlin/repo/RepoModResourcePack.kt | 5 | ||||
-rw-r--r-- | src/main/resources/fabric.mod.json | 2 |
3 files changed, 19 insertions, 12 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java b/src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java index 22ce991..d8e35d7 100644 --- a/src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java +++ b/src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java @@ -1,28 +1,34 @@ package moe.nea.firmament.mixins; +import com.llamalad7.mixinextras.sugar.Local; import moe.nea.firmament.repo.RepoModResourcePack; import net.fabricmc.fabric.api.resource.ModResourcePack; +import net.fabricmc.fabric.impl.resource.loader.ModResourcePackSorter; import net.fabricmc.fabric.impl.resource.loader.ModResourcePackUtil; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.resource.ResourceType; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.List; @Mixin(ModResourcePackUtil.class) public class AppendRepoAsResourcePack { - @Inject(method = "appendModResourcePacks", at = @At("TAIL")) - private static void onAppendModResourcePack( - List<ModResourcePack> packs, - ResourceType type, - @Nullable String subPath, - CallbackInfo ci - ) { - RepoModResourcePack.Companion.append(packs); - } + @Inject( + method = "getModResourcePacks", + at = @At(value = "INVOKE", target = "Lnet/fabricmc/fabric/impl/resource/loader/ModResourcePackSorter;getPacks()Ljava/util/List;"), + require = 0 + ) + private static void onAppendModResourcePack( + FabricLoader fabricLoader, ResourceType type, @Nullable String subPath, CallbackInfoReturnable<List<ModResourcePack>> cir, + @Local ModResourcePackSorter sorter + ) { + RepoModResourcePack.Companion.append(sorter); + } } diff --git a/src/main/kotlin/repo/RepoModResourcePack.kt b/src/main/kotlin/repo/RepoModResourcePack.kt index 617efec..2fdf710 100644 --- a/src/main/kotlin/repo/RepoModResourcePack.kt +++ b/src/main/kotlin/repo/RepoModResourcePack.kt @@ -5,6 +5,7 @@ import java.nio.file.Files import java.nio.file.Path import java.util.* import net.fabricmc.fabric.api.resource.ModResourcePack +import net.fabricmc.fabric.impl.resource.loader.ModResourcePackSorter import net.fabricmc.loader.api.FabricLoader import net.fabricmc.loader.api.metadata.ModMetadata import kotlin.io.path.exists @@ -28,9 +29,9 @@ import moe.nea.firmament.Firmament class RepoModResourcePack(val basePath: Path) : ModResourcePack { companion object { - fun append(packs: MutableList<in ModResourcePack>) { + fun append(packs: ModResourcePackSorter) { Firmament.logger.info("Registering mod resource pack") - packs.add(RepoModResourcePack(RepoDownloadManager.repoSavedLocation)) + packs.addPack(RepoModResourcePack(RepoDownloadManager.repoSavedLocation)) } fun createResourceDirectly(identifier: Identifier): Optional<Resource> { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3b988b1..cf7130b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -48,7 +48,7 @@ "firmament.mixins.json" ], "depends": { - "fabric": "*", + "fabric": ">=${fabric_api_version}", "fabric-language-kotlin": ">=${fabric_kotlin_version}", "minecraft": ">=${minecraft_version}" }, |