diff --git a/src/main/java/dev/dubhe/anvilcraft/integration/embeddium/ModEmbeddiumMaterials.java b/src/main/java/dev/dubhe/anvilcraft/integration/embeddium/ModEmbeddiumMaterials.java new file mode 100644 index 000000000..3da7d7519 --- /dev/null +++ b/src/main/java/dev/dubhe/anvilcraft/integration/embeddium/ModEmbeddiumMaterials.java @@ -0,0 +1,9 @@ +package dev.dubhe.anvilcraft.integration.embeddium; + + +import org.embeddedt.embeddium.impl.render.chunk.terrain.material.Material; +import org.embeddedt.embeddium.impl.render.chunk.terrain.material.parameters.AlphaCutoffParameter; + +public class ModEmbeddiumMaterials { + public static final Material LASER = new Material(ModEmbeddiumTerrainRenderPasses.LASER, AlphaCutoffParameter.ZERO, true); +} diff --git a/src/main/java/dev/dubhe/anvilcraft/integration/embeddium/ModEmbeddiumTerrainRenderPasses.java b/src/main/java/dev/dubhe/anvilcraft/integration/embeddium/ModEmbeddiumTerrainRenderPasses.java new file mode 100644 index 000000000..536b4c6f1 --- /dev/null +++ b/src/main/java/dev/dubhe/anvilcraft/integration/embeddium/ModEmbeddiumTerrainRenderPasses.java @@ -0,0 +1,9 @@ +package dev.dubhe.anvilcraft.integration.embeddium; + + +import dev.dubhe.anvilcraft.client.init.ModRenderTypes; +import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass; + +public class ModEmbeddiumTerrainRenderPasses { + public static final TerrainRenderPass LASER = new TerrainRenderPass(ModRenderTypes.LASER, true, true); +} diff --git a/src/main/java/dev/dubhe/anvilcraft/integration/sodium/ModSodiumMaterials.java b/src/main/java/dev/dubhe/anvilcraft/integration/sodium/ModSodiumMaterials.java new file mode 100644 index 000000000..aacef0308 --- /dev/null +++ b/src/main/java/dev/dubhe/anvilcraft/integration/sodium/ModSodiumMaterials.java @@ -0,0 +1,8 @@ +package dev.dubhe.anvilcraft.integration.sodium; + +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material; +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.parameters.AlphaCutoffParameter; + +public class ModSodiumMaterials { + public static final Material LASER = new Material(ModSodiumTerrainRenderPasses.LASER, AlphaCutoffParameter.ZERO, true); +} diff --git a/src/main/java/dev/dubhe/anvilcraft/integration/sodium/ModSodiumTerrainRenderPasses.java b/src/main/java/dev/dubhe/anvilcraft/integration/sodium/ModSodiumTerrainRenderPasses.java new file mode 100644 index 000000000..6515f8f5c --- /dev/null +++ b/src/main/java/dev/dubhe/anvilcraft/integration/sodium/ModSodiumTerrainRenderPasses.java @@ -0,0 +1,9 @@ +package dev.dubhe.anvilcraft.integration.sodium; + + +import dev.dubhe.anvilcraft.client.init.ModRenderTypes; +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; + +public class ModSodiumTerrainRenderPasses { + public static final TerrainRenderPass LASER = new TerrainRenderPass(ModRenderTypes.LASER, true, true); +} diff --git a/src/main/java/dev/dubhe/anvilcraft/mixin/compat/EmbeddiumDefaultMaterialsMixin.java b/src/main/java/dev/dubhe/anvilcraft/mixin/compat/EmbeddiumDefaultMaterialsMixin.java new file mode 100644 index 000000000..4b146b668 --- /dev/null +++ b/src/main/java/dev/dubhe/anvilcraft/mixin/compat/EmbeddiumDefaultMaterialsMixin.java @@ -0,0 +1,26 @@ +package dev.dubhe.anvilcraft.mixin.compat; + +import dev.dubhe.anvilcraft.client.init.ModRenderTypes; +import dev.dubhe.anvilcraft.integration.embeddium.ModEmbeddiumMaterials; +import net.minecraft.client.renderer.RenderType; +import org.embeddedt.embeddium.impl.render.chunk.terrain.material.DefaultMaterials; +import org.embeddedt.embeddium.impl.render.chunk.terrain.material.Material; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(DefaultMaterials.class) +public class EmbeddiumDefaultMaterialsMixin { + @Inject( + method = "forRenderLayer", + at = @At("HEAD"), + cancellable = true + ) + private static void anvilcraft$forRenderLayer(RenderType layer, CallbackInfoReturnable cir){ + if (layer == ModRenderTypes.LASER){ + cir.setReturnValue(ModEmbeddiumMaterials.LASER); + cir.cancel(); + } + } +} diff --git a/src/main/java/dev/dubhe/anvilcraft/mixin/compat/EmbeddiumDefaultTerrainRenderPassesMixin.java b/src/main/java/dev/dubhe/anvilcraft/mixin/compat/EmbeddiumDefaultTerrainRenderPassesMixin.java new file mode 100644 index 000000000..46bf4c8b4 --- /dev/null +++ b/src/main/java/dev/dubhe/anvilcraft/mixin/compat/EmbeddiumDefaultTerrainRenderPassesMixin.java @@ -0,0 +1,34 @@ +package dev.dubhe.anvilcraft.mixin.compat; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.dubhe.anvilcraft.integration.embeddium.ModEmbeddiumTerrainRenderPasses; +import org.apache.commons.lang3.ArrayUtils; +import org.embeddedt.embeddium.impl.render.chunk.terrain.DefaultTerrainRenderPasses; +import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(DefaultTerrainRenderPasses.class) +public class EmbeddiumDefaultTerrainRenderPassesMixin { + + @Shadow + @Final + @Mutable + public static TerrainRenderPass[] ALL; + + @WrapOperation( + method = "", + at = @At( + value = "FIELD", + target = "Lorg/embeddedt/embeddium/impl/render/chunk/terrain/DefaultTerrainRenderPasses;ALL:[Lorg/embeddedt/embeddium/impl/render/chunk/terrain/TerrainRenderPass;" + ) + ) + private static void wrapAllClinit(TerrainRenderPass[] value, Operation original) { + original.call((Object) ArrayUtils.add(value, ModEmbeddiumTerrainRenderPasses.LASER)); + } + +} diff --git a/src/main/java/dev/dubhe/anvilcraft/mixin/compat/SodiumDefaultMaterialsMixin.java b/src/main/java/dev/dubhe/anvilcraft/mixin/compat/SodiumDefaultMaterialsMixin.java new file mode 100644 index 000000000..5369cb48b --- /dev/null +++ b/src/main/java/dev/dubhe/anvilcraft/mixin/compat/SodiumDefaultMaterialsMixin.java @@ -0,0 +1,26 @@ +package dev.dubhe.anvilcraft.mixin.compat; + +import dev.dubhe.anvilcraft.client.init.ModRenderTypes; +import dev.dubhe.anvilcraft.integration.sodium.ModSodiumMaterials; +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.DefaultMaterials; +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material; +import net.minecraft.client.renderer.RenderType; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(DefaultMaterials.class) +public class SodiumDefaultMaterialsMixin { + @Inject( + method = "forRenderLayer", + at = @At("HEAD"), + cancellable = true + ) + private static void anvilcraft$forRenderLayer(RenderType layer, CallbackInfoReturnable cir){ + if (layer == ModRenderTypes.LASER){ + cir.setReturnValue(ModSodiumMaterials.LASER); + cir.cancel(); + } + } +} diff --git a/src/main/java/dev/dubhe/anvilcraft/mixin/compat/SodiumDefaultTerrainRenderPassesMixin.java b/src/main/java/dev/dubhe/anvilcraft/mixin/compat/SodiumDefaultTerrainRenderPassesMixin.java new file mode 100644 index 000000000..f630f252d --- /dev/null +++ b/src/main/java/dev/dubhe/anvilcraft/mixin/compat/SodiumDefaultTerrainRenderPassesMixin.java @@ -0,0 +1,32 @@ +package dev.dubhe.anvilcraft.mixin.compat; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.dubhe.anvilcraft.integration.sodium.ModSodiumTerrainRenderPasses; +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.DefaultTerrainRenderPasses; +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; +import org.apache.commons.lang3.ArrayUtils; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(DefaultTerrainRenderPasses.class) +public class SodiumDefaultTerrainRenderPassesMixin { + + @Shadow @Final @Mutable + public static TerrainRenderPass[] ALL; + + @WrapOperation( + method = "", + at = @At( + value = "FIELD", + target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/DefaultTerrainRenderPasses;ALL:[Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;" + ) + ) + private static void wrapAllClinit(TerrainRenderPass[] value, Operation original) { + original.call((Object) ArrayUtils.add(value, ModSodiumTerrainRenderPasses.LASER)); + } + +} diff --git a/src/main/resources/anvilcraft.mixins.json b/src/main/resources/anvilcraft.mixins.json index d720609bc..33eb92b73 100644 --- a/src/main/resources/anvilcraft.mixins.json +++ b/src/main/resources/anvilcraft.mixins.json @@ -41,7 +41,11 @@ "SectionCompilerMixin", "SoundEngineMixin", "compat.EmbChunkBuilderMeshingTaskMixin", - "compat.SodiumChunkBuilderMeshingTaskMixin" + "compat.SodiumChunkBuilderMeshingTaskMixin", + "compat.EmbeddiumDefaultMaterialsMixin", + "compat.EmbeddiumDefaultTerrainRenderPassesMixin", + "compat.SodiumDefaultMaterialsMixin", + "compat.SodiumDefaultTerrainRenderPassesMixin" ], "plugin": "dev.dubhe.anvilcraft.mixin.plugin.AnvilCraftMixinPlugin", "injectors": {