From 7741cd8a909da537af7db153e5288096306210e5 Mon Sep 17 00:00:00 2001 From: noramibu <50046813+noramibu@users.noreply.github.com> Date: Sat, 24 Jan 2026 18:38:50 +0300 Subject: [PATCH] BadOptimizations and More Culling compatibility for Xray and Fullbright modules --- .../meteorclient/mixin/BlockMixin.java | 17 ++++++++++ .../SodiumBlockOcclusionCacheMixin.java | 10 ++++++ .../modintegration/BadOptimizationsHook.java | 31 +++++++++++++++++++ .../ModMenuIntegration.java | 2 +- src/main/resources/fabric.mod.json | 5 ++- 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/main/java/meteordevelopment/meteorclient/modintegration/BadOptimizationsHook.java rename src/main/java/meteordevelopment/meteorclient/{ => modintegration}/ModMenuIntegration.java (91%) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BlockMixin.java index 29d18c9ce6..119b58039f 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BlockMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BlockMixin.java @@ -9,12 +9,17 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; import meteordevelopment.meteorclient.systems.modules.movement.Slippy; +import meteordevelopment.meteorclient.systems.modules.render.Xray; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.item.ItemConvertible; +import net.minecraft.util.math.Direction; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Block.class) public abstract class BlockMixin extends AbstractBlock implements ItemConvertible { @@ -37,4 +42,16 @@ public float getSlipperiness(float original) { if (block == Blocks.SLIME_BLOCK && Modules.get().get(NoSlow.class).slimeBlock()) return 0.6F; else return original; } + + // For More Culling compatibility - runs before More Culling's inject to force-render whitelisted Xray blocks + @Inject(method = "shouldDrawSide", at = @At("HEAD"), cancellable = true) + private static void meteor$forceXrayFace(BlockState state, BlockState sideState, Direction side, CallbackInfoReturnable cir) { + Modules modules = Modules.get(); + if (modules == null) return; + + Xray xray = modules.get(Xray.class); + if (xray.isActive() && !xray.isBlocked(state.getBlock(), null)) { + cir.setReturnValue(true); + } + } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBlockOcclusionCacheMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBlockOcclusionCacheMixin.java index 9c34df0b5b..7151983142 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBlockOcclusionCacheMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBlockOcclusionCacheMixin.java @@ -18,6 +18,7 @@ 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.CallbackInfoReturnable; @Mixin(value = BlockOcclusionCache.class, remap = false) public abstract class SodiumBlockOcclusionCacheMixin { @@ -29,6 +30,15 @@ private void onInit(CallbackInfo info) { xray = Modules.get().get(Xray.class); } + // For More Culling compatibility - runs before More Culling's inject to force-render whitelisted Xray blocks + @Inject(method = "shouldDrawSide", at = @At("HEAD"), cancellable = true) + private void meteor$forceXrayFace(BlockState state, BlockView view, BlockPos pos, Direction facing, + CallbackInfoReturnable cir) { + if (xray != null && xray.isActive() && !xray.isBlocked(state.getBlock(), null)) { + cir.setReturnValue(true); + } + } + @ModifyReturnValue(method = "shouldDrawSide", at = @At("RETURN")) private boolean shouldDrawSide(boolean original, BlockState state, BlockView view, BlockPos pos, Direction facing) { if (xray.isActive()) { diff --git a/src/main/java/meteordevelopment/meteorclient/modintegration/BadOptimizationsHook.java b/src/main/java/meteordevelopment/meteorclient/modintegration/BadOptimizationsHook.java new file mode 100644 index 0000000000..0f39acb48b --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/modintegration/BadOptimizationsHook.java @@ -0,0 +1,31 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.modintegration; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.Fullbright; +import meteordevelopment.meteorclient.systems.modules.render.Xray; + +import java.util.function.BooleanSupplier; + +/* + * Hook for BadOptimizations mod compatibility. + * Signals when the lightmap needs to be updated due to Fullbright or Xray state changes. + */ +public class BadOptimizationsHook implements BooleanSupplier { + private int lastState; + + @Override + public boolean getAsBoolean() { + Modules m = Modules.get(); + if (m == null) return false; + + int state = (m.get(Fullbright.class).getGamma() ? 1 : 0) | (m.isActive(Xray.class) ? 2 : 0); + boolean changed = state != lastState; + lastState = state; + return changed; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/ModMenuIntegration.java b/src/main/java/meteordevelopment/meteorclient/modintegration/ModMenuIntegration.java similarity index 91% rename from src/main/java/meteordevelopment/meteorclient/ModMenuIntegration.java rename to src/main/java/meteordevelopment/meteorclient/modintegration/ModMenuIntegration.java index b33b181080..3e6783c004 100644 --- a/src/main/java/meteordevelopment/meteorclient/ModMenuIntegration.java +++ b/src/main/java/meteordevelopment/meteorclient/modintegration/ModMenuIntegration.java @@ -3,7 +3,7 @@ * Copyright (c) Meteor Development. */ -package meteordevelopment.meteorclient; +package meteordevelopment.meteorclient.modintegration; import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0f5f204d16..bd5b41ef5b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,7 +23,7 @@ "meteordevelopment.meteorclient.MeteorClient" ], "modmenu": [ - "meteordevelopment.meteorclient.ModMenuIntegration" + "meteordevelopment.meteorclient.modintegration.ModMenuIntegration" ] }, "mixins": [ @@ -43,6 +43,9 @@ "links": { "modmenu.discord": "https://meteorclient.com/discord" } + }, + "badoptimizations:cache_hooks": { + "lightmap": "meteordevelopment.meteorclient.modintegration.BadOptimizationsHook" } }, "depends": {