Skip to content

Commit a07d7ac

Browse files
authored
Fix: Make Sodium optional with new fabric loader, and make no fog and Voxy work together (#347)
1 parent 2d08eb6 commit a07d7ac

3 files changed

Lines changed: 63 additions & 1 deletion

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2026 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin;
19+
20+
import net.fabricmc.loader.api.FabricLoader;
21+
import org.objectweb.asm.tree.ClassNode;
22+
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
23+
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
24+
25+
import java.util.List;
26+
import java.util.Set;
27+
28+
public class OptionalModMixinPlugin implements IMixinConfigPlugin {
29+
@Override
30+
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
31+
if (targetClassName.startsWith("net.caffeinemc.mods.sodium.")) {
32+
return FabricLoader.getInstance().isModLoaded("sodium");
33+
}
34+
if (targetClassName.startsWith("net.fabricmc.fabric.impl.client.indigo.")) {
35+
return FabricLoader.getInstance().isModLoaded("fabric-renderer-indigo");
36+
}
37+
return true;
38+
}
39+
40+
@Override
41+
public void onLoad(String mixinPackage) {}
42+
43+
@Override
44+
public String getRefMapperConfig() {
45+
return null;
46+
}
47+
48+
@Override
49+
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {}
50+
51+
@Override
52+
public List<String> getMixins() {
53+
return null;
54+
}
55+
56+
@Override
57+
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
58+
59+
@Override
60+
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
61+
}

‎src/main/java/com/lambda/mixin/render/SodiumWorldRendererMixin.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
@Mixin(SodiumWorldRenderer.class)
3030
public class SodiumWorldRendererMixin {
3131
@Unique
32-
private final FogParameters NO_FOG = new FogParameters(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f);
32+
private final FogParameters NO_FOG = new FogParameters(0f, 0f, 0f, 0f, Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
3333

3434
@ModifyExpressionValue(method = "drawChunkLayer(Lnet/minecraft/client/render/BlockRenderLayerGroup;Lnet/caffeinemc/mods/sodium/client/render/chunk/ChunkRenderMatrices;DDDLnet/minecraft/client/gl/GpuSampler;)V", at = @At(value = "FIELD", target = "Lnet/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer;lastFogParameters:Lnet/caffeinemc/mods/sodium/client/util/FogParameters;", opcode = Opcodes.GETFIELD))
3535
private FogParameters modifyFogParameters(FogParameters original) {

‎src/main/resources/lambda.mixins.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"required": true,
33
"minVersion": "0.8",
44
"package": "com.lambda.mixin",
5+
"plugin": "com.lambda.mixin.OptionalModMixinPlugin",
56
"compatibilityLevel": "JAVA_21",
67
"client": [
78
"CrashReportMixin",

0 commit comments

Comments
 (0)