Skip to content

Commit

Permalink
fullbright luminance mode - fixes and new setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wide-Cat committed Oct 23, 2023
1 parent f0438f7 commit 7b011fb
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.world.LightType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -51,7 +52,12 @@ private void shouldRender(T entity, Frustum frustum, double x, double y, double

@ModifyReturnValue(method = "getSkyLight", at = @At("RETURN"))
private int onGetSkyLight(int original) {
return Math.max(Modules.get().get(Fullbright.class).getLuminance(), original);
return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.SKY), original);
}

@ModifyReturnValue(method = "getBlockLight", at = @At("RETURN"))
private int onGetBlockLight(int original) {
return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.BLOCK), original);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.LightType;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -127,6 +128,11 @@ private void onRenderEndSkyDraw(MatrixStack matrices, CallbackInfo info) {

@ModifyVariable(method = "getLightmapCoordinates(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "STORE"), ordinal = 0)
private static int getLightmapCoordinatesModifySkyLight(int sky) {
return Math.max(Modules.get().get(Fullbright.class).getLuminance(), sky);
return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.SKY), sky);
}

@ModifyVariable(method = "getLightmapCoordinates(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "STORE"), ordinal = 1)
private static int getLightmapCoordinatesModifyBlockLight(int sky) {
return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.BLOCK), sky);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin.indigo;

import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.Fullbright;
import net.fabricmc.fabric.impl.client.indigo.renderer.aocalc.AoCalculator;
import net.minecraft.world.LightType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(AoCalculator.class)
public class AoCalculatorMixin {
@ModifyVariable(method = "getLightmapCoordinates(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "STORE"), ordinal = 0)
private static int getLightmapCoordinatesModifySkyLight(int sky) {
return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.SKY), sky);
}

@ModifyVariable(method = "getLightmapCoordinates(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "STORE"), ordinal = 1)
private static int getLightmapCoordinatesModifyBlockLight(int sky) {
return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.BLOCK), sky);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.LightType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -34,9 +35,13 @@ public class SodiumLightDataAccessMixin {
@Unique
private Xray xray;

@Unique
private Fullbright fb;

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

@ModifyVariable(method = "compute", at = @At(value = "TAIL"), name = "bl")
Expand All @@ -49,8 +54,15 @@ private int compute_modifyBL(int light) {
return light;
}

@ModifyVariable(method = "compute", at = @At(value = "TAIL"), name = "sl")
private int compute_modifySL(int light) {
return Math.max(Modules.get().get(Fullbright.class).getLuminance(), light);
// 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 = "bl")
private int compute_assignBL(int bl) {
return Math.max(fb.getLuminance(LightType.BLOCK), bl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import net.minecraft.world.LightType;

public class Fullbright extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup();
Expand All @@ -22,6 +23,17 @@ public class Fullbright extends Module {
.build()
);

public final Setting<LightType> lightType = sgGeneral.add(new EnumSetting.Builder<LightType>()
.name("light-type")
.description("Which type of light to use for Luminance mode.")
.defaultValue(LightType.BLOCK)
.visible(() -> mode.get() == Mode.Luminance)
.onChanged(integer -> {
if (mc.worldRenderer != null && isActive()) mc.worldRenderer.reload();
})
.build()
);

private final Setting<Integer> minimumLightLevel = sgGeneral.add(new IntSetting.Builder()
.name("minimum-light-level")
.description("Minimum light level when using Luminance mode.")
Expand All @@ -30,7 +42,7 @@ public class Fullbright extends Module {
.range(0, 15)
.sliderMax(15)
.onChanged(integer -> {
if (mc.worldRenderer != null) mc.worldRenderer.reload();
if (mc.worldRenderer != null && isActive()) mc.worldRenderer.reload();
})
.build()
);
Expand All @@ -49,8 +61,8 @@ public void onDeactivate() {
if (mode.get() == Mode.Luminance) mc.worldRenderer.reload();
}

public int getLuminance() {
if (!isActive() || mode.get() != Mode.Luminance) return 0;
public int getLuminance(LightType type) {
if (!isActive() || mode.get() != Mode.Luminance || type != lightType.get()) return 0;
return minimumLightLevel.get();
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/meteor-client-indigo.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"compatibilityLevel": "JAVA_17",
"plugin": "meteordevelopment.meteorclient.MixinPlugin",
"client": [
"AbstractBlockRenderContextMixin"
"AbstractBlockRenderContextMixin",
"AoCalculatorMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 7b011fb

Please sign in to comment.