Skip to content

Commit

Permalink
Fix xray with indium
Browse files Browse the repository at this point in the history
  • Loading branch information
Wide-Cat committed Sep 8, 2023
1 parent 74deeea commit c8cf97a
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies {
modCompileOnly("maven.modrinth:lithium:${project.lithium_version}") { transitive = false }
modCompileOnly("maven.modrinth:iris:${project.iris_version}") { transitive = false }
//modCompileOnly("io.vram:canvas-fabric-mc119:1.0.+") { transitive = false } // TODO: 1.19.3
modCompileOnly("maven.modrinth:indium:${project.indium_version}") { transitive = false }

// Baritone (https://github.com/MeteorDevelopment/baritone)
modInclude "baritone:fabric:${project.minecraft_version}-SNAPSHOT"
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ netty_version=4.1.90.Final

# Mixin Extras (https://github.com/LlamaLad7/MixinExtras)
mixin_extras_version=0.2.0-beta.8

# Indium (https://github.com/comp500/Indium)
indium_version=1.0.25+mc1.20.1
5 changes: 5 additions & 0 deletions src/main/java/meteordevelopment/meteorclient/MixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class MixinPlugin implements IMixinConfigPlugin {
private static boolean isCanvasPresent;
private static boolean isLithiumPresent;
public static boolean isIrisPresent;
private static boolean isIndiumPresent;

@Override
public void onLoad(String mixinPackage) {
Expand Down Expand Up @@ -72,6 +73,7 @@ public void onLoad(String mixinPackage) {
isCanvasPresent = FabricLoader.getInstance().isModLoaded("canvas");
isLithiumPresent = FabricLoader.getInstance().isModLoaded("lithium");
isIrisPresent = FabricLoader.getInstance().isModLoaded("iris");
isIndiumPresent = FabricLoader.getInstance().isModLoaded("indium");

loaded = true;
}
Expand Down Expand Up @@ -101,6 +103,9 @@ else if (mixinClassName.startsWith(mixinPackage + ".canvas")) {
else if (mixinClassName.startsWith(mixinPackage + ".lithium")) {
return isLithiumPresent;
}
else if (mixinClassName.startsWith(mixinPackage + ".indium")) {
return isIndiumPresent;
}


return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -32,6 +33,7 @@ else if (alpha != -1) {
}
}

@Unique
private int rewriteQuadAlpha(int color, int alpha) {
return ((alpha & 0xFF) << 24) | (color & 0x00FFFFFF);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin.indium;

import link.infra.indium.renderer.mesh.MutableQuadViewImpl;
import link.infra.indium.renderer.render.AbstractBlockRenderContext;
import link.infra.indium.renderer.render.BlockRenderInfo;
import meteordevelopment.meteorclient.systems.modules.render.Xray;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = AbstractBlockRenderContext.class, remap = false)
public class BakedModelConsumerImplMixin {
@Shadow
protected BlockRenderInfo blockInfo;

@Inject(method = "renderQuad(Llink/infra/indium/renderer/mesh/MutableQuadViewImpl;Z)V", at = @At(value = "INVOKE", target = "Llink/infra/indium/renderer/render/AbstractBlockRenderContext;bufferQuad(Llink/infra/indium/renderer/mesh/MutableQuadViewImpl;Lme/jellysquid/mods/sodium/client/render/chunk/terrain/material/Material;)V"), cancellable = true)
private void onBufferQuad(MutableQuadViewImpl quad, boolean isVanilla, CallbackInfo ci) {
int alpha = Xray.getAlpha(blockInfo.blockState, blockInfo.blockPos);

if (alpha == 0) ci.cancel();
}
}
3 changes: 2 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"meteor-client-indigo.mixins.json",
"meteor-client-sodium.mixins.json",
"meteor-client-canvas.mixins.json",
"meteor-client-lithium.mixins.json"
"meteor-client-lithium.mixins.json",
"meteor-client-indium.mixins.json"
],
"accessWidener": "meteor-client.accesswidener",
"custom": {
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/meteor-client-indium.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"required": true,
"package": "meteordevelopment.meteorclient.mixin.indium",
"compatibilityLevel": "JAVA_17",
"plugin": "meteordevelopment.meteorclient.MixinPlugin",
"client": [
"BakedModelConsumerImplMixin"
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit c8cf97a

Please sign in to comment.