Skip to content

Commit

Permalink
Actually fixed now
Browse files Browse the repository at this point in the history
  • Loading branch information
MineGame159 committed Aug 6, 2023
1 parent e2a3dc4 commit bb14113
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ private void onInit(CallbackInfo info) {
ambience = Modules.get().get(Ambience.class);
}

@ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getGrassColorAt(DD)I"))
@ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getGrassColorAt(DD)I", remap = true))
private int modify_getGrassColorAt(int color) {
return ambience.isActive() && ambience.customGrassColor.get() ? ambience.grassColor.get().getPacked() : color;
}

@ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getFoliageColor()I"))
@ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getFoliageColor()I", remap = true))
private int modify_getFoliageColor(int color) {
return ambience.isActive() && ambience.customFoliageColor.get() ? ambience.foliageColor.get().getPacked() : color;
}

@ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getWaterColor()I"))
@ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getWaterColor()I", remap = true))
private int modify_getWaterColor(int color) {
return ambience.isActive() && ambience.customWaterColor.get() ? ambience.waterColor.get().getPacked() : color;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,21 @@

package meteordevelopment.meteorclient.mixin.sodium;

import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
import me.jellysquid.mods.sodium.client.model.quad.BakedQuadView;
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadOrientation;
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers;
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder;
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext;
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer;
import me.jellysquid.mods.sodium.client.render.chunk.terrain.material.Material;
import me.jellysquid.mods.sodium.client.render.chunk.vertex.format.ChunkVertexEncoder;
import meteordevelopment.meteorclient.systems.modules.render.Xray;
import net.caffeinemc.mods.sodium.api.util.ColorABGR;
import net.minecraft.util.math.Vec3d;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
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;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(value = BlockRenderer.class, remap = false)
public class SodiumBlockRendererMixin {
@Unique
private final ThreadLocal<Integer> alphas = new ThreadLocal<>();

@Inject(method = "renderModel", at = @At("HEAD"), cancellable = true)
private void onRenderModel(BlockRenderContext ctx, ChunkBuildBuffers buffers, CallbackInfo info) {
int alpha = Xray.getAlpha(ctx.state(), ctx.pos());

if (alpha == 0) info.cancel();
else alphas.set(alpha);
}


@Inject(method = "writeGeometry", at = @At(value = "FIELD", target = "Lme/jellysquid/mods/sodium/client/render/chunk/vertex/format/ChunkVertexEncoder$Vertex;color:I", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
private void setColor(BlockRenderContext ctx, ChunkModelBuilder builder, Vec3d offset, Material material, BakedQuadView quad, int[] colors, QuadLightData light, CallbackInfo info, ModelQuadOrientation orientation, ChunkVertexEncoder.Vertex[] vertices, ModelQuadFacing normalFace, int dstIndex, int srcIndex, ChunkVertexEncoder.Vertex out) {
int alpha = alphas.get();

if (alpha == 0) info.cancel();
else if (alpha != -1) out.color = ColorABGR.withAlpha(out.color, alpha);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public class SodiumFluidRendererMixin {
@Unique
private Ambience ambience;

@Unique
private final ThreadLocal<Integer> alphas = new ThreadLocal<>();

@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
ambience = Modules.get().get(Ambience.class);
Expand All @@ -50,7 +47,6 @@ private void onRender(WorldSlice world, FluidState fluidState, BlockPos blockPos
int alpha = Xray.getAlpha(fluidState.getBlockState(), blockPos);

if (alpha == 0) info.cancel();
else alphas.set(alpha);
}

@Inject(method = "updateQuad", at = @At("TAIL"))
Expand All @@ -59,13 +55,5 @@ private void onUpdateQuad(ModelQuadView quad, WorldSlice world, BlockPos pos, Li
if (ambience.isActive() && ambience.customLavaColor.get() && fluidState.isIn(FluidTags.LAVA)) {
Arrays.fill(quadColors, ColorABGR.withAlpha(ambience.lavaColor.get().getPacked(), 255));
}
else {
// XRay and Wallhack
int alpha = alphas.get();

for (int i = 0; i < quadColors.length; i++) {
quadColors[i] = ColorABGR.withAlpha(quadColors[i], alpha / 255f);
}
}
}
}

0 comments on commit bb14113

Please sign in to comment.