Fix sodium reloadin

[no changelog]
This commit is contained in:
Linnea Gräf
2024-08-12 22:48:07 +02:00
parent b8a45b9a04
commit 0decd04bc3
4 changed files with 42 additions and 0 deletions

View File

@@ -467,6 +467,10 @@ Currently, the only supported filter is `title`, which accepts a [string matcher
## Block Model Replacements ## Block Model Replacements
Firmament adds the ability to retexture block models. Supported renderers are vanilla, indigo (fabric), sodium (and
anything sodium based). Firmament performs gentle world reloading so that even when the world data gets updated very
late by the server there should be no flicker.
If you want to replace block textures in the world you can do so using block overrides. Those are stored in If you want to replace block textures in the world you can do so using block overrides. Those are stored in
`assets/firmskyblock/overrides/blocks/<id>.json`. The id does not matter, all overrides are loaded. This file specifies `assets/firmskyblock/overrides/blocks/<id>.json`. The id does not matter, all overrides are loaded. This file specifies
which block models are replaced under which conditions: which block models are replaced under which conditions:

View File

@@ -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();
}

View File

@@ -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)
}
}

View File

@@ -3,6 +3,7 @@
package moe.nea.firmament.features.texturepack package moe.nea.firmament.features.texturepack
import java.util.concurrent.CompletableFuture import java.util.concurrent.CompletableFuture
import net.fabricmc.loader.api.FabricLoader
import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@@ -29,6 +30,7 @@ import net.minecraft.util.math.BlockPos
import net.minecraft.util.profiler.Profiler import net.minecraft.util.profiler.Profiler
import moe.nea.firmament.Firmament import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.compat.SodiumChunkReloader
import moe.nea.firmament.events.BakeExtraModelsEvent import moe.nea.firmament.events.BakeExtraModelsEvent
import moe.nea.firmament.events.EarlyResourceReloadEvent import moe.nea.firmament.events.EarlyResourceReloadEvent
import moe.nea.firmament.events.FinalizeResourceManagerEvent import moe.nea.firmament.events.FinalizeResourceManagerEvent
@@ -161,10 +163,20 @@ object CustomBlockTextures {
// false schedules rebuilds outside a 27 block radius to happen async // false schedules rebuilds outside a 27 block radius to happen async
it.scheduleRebuild(false) 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 { fun matchesPosition(replacement: BlockReplacement, blockPos: BlockPos?): Boolean {
if (blockPos == null) return true if (blockPos == null) return true
val rc = replacement.roughCheck val rc = replacement.roughCheck