Skip to content

Commit

Permalink
Mixin fixes pt 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Moondarker committed Feb 29, 2024
1 parent 8623f53 commit e9332bc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AbstractBlockRenderContextMixin {
@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)
@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;Lnet/minecraft/client/render/RenderLayer;)V"), cancellable = true)
private void onBufferQuad(MutableQuadViewImpl quad, boolean isVanilla, CallbackInfo ci) {
int alpha = Xray.getAlpha(blockInfo.blockState, blockInfo.blockPos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,14 @@
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
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;

@Mixin(value = BlockOcclusionCache.class, remap = false)
public class SodiumBlockOcclusionCacheMixin {
@Unique
private Xray xray;

@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
xray = Modules.get().get(Xray.class);
}

@ModifyReturnValue(method = "shouldDrawSide", at = @At("RETURN"))
private boolean shouldDrawSide(boolean original, BlockState state, BlockView view, BlockPos pos, Direction facing) {
Xray xray = Modules.get().get(Xray.class);

if (xray.isActive()) {
return xray.modifyDrawSide(state, view, pos, facing, original);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
@Mixin(value = LightDataAccess.class, remap = false)
public class SodiumLightDataAccessMixin {
@Unique
private static final int FULL_LIGHT = 15 | 15 << 4 | 15 << 8;
private static final int BLOCK_OFFSET = 4;
@Unique
private static final int SKY_OFFSET = 20;
@Unique
private static final int FULL_LIGHT = 15 << BLOCK_OFFSET;

@Shadow
protected BlockRenderView world;
Expand All @@ -44,25 +48,26 @@ private void onInit(CallbackInfo info) {
fb = Modules.get().get(Fullbright.class);
}

@ModifyVariable(method = "compute", at = @At(value = "TAIL"), name = "bl")
private int compute_modifyBL(int light) {
@ModifyVariable(method = "compute", at = @At(value = "TAIL"), name = "lm")
private int compute_modifyLM(int lm) {
if (xray.isActive()) {
BlockState state = world.getBlockState(pos);
if (!xray.isBlocked(state.getBlock(), pos)) return FULL_LIGHT;
if (!xray.isBlocked(state.getBlock(), pos)) return lm | FULL_LIGHT;
}

return light;
return lm;
}

// fullbright

@ModifyVariable(method = "compute", at = @At(value = "STORE"), name = "sl")
private int compute_assignSL(int sl) {
return Math.max(fb.getLuminance(LightType.SKY), sl);
}
@ModifyVariable(method = "compute", at = @At(value = "STORE"), name = "lm")
private int compute_assignLM(int lm) {
if (fb.isActive()) {
int sl = Math.max(fb.getLuminance(LightType.SKY), lm >> SKY_OFFSET);
int bl = Math.max(fb.getLuminance(LightType.BLOCK), (lm >> BLOCK_OFFSET) & 0xFF);
return sl << SKY_OFFSET | bl << BLOCK_OFFSET;
}

@ModifyVariable(method = "compute", at = @At(value = "STORE"), name = "bl")
private int compute_assignBL(int bl) {
return Math.max(fb.getLuminance(LightType.BLOCK), bl);
return lm;
}
}

0 comments on commit e9332bc

Please sign in to comment.