diff options
author | Linnea Gräf <nea@nea.moe> | 2024-08-12 22:48:07 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-08-12 22:48:07 +0200 |
commit | 0decd04bc348f957ef94a9a4beba5e3f829da718 (patch) | |
tree | b2fc85671d3748e5a15a64c4f42437307a960c76 /src | |
parent | b8a45b9a0438a12ba3c609f6e416d519829471be (diff) | |
download | firmament-0decd04bc348f957ef94a9a4beba5e3f829da718.tar.gz firmament-0decd04bc348f957ef94a9a4beba5e3f829da718.tar.bz2 firmament-0decd04bc348f957ef94a9a4beba5e3f829da718.zip |
Fix sodium reloadin
[no changelog]
Diffstat (limited to 'src')
3 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/sodium/AccessorSodiumWorldRenderer.java b/src/main/java/moe/nea/firmament/mixins/accessor/sodium/AccessorSodiumWorldRenderer.java new file mode 100644 index 0000000..b759204 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/accessor/sodium/AccessorSodiumWorldRenderer.java @@ -0,0 +1,14 @@ +package moe.nea.firmament.mixins.accessor.sodium; + +import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; +import me.jellysquid.mods.sodium.client.render.chunk.RenderSectionManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(SodiumWorldRenderer.class) +@Pseudo +public interface AccessorSodiumWorldRenderer { + @Accessor("renderSectionManager") + RenderSectionManager getRenderSectionManager_firmament(); +} diff --git a/src/main/kotlin/moe/nea/firmament/compat/SodiumChunkReloader.kt b/src/main/kotlin/moe/nea/firmament/compat/SodiumChunkReloader.kt new file mode 100644 index 0000000..4bb231a --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/compat/SodiumChunkReloader.kt @@ -0,0 +1,12 @@ +package moe.nea.firmament.compat + +import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer +import moe.nea.firmament.mixins.accessor.sodium.AccessorSodiumWorldRenderer + +class SodiumChunkReloader : Runnable { + override fun run() { + (SodiumWorldRenderer.instanceNullable() as AccessorSodiumWorldRenderer) + .renderSectionManager_firmament + .updateChunks(false) + } +} 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 c869ba4..18da54c 100644 --- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt @@ -3,6 +3,7 @@ package moe.nea.firmament.features.texturepack import java.util.concurrent.CompletableFuture +import net.fabricmc.loader.api.FabricLoader import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable @@ -29,6 +30,7 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.profiler.Profiler import moe.nea.firmament.Firmament import moe.nea.firmament.annotations.Subscribe +import moe.nea.firmament.compat.SodiumChunkReloader import moe.nea.firmament.events.BakeExtraModelsEvent import moe.nea.firmament.events.EarlyResourceReloadEvent import moe.nea.firmament.events.FinalizeResourceManagerEvent @@ -161,10 +163,20 @@ object CustomBlockTextures { // false schedules rebuilds outside a 27 block radius to happen async it.scheduleRebuild(false) } + sodiumReloadTask?.run() } } } + private val sodiumReloadTask = runCatching { + SodiumChunkReloader() + }.getOrElse { + if (FabricLoader.getInstance().isModLoaded("sodium")) + logger.error("Could not create sodium chunk reloader") + null + } + + fun matchesPosition(replacement: BlockReplacement, blockPos: BlockPos?): Boolean { if (blockPos == null) return true val rc = replacement.roughCheck |