diff --git a/src/main/java/shit/zen/ZenClient.java b/src/main/java/shit/zen/ZenClient.java index df4e836..8b21eb6 100644 --- a/src/main/java/shit/zen/ZenClient.java +++ b/src/main/java/shit/zen/ZenClient.java @@ -22,6 +22,7 @@ import shit.zen.manager.HudManager; import shit.zen.manager.LagManager; import shit.zen.manager.ModuleManager; import shit.zen.manager.TargetManager; +import shit.zen.patch.BlockPatch; import shit.zen.patch.ChatScreenPatch; import shit.zen.patch.ClientLevelPatch; import shit.zen.patch.ConnectionPatch; @@ -199,6 +200,7 @@ public class ZenClient extends ClientBase { PatchRegistry.register(ChatScreenPatch.class); PatchRegistry.register(EntityRendererPatch.class); PatchRegistry.register(LevelRendererPatch.class); + PatchRegistry.register(BlockPatch.class); PatchRegistry.register(GameRendererPatch.class); PatchRegistry.register(ItemInHandRendererPatch.class); PatchRegistry.register(ItemInHandLayerPatch.class); diff --git a/src/main/java/shit/zen/modules/impl/render/XRay.java b/src/main/java/shit/zen/modules/impl/render/XRay.java index 650b565..24705e7 100644 --- a/src/main/java/shit/zen/modules/impl/render/XRay.java +++ b/src/main/java/shit/zen/modules/impl/render/XRay.java @@ -1,13 +1,1125 @@ package shit.zen.modules.impl.render; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.BufferUploader; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.VertexFormat; +import java.awt.Color; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadPoolExecutor; +import net.minecraft.ChatFormatting; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; +import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.joml.Matrix4f; +import org.joml.Vector3f; +import org.joml.Vector4f; +import shit.zen.ZenClient; +import shit.zen.event.EventTarget; +import shit.zen.event.impl.GameTickEvent; +import shit.zen.event.impl.PacketEvent; +import shit.zen.event.impl.Render2DEvent; +import shit.zen.event.impl.RenderEvent; import shit.zen.modules.Category; import shit.zen.modules.Module; +import shit.zen.settings.impl.BooleanSetting; +import shit.zen.settings.impl.ModeSetting; +import shit.zen.settings.impl.NumberSetting; +import lombok.EqualsAndHashCode; +import shit.zen.utils.game.PlayerUtil; +import shit.zen.utils.misc.ChatUtil; +/** + * XRay — ore locator with two visual layers: + *
{@code Block.shouldRenderFace} is the vanilla face-culling decision evaluated for every block + * face while chunk meshes are built. We hook it at HEAD: when the {@link XRay} module is enabled we + * force the result so that only XRay target blocks render (all faces, hence visible through walls) + * and every other block renders no faces at all (it becomes invisible). When XRay is disabled we + * fall through untouched, leaving vanilla culling intact. + * + *
Toggling the module calls {@code mc.levelRenderer.allChanged()} (see {@link XRay#onEnable()}/ + * {@link XRay#onDisable()}), which rebuilds every chunk mesh so this decision is re-evaluated and + * the effect applies/clears immediately. + * + *
The mojmap {@code method}/{@code desc} below are remapped to the runtime SRG name + * ({@code m_152444_}) by {@code Bootstrap.remapMethod}, exactly like the other patches. + */ +@Patch(Block.class) +public class BlockPatch { + @Inject( + method = "shouldRenderFace", + desc = "(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;Lnet/minecraft/core/BlockPos;)Z", + at = @At(At.Type.HEAD) + ) + public static void onShouldRenderFace(BlockState state, BlockGetter level, BlockPos pos, + Direction direction, BlockPos neighborPos, + CallbackInfo callbackInfo) { + XRay xray = XRay.INSTANCE; + if (xray == null || !xray.isEnabled()) { + return; // module off -> keep vanilla face culling, game renders normally + } + callbackInfo.result = xray.isXrayVisible(state.getBlock()) ? Boolean.TRUE : Boolean.FALSE; + callbackInfo.cancel(); + } +}