diff options
author | Linnea Gräf <nea@nea.moe> | 2024-03-14 18:58:22 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-03-14 18:58:22 +0100 |
commit | 4bf53dcaf18dcc1fb7b064f482b2e8922d9d326f (patch) | |
tree | f163e9f9a58eaa5000da4cfa23ccc7e54f231dc5 /src/main/kotlin/moe | |
parent | b025b06b6b799b16cfcfb26ee8ffad27879a1bfb (diff) | |
download | Firmament-4bf53dcaf18dcc1fb7b064f482b2e8922d9d326f.tar.gz Firmament-4bf53dcaf18dcc1fb7b064f482b2e8922d9d326f.tar.bz2 Firmament-4bf53dcaf18dcc1fb7b064f482b2e8922d9d326f.zip |
Bandaid fix resources not being loade for june
[no changelog]
Diffstat (limited to 'src/main/kotlin/moe')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/repo/RepoModResourcePack.kt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/repo/RepoModResourcePack.kt b/src/main/kotlin/moe/nea/firmament/repo/RepoModResourcePack.kt index c511c90..810e2a4 100644 --- a/src/main/kotlin/moe/nea/firmament/repo/RepoModResourcePack.kt +++ b/src/main/kotlin/moe/nea/firmament/repo/RepoModResourcePack.kt @@ -9,6 +9,7 @@ package moe.nea.firmament.repo import java.io.InputStream import java.nio.file.Files import java.nio.file.Path +import java.util.* import net.fabricmc.fabric.api.resource.ModResourcePack import net.fabricmc.loader.api.FabricLoader import net.fabricmc.loader.api.metadata.ModMetadata @@ -18,17 +19,39 @@ import kotlin.io.path.relativeTo import kotlin.streams.asSequence import net.minecraft.resource.AbstractFileResourcePack import net.minecraft.resource.InputSupplier +import net.minecraft.resource.NamespaceResourceManager +import net.minecraft.resource.Resource import net.minecraft.resource.ResourcePack import net.minecraft.resource.ResourceType +import net.minecraft.resource.metadata.ResourceMetadata import net.minecraft.resource.metadata.ResourceMetadataReader import net.minecraft.util.Identifier import net.minecraft.util.PathUtil +import moe.nea.firmament.Firmament class RepoModResourcePack(val basePath: Path) : ModResourcePack { companion object { fun append(packs: MutableList<in ModResourcePack>) { + Firmament.logger.info("Registering mod resource pack") packs.add(RepoModResourcePack(RepoDownloadManager.repoSavedLocation)) } + + fun createResourceDirectly(identifier: Identifier): Optional<Resource> { + val pack = RepoModResourcePack(RepoDownloadManager.repoSavedLocation) + return Optional.of( + Resource( + pack, + pack.open(ResourceType.CLIENT_RESOURCES, identifier) ?: return Optional.empty() + ) { + val base = + pack.open(ResourceType.CLIENT_RESOURCES, identifier.withPath(identifier.path + ".mcmeta")) + if (base == null) + ResourceMetadata.NONE + else + NamespaceResourceManager.loadMetadata(base) + } + ) + } } override fun close() { |