diff --git a/build.gradle.kts b/build.gradle.kts index 32d2c17b..0f0b3fed 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -55,6 +55,7 @@ repositories { includeGroup("curse.maven") } } + maven(url = "https://api.modrinth.com/maven") maven(url = "https://maven.ladysnake.org/releases") maven("https://maven.terraformersmc.com/") maven(url = "https://maven.parchmentmc.org") @@ -89,6 +90,7 @@ dependencies { modApi(("io.github.fabricators_of_create.Porting-Lib:$module:${property("port_lib_version")}")) } + modApi("maven.modrinth:sodium:${property("sodium_version")}") modApi("com.jamieswhiteshirt:reach-entity-attributes:${property("reach_entity_attributes_version")}") } diff --git a/gradle.properties b/gradle.properties index eebeec29..01fb5764 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,7 @@ parchment_version=2023.09.03-1.20.1 # Mod Properties mod_name=Lodestone mod_id=lodestone -mod_version=1.5.1 +mod_version=1.5.2 mod_license=GPLv3 mod_group_id=team.lodestar.lodestone # The authors of the mod. This is a simple text string that is used for display purposes in the mod list. @@ -36,6 +36,7 @@ jei_version=15.2.0.27 trinkets_version=3.7.0 cca_version=5.2.2 reach_entity_attributes_version=2.4.0 +sodium_version=mc1.20.1-0.5.8 port_lib_version = 2.3.4+1.20.1 port_lib_modules = \ diff --git a/src/main/java/team/lodestar/lodestone/mixin/LodestoneMixinPlugin.java b/src/main/java/team/lodestar/lodestone/mixin/LodestoneMixinPlugin.java new file mode 100644 index 00000000..32f1121b --- /dev/null +++ b/src/main/java/team/lodestar/lodestone/mixin/LodestoneMixinPlugin.java @@ -0,0 +1,55 @@ +package team.lodestar.lodestone.mixin; + +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class LodestoneMixinPlugin implements IMixinConfigPlugin { + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return ""; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + boolean sodiumLoaded = FabricLoader.getInstance().isModLoaded("sodium"); + if (mixinClassName.startsWith("team.lodestar.lodestone.mixin.client.integration.sodium")) { + return sodiumLoaded; + } + + if (mixinClassName.startsWith("team.lodestar.lodestone.mixin.client.integration.notsodium")) { + return !sodiumLoaded; + } + + return true; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return List.of(); + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/src/main/java/team/lodestar/lodestone/mixin/client/LevelRendererMixin.java b/src/main/java/team/lodestar/lodestone/mixin/client/LevelRendererMixin.java index d7b2d87b..5cb20b65 100644 --- a/src/main/java/team/lodestar/lodestone/mixin/client/LevelRendererMixin.java +++ b/src/main/java/team/lodestar/lodestone/mixin/client/LevelRendererMixin.java @@ -105,11 +105,6 @@ private void lodestoneLevelRendererPoseStackGrabber(PoseStack pPoseStack, float LodestoneRenderEvents.AFTER_SKY.invoker().render(poseStack, partialTick, Stage.AFTER_SKY); } - @Inject(method = "renderChunkLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderType;clearRenderState()V")) - private void lodestone$injectEvent6(RenderType renderType, PoseStack poseStack, double camX, double camY, double camZ, Matrix4f projectionMatrix, CallbackInfo ci){ - LodestoneRenderEvents.BEFORE_CLEAR.invoker().render(renderType, poseStack, Stage.AFTER_SOLID_BLOCKS); - } - @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", ordinal = 12)) private void lodestone$injectEvent57(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci){ LodestoneRenderEvents.AFTER_BLOCK_ENTITIES.invoker().render(poseStack, partialTick, Stage.AFTER_BLOCK_ENTITIES); diff --git a/src/main/java/team/lodestar/lodestone/mixin/client/integration/notsodium/LevelRendererMixin.java b/src/main/java/team/lodestar/lodestone/mixin/client/integration/notsodium/LevelRendererMixin.java new file mode 100644 index 00000000..e977ea86 --- /dev/null +++ b/src/main/java/team/lodestar/lodestone/mixin/client/integration/notsodium/LevelRendererMixin.java @@ -0,0 +1,20 @@ +package team.lodestar.lodestone.mixin.client.integration.notsodium; + +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.*; +import org.joml.Matrix4f; +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.CallbackInfo; +import team.lodestar.lodestone.events.LodestoneRenderEvents; +import team.lodestar.lodestone.events.Stage; + +@Mixin(LevelRenderer.class) +public class LevelRendererMixin { + + @Inject(method = "renderChunkLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderType;clearRenderState()V")) + private void lodestone$injectEvent6(RenderType renderType, PoseStack poseStack, double camX, double camY, double camZ, Matrix4f projectionMatrix, CallbackInfo ci){ + LodestoneRenderEvents.BEFORE_CLEAR.invoker().render(renderType, poseStack, Stage.AFTER_SOLID_BLOCKS); + } +} \ No newline at end of file diff --git a/src/main/java/team/lodestar/lodestone/mixin/client/integration/sodium/SodiumWorldRendererMixin.java b/src/main/java/team/lodestar/lodestone/mixin/client/integration/sodium/SodiumWorldRendererMixin.java new file mode 100644 index 00000000..7a78d526 --- /dev/null +++ b/src/main/java/team/lodestar/lodestone/mixin/client/integration/sodium/SodiumWorldRendererMixin.java @@ -0,0 +1,21 @@ +package team.lodestar.lodestone.mixin.client.integration.sodium; + + +import com.mojang.blaze3d.vertex.PoseStack; +import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; +import net.minecraft.client.renderer.RenderType; +import org.joml.Matrix4f; +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.CallbackInfo; +import team.lodestar.lodestone.events.LodestoneRenderEvents; +import team.lodestar.lodestone.events.Stage; + +@Mixin(SodiumWorldRenderer.class) +public class SodiumWorldRendererMixin { + @Inject(method = "drawChunkLayer", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSectionManager;renderLayer(Lme/jellysquid/mods/sodium/client/render/chunk/ChunkRenderMatrices;Lme/jellysquid/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;DDD)V")) + private void lodestone$injectEvent6(RenderType renderLayer, PoseStack matrixStack, double x, double y, double z, CallbackInfo ci){ + LodestoneRenderEvents.BEFORE_CLEAR.invoker().render(renderLayer, matrixStack, Stage.AFTER_SOLID_BLOCKS); + } +} diff --git a/src/main/resources/lodestone.mixins.json b/src/main/resources/lodestone.mixins.json index 8bf66f8e..ac741f0b 100644 --- a/src/main/resources/lodestone.mixins.json +++ b/src/main/resources/lodestone.mixins.json @@ -2,7 +2,9 @@ "required": true, "package": "team.lodestar.lodestone.mixin", "compatibilityLevel": "JAVA_17", + "plugin": "team.lodestar.lodestone.mixin.LodestoneMixinPlugin", "mixins": [ + "client.integration.sodium.SodiumWorldRendererMixin", "common.BlockItemMixin", "common.EntityMixin", "common.ItemEntityMixin", @@ -27,7 +29,8 @@ "client.MultiPlayerGameModeMixin", "client.ParticleEngineMixin", "client.ScreenEffectRendererMixin", - "client.ShaderInstanceMixin" + "client.ShaderInstanceMixin", + "client.integration.notsodium.LevelRendererMixin" ], "injectors": { "defaultRequire": 1