aboutsummaryrefslogtreecommitdiff
path: root/src/compat
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-10-14 23:41:36 +0200
committerLinnea Gräf <nea@nea.moe>2025-10-14 23:41:36 +0200
commit765a38ecc0f855229722354866eaf561a9a6123c (patch)
treef94447f5cd4e826930c46d0db79685b80d25e09c /src/compat
parentd8f449c708c3fec138c0c4c1463d2f3de3f8f221 (diff)
downloadFirmament-765a38ecc0f855229722354866eaf561a9a6123c.tar.gz
Firmament-765a38ecc0f855229722354866eaf561a9a6123c.tar.bz2
Firmament-765a38ecc0f855229722354866eaf561a9a6123c.zip
fix: sodium integration for custom block texture areas
Diffstat (limited to 'src/compat')
-rw-r--r--src/compat/sodium/java/moe/nea/firmament/compat/sodium/Compat.kt12
-rw-r--r--src/compat/sodium/java/moe/nea/firmament/compat/sodium/SodiumChunkReloader.kt (renamed from src/compat/sodium/java/SodiumChunkReloader.kt)2
-rw-r--r--src/compat/sodium/java/moe/nea/firmament/mixins/custommodels/PatchBlockModelInSodiumChunkGenerator.java29
-rw-r--r--src/compat/sodium/java/moe/nea/firmament/mixins/sodium/accessor/AccessorSodiumWorldRenderer.java (renamed from src/compat/sodium/java/moe/nea/firmament/mixins/accessor/sodium/AccessorSodiumWorldRenderer.java)2
-rw-r--r--src/compat/sodium/java/moe/nea/firmament/mixins/sodium/custommodels/PatchBlockModelInSodiumChunkGenerator.java29
5 files changed, 43 insertions, 31 deletions
diff --git a/src/compat/sodium/java/moe/nea/firmament/compat/sodium/Compat.kt b/src/compat/sodium/java/moe/nea/firmament/compat/sodium/Compat.kt
new file mode 100644
index 0000000..97ae1fc
--- /dev/null
+++ b/src/compat/sodium/java/moe/nea/firmament/compat/sodium/Compat.kt
@@ -0,0 +1,12 @@
+package moe.nea.firmament.compat.sodium
+
+import moe.nea.firmament.util.compatloader.CompatMeta
+import moe.nea.firmament.util.compatloader.ICompatMeta
+import net.fabricmc.loader.api.FabricLoader
+
+@CompatMeta
+object Compat : ICompatMeta {
+ override fun shouldLoad(): Boolean {
+ return FabricLoader.getInstance().isModLoaded("sodium")
+ }
+}
diff --git a/src/compat/sodium/java/SodiumChunkReloader.kt b/src/compat/sodium/java/moe/nea/firmament/compat/sodium/SodiumChunkReloader.kt
index 0256b88..e5d0fd9 100644
--- a/src/compat/sodium/java/SodiumChunkReloader.kt
+++ b/src/compat/sodium/java/moe/nea/firmament/compat/sodium/SodiumChunkReloader.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.compat.sodium
+import moe.nea.firmament.mixins.sodium.accessor.AccessorSodiumWorldRenderer
import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer
-import moe.nea.firmament.mixins.accessor.sodium.AccessorSodiumWorldRenderer
class SodiumChunkReloader : Runnable {
override fun run() {
diff --git a/src/compat/sodium/java/moe/nea/firmament/mixins/custommodels/PatchBlockModelInSodiumChunkGenerator.java b/src/compat/sodium/java/moe/nea/firmament/mixins/custommodels/PatchBlockModelInSodiumChunkGenerator.java
deleted file mode 100644
index fe87310..0000000
--- a/src/compat/sodium/java/moe/nea/firmament/mixins/custommodels/PatchBlockModelInSodiumChunkGenerator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package moe.nea.firmament.mixins.custommodels;
-
-import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
-import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
-import com.llamalad7.mixinextras.sugar.Local;
-import moe.nea.firmament.features.texturepack.CustomBlockTextures;
-import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask;
-import net.minecraft.block.BlockState;
-import net.minecraft.client.render.block.BlockModels;
-import net.minecraft.client.render.model.BakedModel;
-import net.minecraft.util.math.BlockPos;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-
-@Mixin(ChunkBuilderMeshingTask.class)
-public class PatchBlockModelInSodiumChunkGenerator {
- @WrapOperation(
- method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;",
- at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/BlockModels;getModel(Lnet/minecraft/block/BlockState;)Lnet/minecraft/client/render/model/BakedModel;"))
- private BakedModel replaceBlockModel(BlockModels instance, BlockState state, Operation<BakedModel> original,
- @Local(name = "blockPos") BlockPos.Mutable pos) {
- var replacement = CustomBlockTextures.getReplacementModel(state, pos);
- if (replacement != null) return replacement;
- CustomBlockTextures.enterFallbackCall();
- var fallback = original.call(instance, state);
- CustomBlockTextures.exitFallbackCall();
- return fallback;
- }
-}
diff --git a/src/compat/sodium/java/moe/nea/firmament/mixins/accessor/sodium/AccessorSodiumWorldRenderer.java b/src/compat/sodium/java/moe/nea/firmament/mixins/sodium/accessor/AccessorSodiumWorldRenderer.java
index f75874d..bc2210a 100644
--- a/src/compat/sodium/java/moe/nea/firmament/mixins/accessor/sodium/AccessorSodiumWorldRenderer.java
+++ b/src/compat/sodium/java/moe/nea/firmament/mixins/sodium/accessor/AccessorSodiumWorldRenderer.java
@@ -1,4 +1,4 @@
-package moe.nea.firmament.mixins.accessor.sodium;
+package moe.nea.firmament.mixins.sodium.accessor;
import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer;
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSectionManager;
diff --git a/src/compat/sodium/java/moe/nea/firmament/mixins/sodium/custommodels/PatchBlockModelInSodiumChunkGenerator.java b/src/compat/sodium/java/moe/nea/firmament/mixins/sodium/custommodels/PatchBlockModelInSodiumChunkGenerator.java
new file mode 100644
index 0000000..50a545a
--- /dev/null
+++ b/src/compat/sodium/java/moe/nea/firmament/mixins/sodium/custommodels/PatchBlockModelInSodiumChunkGenerator.java
@@ -0,0 +1,29 @@
+package moe.nea.firmament.mixins.sodium.custommodels;
+
+import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
+import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
+import com.llamalad7.mixinextras.sugar.Local;
+import moe.nea.firmament.features.texturepack.CustomBlockTextures;
+import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask;
+import net.minecraft.block.BlockState;
+import net.minecraft.client.render.block.BlockModels;
+import net.minecraft.client.render.model.BlockStateModel;
+import net.minecraft.util.math.BlockPos;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+
+@Mixin(ChunkBuilderMeshingTask.class)
+public class PatchBlockModelInSodiumChunkGenerator {
+ @WrapOperation(
+ method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;",
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/BlockModels;getModel(Lnet/minecraft/block/BlockState;)Lnet/minecraft/client/render/model/BlockStateModel;"))
+ private BlockStateModel replaceBlockModel(BlockModels instance, BlockState state, Operation<BlockStateModel> original,
+ @Local(name = "blockPos") BlockPos.Mutable pos) {
+ var replacement = CustomBlockTextures.getReplacementModel(state, pos);
+ if (replacement != null) return replacement;
+ CustomBlockTextures.enterFallbackCall();
+ var fallback = original.call(instance, state);
+ CustomBlockTextures.exitFallbackCall();
+ return fallback;
+ }
+}