From 3c7e6b6177de6ef3cff8a46bb1726466a299cdde Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 10 Aug 2024 01:59:34 +0200 Subject: Add indigo support to custom block textures --- src/main/kotlin/moe/nea/firmament/Firmament.kt | 3 +++ .../nea/firmament/features/texturepack/CustomBlockTextures.kt | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main/kotlin/moe/nea') diff --git a/src/main/kotlin/moe/nea/firmament/Firmament.kt b/src/main/kotlin/moe/nea/firmament/Firmament.kt index 4b742e8..400dcf2 100644 --- a/src/main/kotlin/moe/nea/firmament/Firmament.kt +++ b/src/main/kotlin/moe/nea/firmament/Firmament.kt @@ -33,6 +33,7 @@ import kotlinx.coroutines.plus import kotlinx.serialization.json.Json import kotlinx.serialization.json.decodeFromStream import kotlin.coroutines.EmptyCoroutineContext +import net.minecraft.client.render.chunk.SectionBuilder import net.minecraft.command.CommandRegistryAccess import net.minecraft.util.Identifier import moe.nea.firmament.commands.registerFirmamentCommand @@ -112,6 +113,8 @@ object Firmament { ClientTickEvents.END_CLIENT_TICK.register(ClientTickEvents.EndTick { instance -> TickEvent.publish(TickEvent(tick++)) }) + // TODO: remove me + Class.forName(SectionBuilder::class.java.name) IDataHolder.registerEvents() RepoManager.initialize() SBData.init() diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt index 2289be2..c869ba4 100644 --- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt @@ -157,7 +157,10 @@ object CustomBlockTextures { currentIslandReplacements = replacements if (lastReplacements != replacements) { MC.nextTick { - MC.worldRenderer.reload() + MC.worldRenderer.chunks?.chunks?.forEach { + // false schedules rebuilds outside a 27 block radius to happen async + it.scheduleRebuild(false) + } } } } @@ -259,6 +262,10 @@ object CustomBlockTextures { return BakedReplacements(map.mapValues { LocationReplacements(it.value) }) } + @JvmStatic + fun patchIndigo(orig: BakedModel, pos: BlockPos, state: BlockState): BakedModel { + return getReplacementModel(state, pos) ?: orig + } @Subscribe fun onStart(event: FinalizeResourceManagerEvent) { -- cgit