From 4c4500388c04bd3e813b6c5484256321e0e21e03 Mon Sep 17 00:00:00 2001 From: 1zuna <1zuna@ccbluex.net> Date: Mon, 9 Sep 2024 07:18:59 +0200 Subject: [PATCH] feat: block outline changer (#3910) --- .../minecraft/render/MixinWorldRenderer.java | 37 +++++++++++++++++++ .../features/module/ModuleManager.kt | 1 + .../modules/render/ModuleBlockOutline.kt | 34 +++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBlockOutline.kt diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWorldRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWorldRenderer.java index 4722041c49d..308831b8c5a 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWorldRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWorldRenderer.java @@ -44,6 +44,7 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; import static org.lwjgl.opengl.GL11.*; @@ -295,4 +296,40 @@ private float removeRainSplashing(float original) { return original; } + + @ModifyArgs( + method = "drawBlockOutline", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/render/WorldRenderer;drawCuboidShapeOutline(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/util/shape/VoxelShape;DDDFFFF)V" + ) + ) + private void modifyBlockOutlineArgs(Args args) { + // args: MatrixStack matrices, + // VertexConsumer vertexConsumer, + // VoxelShape shape, + // double offsetX, + // double offsetY, + // double offsetZ, + // float red, + // float green, + // float blue, + // float alpha + + if (!ModuleBlockOutline.INSTANCE.getEnabled()) { + return; + } + + var color = ModuleBlockOutline.INSTANCE.getOutlineColor(); + var red = color.getR() / 255f; + var green = color.getG() / 255f; + var blue = color.getB() / 255f; + var alpha = color.getA() / 255f; + + args.set(6, red); + args.set(7, green); + args.set(8, blue); + args.set(9, alpha); + } + } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt index e643c720eed..8bf9eb2cb48 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt @@ -234,6 +234,7 @@ object ModuleManager : Listenable, Iterable by modules { ModuleAnimations, ModuleAntiBlind, ModuleBlockESP, + ModuleBlockOutline, ModuleBreadcrumbs, ModuleCameraClip, ModuleClickGui, diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBlockOutline.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBlockOutline.kt new file mode 100644 index 00000000000..95b06242f5e --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBlockOutline.kt @@ -0,0 +1,34 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 CCBlueX + * + * LiquidBounce is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * LiquidBounce is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LiquidBounce. If not, see . + */ +package net.ccbluex.liquidbounce.features.module.modules.render + +import net.ccbluex.liquidbounce.features.module.Category +import net.ccbluex.liquidbounce.features.module.Module +import net.ccbluex.liquidbounce.render.engine.Color4b + +/** + * Block Outline module + * + * Changes the way Minecraft highlights blocks. + * + * TODO: Implement Block Side Box and GUI Information Panel + */ +object ModuleBlockOutline : Module("BlockOutline", Category.RENDER, aliases = arrayOf("BlockOverlay")) { + val outlineColor by color("Outline", Color4b(68, 117, 255, 102)) +}