Skip to content

Commit

Permalink
fixed sodium compat
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsterner committed Jun 13, 2024
1 parent 2f4df58 commit ba05337
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 7 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")}")
}

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 = \
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> myTargets, Set<String> otherTargets) {

}

@Override
public List<String> 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) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
5 changes: 4 additions & 1 deletion src/main/resources/lodestone.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -27,7 +29,8 @@
"client.MultiPlayerGameModeMixin",
"client.ParticleEngineMixin",
"client.ScreenEffectRendererMixin",
"client.ShaderInstanceMixin"
"client.ShaderInstanceMixin",
"client.integration.notsodium.LevelRendererMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit ba05337

Please sign in to comment.