LiquidBounce (Kotlin)

LiquidBounce (Kotlin) modules for Minecraft 26.2: 238 modules across 8 categories, each with its complete source file.

Minecraft 26.2238 modulesKotlin175 mixins

Mixins (175)

Every mixin LiquidBounce (Kotlin) ships, complete and verbatim, with the vanilla classes it modifies. Target links open that class in the site source browser.

MixinMinecraftClientsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/authlib/MixinMinecraftClient.javaJava · 75 lines · 2.8 KB
@Mixin(value = MinecraftClient.class, remap = false)remap=false
ModifiesMinecraftClient not in 26.3
MixinMinecraftClient.javaJava · 75 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.authlib;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.mojang.authlib.minecraft.client.MinecraftClient;
23
import net.ccbluex.liquidbounce.features.misc.proxy.ProxyManager;
24
import net.minecraft.client.Minecraft;
25
import net.minecraft.client.gui.screens.ConnectScreen;
26
import org.objectweb.asm.Opcodes;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
30
import java.net.Authenticator;
31
import java.net.PasswordAuthentication;
32
import java.net.Proxy;
33
34
@Mixin(value = MinecraftClient.class, remap = false)
35
public abstract class MixinMinecraftClient {
36
37
    @ModifyExpressionValue(method = "createUrlConnection", at = @At(
38
        value = "FIELD",
39
        target = "Lcom/mojang/authlib/minecraft/client/MinecraftClient;proxy:Ljava/net/Proxy;",
40
        remap = false,
41
        opcode = Opcodes.GETFIELD))
42
    private Proxy hookClientProxy(Proxy proxy) {
43
        // We only want to use the proxy when connecting to a server
44
        // Can be null on init stage
45
        if (!(Minecraft.getInstance().gui != null && Minecraft.getInstance().gui.screen() instanceof ConnectScreen)) {
46
            return Proxy.NO_PROXY;
47
        }
48
49
        var currentProxy = ProxyManager.INSTANCE.getCurrentProxy();
50
        if (currentProxy != null && currentProxy.getForwardAuthentication()) {
51
            var credentials = currentProxy.getCredentials();
52
53
            if (credentials != null) {
54
                Authenticator.setDefault(new Authenticator() {
55
                    @Override
56
                    public PasswordAuthentication getPasswordAuthentication() {
57
                        return new PasswordAuthentication(
58
                                credentials.getUsername(),
59
                                credentials.getPassword().toCharArray()
60
                        );
61
                    }
62
                });
63
            }
64
65
            return new Proxy(
66
                    Proxy.Type.SOCKS,
67
                    currentProxy.getAddress()
68
            );
69
        }
70
71
        return Proxy.NO_PROXY;
72
    }
73
74
}
75
MixinYggdrasilMinecraftSessionServicesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/authlib/MixinYggdrasilMinecraftSessionService.javaJava · 88 lines · 3.5 KB
@Mixin(YggdrasilMinecraftSessionService.class)
ModifiesYggdrasilMinecraftSessionService not in 26.3
MixinYggdrasilMinecraftSessionService.javaJava · 88 lines · 3.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.authlib;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import com.mojang.authlib.SignatureState;
25
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
26
import com.mojang.authlib.minecraft.MinecraftProfileTextures;
27
import com.mojang.authlib.properties.Property;
28
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
29
import net.ccbluex.liquidbounce.features.module.modules.exploit.ModuleYggdrasilSignatureFix;
30
import net.minecraft.world.entity.player.PlayerModelType;
31
import org.spongepowered.asm.mixin.Mixin;
32
import org.spongepowered.asm.mixin.injection.At;
33
import org.spongepowered.asm.mixin.injection.Inject;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
35
36
import java.util.Map;
37
38
@Mixin(YggdrasilMinecraftSessionService.class)
39
40
public abstract class MixinYggdrasilMinecraftSessionService {
41
    @Inject(
42
            method = "getPropertySignatureState",
43
            at = @At("HEAD"),
44
            cancellable = true,
45
            remap = false
46
    )
47
    private void bypassSignature(Property property, CallbackInfoReturnable<SignatureState> cir) {
48
        if (ModuleYggdrasilSignatureFix.INSTANCE.getRunning()) {
49
            cir.setReturnValue(SignatureState.SIGNED);
50
        }
51
    }
52
53
    @WrapOperation(
54
            method = "unpackTextures",
55
            at = @At(
56
                    value = "INVOKE",
57
                    target = "Lcom/mojang/authlib/yggdrasil/TextureUrlChecker;isAllowedTextureDomain(Ljava/lang/String;)Z"
58
            ),
59
            remap = false
60
    )
61
    private boolean bypassUrlCheck(String url, Operation<Boolean> original) {
62
        return ModuleYggdrasilSignatureFix.INSTANCE.getRunning() || original.call(url);
63
    }
64
65
66
    @Inject(method = "unpackTextures", at = @At("RETURN"), cancellable = true, remap = false)
67
    private void onUnpackTexturesReturn(Property packedTextures, CallbackInfoReturnable<MinecraftProfileTextures> cir) {
68
        if (!ModuleYggdrasilSignatureFix.INSTANCE.getRunning() || !ModuleYggdrasilSignatureFix.INSTANCE.getForceSlimModel())
69
            return;
70
71
        MinecraftProfileTextures original = cir.getReturnValue();
72
        if (original == null || original == MinecraftProfileTextures.EMPTY || original.skin() == null) return;
73
74
        String url = original.skin().getUrl();
75
        if (!url.contains("127.0.0.1")) return;
76
77
        MinecraftProfileTextures forced = new MinecraftProfileTextures(
78
                new MinecraftProfileTexture(url, Map.of("model", PlayerModelType.SLIM.getSerializedName())),
79
                original.cape(),
80
                original.elytra(),
81
                original.signatureState()
82
        );
83
84
        cir.setReturnValue(forced);
85
    }
86
87
}
88
MixinYggdrasilMinecraftSessionServiceAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/authlib/MixinYggdrasilMinecraftSessionServiceAccessor.javaJava · 31 lines · 1.1 KB
@Mixin(YggdrasilMinecraftSessionService.class)
ModifiesYggdrasilMinecraftSessionService not in 26.3
MixinYggdrasilMinecraftSessionServiceAccessor.javaJava · 31 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.authlib;
21
22
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.gen.Accessor;
25
26
@Mixin(YggdrasilMinecraftSessionService.class)
27
public interface MixinYggdrasilMinecraftSessionServiceAccessor {
28
    @Accessor(remap = false)
29
    String getBaseUrl();
30
}
31
MixinGLXsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/blaze3d/MixinGLX.javaJava · 40 lines · 1.6 KB
@Mixin(GLX.class)
ModifiesGLX not in 26.3
MixinGLX.javaJava · 40 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.blaze3d;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.mojang.blaze3d.platform.GLX;
24
import net.ccbluex.liquidbounce.integration.backend.BrowserBackendManagerKt;
25
import org.objectweb.asm.Opcodes;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
29
@Mixin(GLX.class)
30
public abstract class MixinGLX {
31
32
    @ModifyExpressionValue(method = "_initGlfw", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;DEBUG_PREFER_WAYLAND:Z", opcode = Opcodes.GETSTATIC))
33
    private static boolean isWaylandPreferred(boolean original) {
34
        return original || !BrowserBackendManagerKt.isBrowserDisabled()
35
            && !BrowserBackendManagerKt.getBrowserBackend().equalsIgnoreCase("none")
36
            && !BrowserBackendManagerKt.isBrowserAccelerationDisabled();
37
    }
38
39
}
40
MixinRenderPasssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/blaze3d/MixinRenderPass.javaJava · 39 lines · 1.5 KB
@Mixin(RenderPass.class)
ModifiesRenderPass
MixinRenderPass.javaJava · 39 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.blaze3d;
21
22
import com.mojang.blaze3d.systems.RenderPass;
23
import net.ccbluex.liquidbounce.render.utils.RenderingDebug;
24
import org.objectweb.asm.Opcodes;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
30
@Mixin(RenderPass.class)
31
public abstract class MixinRenderPass {
32
33
    @Inject(method = "close", at = @At(value = "FIELD", target = "Lcom/mojang/blaze3d/systems/RenderPass;isClosed:Z", opcode = Opcodes.PUTFIELD))
34
    private void onClose(CallbackInfo callbackInfo) {
35
        RenderingDebug.increaseRenderPassCount();
36
    }
37
38
}
39
MixinWindowsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/blaze3d/MixinWindow.javaJava · 102 lines · 4.0 KB
@Mixin(Window.class)
ModifiesWindow
MixinWindow.javaJava · 102 lines · 4.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.blaze3d;
20
21
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
22
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
23
import com.mojang.blaze3d.platform.IconSet;
24
import com.mojang.blaze3d.platform.Window;
25
import net.ccbluex.liquidbounce.LiquidBounce;
26
import net.ccbluex.liquidbounce.event.EventManager;
27
import net.ccbluex.liquidbounce.event.events.FramebufferResizeEvent;
28
import net.ccbluex.liquidbounce.event.events.ScaleFactorChangeEvent;
29
import net.ccbluex.liquidbounce.event.events.WindowResizeEvent;
30
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
31
import net.minecraft.server.packs.PackResources;
32
import net.minecraft.server.packs.resources.IoSupplier;
33
import org.spongepowered.asm.mixin.Final;
34
import org.spongepowered.asm.mixin.Mixin;
35
import org.spongepowered.asm.mixin.Shadow;
36
import org.spongepowered.asm.mixin.injection.At;
37
import org.spongepowered.asm.mixin.injection.Inject;
38
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
39
40
import java.io.InputStream;
41
import java.util.List;
42
43
@Mixin(Window.class)
44
public abstract class MixinWindow {
45
46
    @Shadow
47
    @Final
48
    private long handle;
49
50
    /**
51
     * Set the window icon to our client icon.
52
     *
53
     * @return modified game icon
54
     */
55
    @WrapOperation(method = "setIcon", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/IconSet;getStandardIcons(Lnet/minecraft/server/packs/PackResources;)Ljava/util/List;"))
56
    private List<IoSupplier<InputStream>> setupIcon(IconSet instance, PackResources resources,
57
        Operation<List<IoSupplier<InputStream>>> original) {
58
        if (SelfDestruct.INSTANCE.isDestructed()) {
59
            return original.call(instance, resources);
60
        }
61
62
        LiquidBounce.INSTANCE.getLogger().debug("Loading client icons");
63
64
        // Find client icons
65
        final InputStream stream16 = LiquidBounce.class.getResourceAsStream("/resources/liquidbounce/icon_16x16.png");
66
        final InputStream stream32 = LiquidBounce.class.getResourceAsStream("/resources/liquidbounce/icon_32x32.png");
67
68
        // In case one of the icons was not found
69
        if (stream16 == null || stream32 == null) {
70
            LiquidBounce.INSTANCE.getLogger().error("Unable to find client icons.");
71
72
            // Load default icons
73
            return original.call(instance, resources);
74
        }
75
76
        return List.of(() -> stream16, () -> stream32);
77
    }
78
79
    /**
80
     * Hook window resize
81
     */
82
    @Inject(method = "onResize", at = @At("RETURN"))
83
    public void hookResize(long window, int width, int height, CallbackInfo callbackInfo) {
84
        if (window == handle) {
85
            EventManager.INSTANCE.callEvent(new WindowResizeEvent(width, height));
86
        }
87
    }
88
89
    @Inject(method = "onFramebufferResize", at = @At("RETURN"))
90
    public void hookFramebufferResize(long window, int width, int height, CallbackInfo callbackInfo) {
91
        if (window == handle) {
92
            EventManager.INSTANCE.callEvent(new FramebufferResizeEvent(width, height));
93
        }
94
    }
95
96
    @Inject(method = "setGuiScale", at = @At("RETURN"))
97
    public void hookScaleFactor(int scaleFactor, CallbackInfo ci) {
98
        EventManager.INSTANCE.callEvent(new ScaleFactorChangeEvent(scaleFactor));
99
    }
100
101
}
102
MixinGlDebugsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/blaze3d/gl/MixinGlDebug.javaJava · 63 lines · 2.3 KB
@Mixin(GlDebug.class)
ModifiesGlDebug
MixinGlDebug.javaJava · 63 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.blaze3d.gl;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import com.mojang.blaze3d.opengl.GlDebug;
25
import org.slf4j.Logger;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
29
@Mixin(GlDebug.class)
30
public abstract class MixinGlDebug {
31
32
    /**
33
     * Adds source information to GL errors.
34
     */
35
    @WrapOperation(method = "printDebugLog", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;)V"), remap = false)
36
    private void injectAdvancedDebugInfo(Logger logger, String format, Object arg, Operation<Void> original) {
37
        var exception = new Exception();
38
39
        var currState = 0;
40
41
        StackTraceElement finalElement = null;
42
43
        for (var stackTraceElement : exception.getStackTrace()) {
44
            if (currState == 0 && stackTraceElement.getClassName().startsWith("org.lwjgl.")) {
45
                currState = 1;
46
            } else if (currState == 1 && !stackTraceElement.getClassName().startsWith("org.lwjgl.")) {
47
                finalElement = stackTraceElement;
48
                break;
49
            }
50
        }
51
52
        String locationText;
53
54
        if (finalElement != null) {
55
            locationText = finalElement.getClassName() + '.' + finalElement.getMethodName() + ':' + finalElement.getLineNumber();
56
        } else {
57
            locationText = "?";
58
        }
59
60
        logger.info("OpenGL debug message: {} (at {})", arg, locationText);
61
    }
62
}
63
MixinVulkanRenderPasssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/blaze3d/vk/MixinVulkanRenderPass.javaJava · 85 lines · 2.8 KB
@Mixin(VulkanRenderPass.class)
MixinVulkanRenderPass.javaJava · 85 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.blaze3d.vk;
21
22
import com.mojang.blaze3d.buffers.GpuBuffer;
23
import com.mojang.blaze3d.buffers.GpuBufferSlice;
24
import com.mojang.blaze3d.pipeline.RenderPipeline;
25
import com.mojang.blaze3d.vulkan.VulkanRenderPass;
26
import com.mojang.blaze3d.vulkan.VulkanRenderPipeline;
27
import org.jspecify.annotations.Nullable;
28
import org.spongepowered.asm.mixin.Final;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.Shadow;
31
import org.spongepowered.asm.mixin.Unique;
32
import org.spongepowered.asm.mixin.injection.At;
33
import org.spongepowered.asm.mixin.injection.Inject;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
35
36
import java.util.HashMap;
37
import java.util.Objects;
38
39
@Mixin(VulkanRenderPass.class)
40
public abstract class MixinVulkanRenderPass {
41
42
    @Shadow
43
    @Nullable
44
    protected VulkanRenderPipeline pipeline;
45
46
    @Unique
47
    private @Nullable RenderPipeline liquid_bounce$previousPipeline;
48
49
    @Shadow
50
    @Final
51
    protected HashMap<String, GpuBufferSlice> uniforms;
52
53
    @Inject(method = "setPipeline", at = @At("HEAD"), cancellable = true)
54
    private void skipBindPipeline(RenderPipeline pipeline, CallbackInfo ci) {
55
        if (pipeline == liquid_bounce$previousPipeline) {
56
            ci.cancel();
57
        }
58
59
        this.liquid_bounce$previousPipeline = pipeline;
60
    }
61
62
    @Inject(
63
        method = "setUniform(Ljava/lang/String;Lcom/mojang/blaze3d/buffers/GpuBuffer;)V",
64
        at = @At("HEAD"),
65
        cancellable = true
66
    )
67
    private void skipSetUniform(String name, GpuBuffer value, CallbackInfo ci) {
68
        if (Objects.equals(this.uniforms.get(name), value.slice())) {
69
            ci.cancel();
70
        }
71
    }
72
73
    @Inject(
74
        method = "setUniform(Ljava/lang/String;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;)V",
75
        at = @At("HEAD"),
76
        cancellable = true
77
    )
78
    private void skipSetUniformSlice(String name, GpuBufferSlice value, CallbackInfo ci) {
79
        if (Objects.equals(this.uniforms.get(name), value)) {
80
            ci.cancel();
81
        }
82
    }
83
84
}
85
MixinUtilssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/djl/MixinUtils.javaJava · 93 lines · 3.3 KB
@Mixin(value = Utils.class)
ModifiesUtils external mod
MixinUtils.javaJava · 93 lines · 3.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.djl;
20
21
import ai.djl.util.Utils;
22
import net.ccbluex.liquidbounce.api.core.HttpClient;
23
import net.ccbluex.liquidbounce.deeplearn.DeepLearningEngine;
24
import net.ccbluex.liquidbounce.mcef.listeners.OkHttpProgressInterceptor;
25
import okhttp3.Headers;
26
import okhttp3.OkHttpClient;
27
import okhttp3.Request;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Pseudo;
30
import org.spongepowered.asm.mixin.Unique;
31
import org.spongepowered.asm.mixin.injection.At;
32
import org.spongepowered.asm.mixin.injection.Inject;
33
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
34
35
import java.io.IOException;
36
import java.io.InputStream;
37
import java.net.URL;
38
import java.util.Map;
39
40
import static ai.djl.util.Utils.isOfflineMode;
41
42
@Pseudo
43
@Mixin(value = Utils.class)
44
public abstract class MixinUtils {
45
46
    @Unique
47
    private static final ThreadLocal<String> CURRENT_URL = new ThreadLocal<>();
48
49
    @Unique
50
    private static final OkHttpClient CLIENT = HttpClient.getClient().newBuilder()
51
            .addNetworkInterceptor(new OkHttpProgressInterceptor((bytesRead, contentLength, done) -> {
52
                var url = CURRENT_URL.get();
53
                var mainTask = DeepLearningEngine.getTask();
54
55
                if (mainTask == null || url == null) {
56
                    return;
57
                }
58
59
                var task = mainTask.getOrCreateFileTask(url);
60
                task.update(bytesRead, contentLength);
61
62
                if (done) {
63
                    task.setCompleted(true);
64
                    CURRENT_URL.remove();
65
                }
66
            }))
67
            .build();
68
69
    @Inject(
70
            method = "openUrl(Ljava/net/URL;Ljava/util/Map;)Ljava/io/InputStream;",
71
            at = @At("HEAD"),
72
            remap = false,
73
            cancellable = true
74
    )
75
    private static void openUrl(URL url, Map<String, String> headers, CallbackInfoReturnable<InputStream> cir) throws IOException {
76
        var protocol = url.getProtocol();
77
        if ("http".equalsIgnoreCase(protocol) || "https".equalsIgnoreCase(protocol)) {
78
            if (isOfflineMode()) {
79
                throw new IOException("Offline model is enabled.");
80
            }
81
82
            var request = new Request.Builder()
83
                    .url(url)
84
                    .headers(Headers.of(headers))
85
                    .build();
86
            CURRENT_URL.set(url.toString());
87
            var response = CLIENT.newCall(request).execute();
88
            cir.setReturnValue(response.body().byteStream());
89
        }
90
    }
91
92
}
93
MixinChunkAwareBlockCollisionSweeperBlockPossrc/main/java/net/ccbluex/liquidbounce/injection/mixins/lithium/MixinChunkAwareBlockCollisionSweeperBlockPos.javaJava · 75 lines · 3.0 KB
@Mixin(ChunkAwareBlockCollisionSweeperBlockPos.class)
ModifiesChunkAwareBlockCollisionSweeperBlockPos external mod
MixinChunkAwareBlockCollisionSweeperBlockPos.javaJava · 75 lines · 3.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.lithium;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.caffeinemc.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper;
25
import net.caffeinemc.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeperBlockPos;
26
import net.ccbluex.liquidbounce.common.ShapeFlag;
27
import net.ccbluex.liquidbounce.event.EventManager;
28
import net.ccbluex.liquidbounce.event.events.BlockShapeEvent;
29
import net.minecraft.world.entity.Entity;
30
import net.minecraft.world.level.Level;
31
import net.minecraft.world.level.block.state.BlockState;
32
import net.minecraft.world.phys.AABB;
33
import net.minecraft.world.phys.shapes.VoxelShape;
34
import org.jspecify.annotations.NullMarked;
35
import org.jspecify.annotations.Nullable;
36
import org.spongepowered.asm.mixin.Mixin;
37
import org.spongepowered.asm.mixin.Pseudo;
38
import org.spongepowered.asm.mixin.injection.At;
39
40
@NullMarked
41
@SuppressWarnings("rawtypes")
42
@Pseudo
43
@Mixin(ChunkAwareBlockCollisionSweeperBlockPos.class)
44
public abstract class MixinChunkAwareBlockCollisionSweeperBlockPos extends ChunkAwareBlockCollisionSweeper {
45
46
    public MixinChunkAwareBlockCollisionSweeperBlockPos(
47
        Level world,
48
        @Nullable Entity entity,
49
        AABB box,
50
        boolean hideLastCollision
51
    ) {
52
        super(world, entity, box, hideLastCollision);
53
    }
54
55
    /**
56
     * Hook collision shape event
57
     *
58
     * @param original voxel shape
59
     * @return possibly modified voxel shape
60
     */
61
    @ModifyExpressionValue(method = "computeNext()Lnet/minecraft/core/BlockPos$MutableBlockPos;", at = @At(
62
            value = "INVOKE",
63
            target = "Lnet/minecraft/world/phys/shapes/CollisionContext;getCollisionShape(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/CollisionGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/shapes/VoxelShape;"
64
    ))
65
    private VoxelShape hookCollisionShape(VoxelShape original, @Local(name = "state") BlockState blockState) {
66
        if (this.pos == null || ShapeFlag.noShapeChange) {
67
            return original;
68
        }
69
70
        final BlockShapeEvent shapeEvent = EventManager.INSTANCE.callEvent(new BlockShapeEvent(blockState, this.pos, original));
71
        return shapeEvent.getShape();
72
    }
73
74
}
75
MixinChunkAwareBlockCollisionSweeperVoxelShapesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/lithium/MixinChunkAwareBlockCollisionSweeperVoxelShape.javaJava · 75 lines · 3.1 KB
@Mixin(ChunkAwareBlockCollisionSweeperVoxelShape.class)
ModifiesChunkAwareBlockCollisionSweeperVoxelShape external mod
MixinChunkAwareBlockCollisionSweeperVoxelShape.javaJava · 75 lines · 3.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.lithium;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.caffeinemc.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper;
25
import net.caffeinemc.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeperVoxelShape;
26
import net.ccbluex.liquidbounce.common.ShapeFlag;
27
import net.ccbluex.liquidbounce.event.EventManager;
28
import net.ccbluex.liquidbounce.event.events.BlockShapeEvent;
29
import net.minecraft.world.entity.Entity;
30
import net.minecraft.world.level.Level;
31
import net.minecraft.world.level.block.state.BlockState;
32
import net.minecraft.world.phys.AABB;
33
import net.minecraft.world.phys.shapes.VoxelShape;
34
import org.jspecify.annotations.NullMarked;
35
import org.jspecify.annotations.Nullable;
36
import org.spongepowered.asm.mixin.Mixin;
37
import org.spongepowered.asm.mixin.Pseudo;
38
import org.spongepowered.asm.mixin.injection.At;
39
40
@NullMarked
41
@SuppressWarnings("rawtypes")
42
@Pseudo
43
@Mixin(ChunkAwareBlockCollisionSweeperVoxelShape.class)
44
public abstract class MixinChunkAwareBlockCollisionSweeperVoxelShape extends ChunkAwareBlockCollisionSweeper {
45
46
    public MixinChunkAwareBlockCollisionSweeperVoxelShape(
47
        Level world,
48
        @Nullable Entity entity,
49
        AABB box,
50
        boolean hideLastCollision
51
    ) {
52
        super(world, entity, box, hideLastCollision);
53
    }
54
55
    /**
56
     * Hook collision shape event
57
     *
58
     * @param original voxel shape
59
     * @return possibly modified voxel shape
60
     */
61
    @ModifyExpressionValue(method = "computeNext()Lnet/minecraft/world/phys/shapes/VoxelShape;", at = @At(
62
            value = "INVOKE",
63
            target = "Lnet/minecraft/world/phys/shapes/CollisionContext;getCollisionShape(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/CollisionGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/shapes/VoxelShape;"
64
    ))
65
    private VoxelShape hookCollisionShape(VoxelShape original, @Local(name = "state") BlockState blockState) {
66
        if (this.pos == null || ShapeFlag.noShapeChange) {
67
            return original;
68
        }
69
70
        final BlockShapeEvent shapeEvent = EventManager.INSTANCE.callEvent(new BlockShapeEvent(blockState, this.pos, original));
71
        return shapeEvent.getShape();
72
    }
73
74
}
75
MixinBlocksrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlock.javaJava · 63 lines · 2.6 KB
@Mixin(Block.class)
ModifiesBlock
MixinBlock.javaJava · 63 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.block;
20
21
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
22
import net.ccbluex.liquidbounce.event.EventManager;
23
import net.ccbluex.liquidbounce.event.events.BlockSlipperinessMultiplierEvent;
24
import net.ccbluex.liquidbounce.event.events.BlockVelocityMultiplierEvent;
25
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay;
26
import net.minecraft.core.Direction;
27
import net.minecraft.world.level.block.Block;
28
import net.minecraft.world.level.block.state.BlockState;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
32
@Mixin(Block.class)
33
public abstract class MixinBlock {
34
35
    @ModifyReturnValue(method = "shouldRenderFace", at = @At("RETURN"))
36
    private static boolean injectXRay(boolean original, BlockState state, BlockState otherState, Direction side) {
37
        var xRay = ModuleXRay.INSTANCE;
38
        if (xRay.getRunning()) {
39
            return xRay.modifyShouldRenderFace(original, state, otherState, side);
40
        }
41
42
        return original;
43
    }
44
45
    /**
46
     * Hook velocity multiplier event
47
     */
48
    @ModifyReturnValue(method = "getSpeedFactor", at = @At("RETURN"))
49
    private float hookVelocityMultiplier(float original) {
50
        final var multiplierEvent = EventManager.INSTANCE.callEvent(new BlockVelocityMultiplierEvent((Block) (Object) this, original));
51
        return multiplierEvent.getMultiplier();
52
    }
53
54
    /**
55
     * Hook slipperiness multiplier event
56
     */
57
    @ModifyReturnValue(method = "getFriction", at = @At("RETURN"))
58
    private float hookSlipperinessMultiplier(float original) {
59
        final var slipperinessEvent = EventManager.INSTANCE.callEvent(new BlockSlipperinessMultiplierEvent((Block) (Object) this, original));
60
        return slipperinessEvent.getSlipperiness();
61
    }
62
}
63
MixinBlockCollisionssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockCollisions.javaJava · 62 lines · 2.5 KB
@Mixin(BlockCollisions.class)
MixinBlockCollisions.javaJava · 62 lines · 2.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.block;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.sugar.Local;
23
import net.ccbluex.liquidbounce.common.ShapeFlag;
24
import net.ccbluex.liquidbounce.event.EventManager;
25
import net.ccbluex.liquidbounce.event.events.BlockShapeEvent;
26
import net.minecraft.core.BlockPos;
27
import net.minecraft.world.level.BlockCollisions;
28
import net.minecraft.world.level.block.state.BlockState;
29
import net.minecraft.world.phys.shapes.VoxelShape;
30
import org.spongepowered.asm.mixin.Final;
31
import org.spongepowered.asm.mixin.Mixin;
32
import org.spongepowered.asm.mixin.Shadow;
33
import org.spongepowered.asm.mixin.injection.At;
34
35
@Mixin(BlockCollisions.class)
36
public abstract class MixinBlockCollisions {
37
38
    @Shadow
39
    @Final
40
    private BlockPos.MutableBlockPos pos;
41
42
    /**
43
     * Hook collision shape event
44
     *
45
     * @param original voxel shape
46
     * @return possibly modified voxel shape
47
     */
48
    @ModifyExpressionValue(method = "computeNext", at = @At(
49
            value = "INVOKE",
50
            target = "Lnet/minecraft/world/phys/shapes/CollisionContext;getCollisionShape(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/CollisionGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/shapes/VoxelShape;"
51
    ))
52
    private VoxelShape hookCollisionShape(VoxelShape original, @Local(name = "blockState") BlockState blockState) {
53
        if (this.pos == null || ShapeFlag.noShapeChange) {
54
            return original;
55
        }
56
57
        final BlockShapeEvent shapeEvent = EventManager.INSTANCE.callEvent(new BlockShapeEvent(blockState, this.pos, original));
58
        return shapeEvent.getShape();
59
    }
60
61
}
62
MixinBlockGettersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockGetter.javaJava · 57 lines · 1.9 KB
@Mixin(BlockGetter.class)
ModifiesBlockGetter
MixinBlockGetter.javaJava · 57 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.block;
21
22
import net.ccbluex.liquidbounce.common.TweakedMethods;
23
import net.minecraft.core.BlockPos;
24
import net.minecraft.world.level.BlockGetter;
25
import net.minecraft.world.level.ClipContext;
26
import net.minecraft.world.level.block.state.BlockState;
27
import net.minecraft.world.phys.BlockHitResult;
28
import net.minecraft.world.phys.Vec3;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.Overwrite;
31
import org.spongepowered.asm.mixin.Shadow;
32
33
import java.util.function.BiFunction;
34
import java.util.function.Function;
35
36
@Mixin(BlockGetter.class)
37
public interface MixinBlockGetter {
38
39
    @Shadow
40
    static <T, C> T traverseBlocks(Vec3 start, Vec3 end, C context, BiFunction<C, BlockPos, T> blockHitFactory, Function<C, T> missFactory) {
41
        return null;
42
    }
43
44
    @Shadow
45
    BlockState getBlockState(BlockPos pos);
46
47
    /**
48
     * @author superblaubeere27
49
     * @reason .
50
     */
51
    @Overwrite
52
    default BlockHitResult clip(ClipContext context) {
53
        return TweakedMethods.tweakedRaycast((BlockGetter) this, context);
54
    }
55
56
}
57
MixinLeavesBlocksrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinLeavesBlock.javaJava · 50 lines · 1.9 KB
@Mixin(LeavesBlock.class)
ModifiesLeavesBlock
MixinLeavesBlock.javaJava · 50 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.block;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.minecraft.core.BlockPos;
25
import net.minecraft.util.RandomSource;
26
import net.minecraft.world.level.Level;
27
import net.minecraft.world.level.block.LeavesBlock;
28
import net.minecraft.world.level.block.state.BlockState;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33
34
/**
35
 * Disables the falling leaves particles (cherry, pale oak, tinted leaves).
36
 *
37
 * @see LeavesBlock#animateTick
38
 */
39
@Mixin(LeavesBlock.class)
40
public abstract class MixinLeavesBlock {
41
42
    @Inject(method = "makeFallingLeavesParticles", at = @At("HEAD"), cancellable = true)
43
    private void hookFallingLeaves(Level level, BlockPos pos, RandomSource random, BlockState belowState, BlockPos below, CallbackInfo ci) {
44
        if (!ModuleAntiBlind.canRender(DoRender.FALLING_LEAVES)) {
45
            ci.cancel();
46
        }
47
    }
48
49
}
50
MixinPowderSnowBlocksrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinPowderSnowBlock.javaJava · 48 lines · 2.0 KB
@Mixin(PowderSnowBlock.class)
MixinPowderSnowBlock.javaJava · 48 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.block;
20
21
import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.powdersnow.NoSlowPowderSnow;
22
import net.minecraft.core.BlockPos;
23
import net.minecraft.world.entity.Entity;
24
import net.minecraft.world.entity.InsideBlockEffectApplier;
25
import net.minecraft.world.level.Level;
26
import net.minecraft.world.level.block.PowderSnowBlock;
27
import net.minecraft.world.level.block.state.BlockState;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.injection.At;
30
import org.spongepowered.asm.mixin.injection.Inject;
31
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
32
33
@Mixin(PowderSnowBlock.class)
34
public abstract class MixinPowderSnowBlock {
35
36
    @Inject(method = "entityInside", at = @At("HEAD"), cancellable = true)
37
    private void hookEntityCollision(BlockState state, Level world, BlockPos pos, Entity entity, InsideBlockEffectApplier handler, boolean bl, CallbackInfo ci) {
38
        if (NoSlowPowderSnow.INSTANCE.getRunning()) {
39
            ci.cancel();
40
41
            var multiplier = NoSlowPowderSnow.INSTANCE.getMultiplier();
42
            var velocity = entity.getDeltaMovement();
43
            entity.setDeltaMovement(velocity.x * multiplier, velocity.y, velocity.z * multiplier);
44
        }
45
    }
46
47
}
48
MixinSlimeBlocksrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinSlimeBlock.javaJava · 42 lines · 1.7 KB
@Mixin(SlimeBlock.class)
ModifiesSlimeBlock
MixinSlimeBlock.javaJava · 42 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.block;
20
21
import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.slime.NoSlowSlime;
22
import net.minecraft.core.BlockPos;
23
import net.minecraft.world.entity.Entity;
24
import net.minecraft.world.level.Level;
25
import net.minecraft.world.level.block.SlimeBlock;
26
import net.minecraft.world.level.block.state.BlockState;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
import org.spongepowered.asm.mixin.injection.Inject;
30
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31
32
@Mixin(SlimeBlock.class)
33
public abstract class MixinSlimeBlock {
34
35
    @Inject(method = "stepOn", at = @At("HEAD"), cancellable = true)
36
    private void hookStep(Level world, BlockPos pos, BlockState state, Entity entity, CallbackInfo ci) {
37
        if (NoSlowSlime.INSTANCE.getRunning()) {
38
            ci.cancel();
39
        }
40
    }
41
}
42
MixinWebBlocksrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinWebBlock.javaJava · 49 lines · 2.0 KB
@Mixin(WebBlock.class)
ModifiesWebBlock
MixinWebBlock.javaJava · 49 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.block;
21
22
import net.ccbluex.liquidbounce.features.module.modules.movement.noweb.ModuleNoWeb;
23
import net.minecraft.client.Minecraft;
24
import net.minecraft.core.BlockPos;
25
import net.minecraft.world.entity.Entity;
26
import net.minecraft.world.entity.InsideBlockEffectApplier;
27
import net.minecraft.world.level.Level;
28
import net.minecraft.world.level.block.WebBlock;
29
import net.minecraft.world.level.block.state.BlockState;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.injection.At;
32
import org.spongepowered.asm.mixin.injection.Inject;
33
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
34
35
@Mixin(WebBlock.class)
36
public abstract class MixinWebBlock {
37
38
    /**
39
     * Hook entity collision event
40
     */
41
    @Inject(method = "entityInside", at = @At("HEAD"), cancellable = true)
42
    private void hookEntityCollision(BlockState state, Level world, BlockPos pos, Entity entity, InsideBlockEffectApplier handler, boolean bl, CallbackInfo ci) {
43
        if (ModuleNoWeb.INSTANCE.getRunning() && entity == Minecraft.getInstance().player &&
44
                ModuleNoWeb.INSTANCE.handleEntityCollision(pos)) {
45
            ci.cancel();
46
        }
47
    }
48
}
49
MinecraftAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MinecraftAccessor.javaJava · 31 lines · 1.1 KB
@Mixin(Minecraft.class)
ModifiesMinecraft
MinecraftAccessor.javaJava · 31 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import net.minecraft.client.Minecraft;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.gen.Invoker;
25
26
@Mixin(Minecraft.class)
27
public interface MinecraftAccessor {
28
    @Invoker("startUseItem")
29
    void callStartUseItem();
30
}
31
MixinClientClockManagersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinClientClockManager.javaJava · 46 lines · 1.7 KB
@Mixin(ClientClockManager.class)
MixinClientClockManager.javaJava · 46 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import net.ccbluex.liquidbounce.features.module.modules.render.customambience.ModuleCustomAmbience;
24
import net.minecraft.client.ClientClockManager;
25
import net.minecraft.core.Holder;
26
import net.minecraft.world.clock.WorldClock;
27
import net.minecraft.world.clock.WorldClocks;
28
import org.jspecify.annotations.NullMarked;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
32
@NullMarked
33
@Mixin(ClientClockManager.class)
34
public abstract class MixinClientClockManager {
35
36
    @ModifyReturnValue(method = "getTotalTicks", at = @At("RETURN"))
37
    private long injectOverrideClockTime(long original, Holder<WorldClock> definition) {
38
        if (!definition.is(WorldClocks.OVERWORLD)) {
39
            return original;
40
        }
41
42
        return ModuleCustomAmbience.getWorldClockTime(original);
43
    }
44
45
}
46
MixinClientInputsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinClientInput.javaJava · 71 lines · 2.3 KB
@Mixin(ClientInput.class)
ModifiesClientInput
MixinClientInput.javaJava · 71 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleSprint;
24
import net.ccbluex.liquidbounce.interfaces.ClientInputAddition;
25
import net.minecraft.client.player.ClientInput;
26
import net.minecraft.world.entity.player.Input;
27
import net.minecraft.world.phys.Vec2;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Shadow;
30
import org.spongepowered.asm.mixin.Unique;
31
import org.spongepowered.asm.mixin.injection.At;
32
33
@Mixin(ClientInput.class)
34
public abstract class MixinClientInput implements ClientInputAddition {
35
36
    @Shadow
37
    protected Vec2 moveVector;
38
39
    @Unique
40
    protected Input initial = Input.EMPTY;
41
42
    @Unique
43
    protected Input untransformed = Input.EMPTY;
44
45
    @ModifyReturnValue(method = "hasForwardImpulse", at = @At("RETURN"))
46
    private boolean hookOmnidirectionalSprint(boolean original) {
47
        // Allow omnidirectional sprinting
48
        if (ModuleSprint.INSTANCE.getShouldSprintOmnidirectional()) {
49
            return Math.abs(moveVector.x) > 1.0E-5F || Math.abs(moveVector.y) > 1.0E-5F;
50
        }
51
52
        return original;
53
    }
54
55
    @Override
56
    public void liquid_bounce$setMovementInput(Vec2 movementVector) {
57
        this.moveVector = movementVector;
58
    }
59
60
    @Override
61
    public Input liquid_bounce$getInitial() {
62
        return initial;
63
    }
64
65
    @Override
66
    public Input liquid_bounce$getUntransformed() {
67
        return untransformed;
68
    }
69
70
}
71
MixinClientLevelsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinClientLevel.javaJava · 121 lines · 5.5 KB
@Mixin(ClientLevel.class)
ModifiesClientLevel
MixinClientLevel.javaJava · 121 lines · 5.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.ccbluex.liquidbounce.event.EventManager;
25
import net.ccbluex.liquidbounce.event.events.WorldEntityRemoveEvent;
26
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleNoPush;
27
import net.ccbluex.liquidbounce.features.module.modules.movement.NoPushBy;
28
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
29
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
30
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleTrueSight;
31
import net.minecraft.client.multiplayer.ClientLevel;
32
import net.minecraft.core.BlockPos;
33
import net.minecraft.core.particles.ExplosionParticleInfo;
34
import net.minecraft.core.particles.ParticleOptions;
35
import net.minecraft.core.particles.ParticleTypes;
36
import net.minecraft.util.random.WeightedList;
37
import net.minecraft.world.entity.Entity;
38
import net.minecraft.world.level.block.Block;
39
import net.minecraft.world.level.block.Blocks;
40
import net.minecraft.world.level.block.state.BlockState;
41
import net.minecraft.world.phys.AABB;
42
import net.minecraft.world.phys.Vec3;
43
import org.jspecify.annotations.Nullable;
44
import org.spongepowered.asm.mixin.Mixin;
45
import org.spongepowered.asm.mixin.injection.At;
46
import org.spongepowered.asm.mixin.injection.Inject;
47
import org.spongepowered.asm.mixin.injection.Redirect;
48
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
49
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
50
51
import java.util.List;
52
53
@Mixin(ClientLevel.class)
54
public abstract class MixinClientLevel {
55
56
    @ModifyReturnValue(method = "getMarkerParticleTarget", at = @At("RETURN"))
57
    private @Nullable Block injectBlockParticle(@Nullable Block original) {
58
        var trueSight = ModuleTrueSight.INSTANCE;
59
        if (trueSight.getRunning() && (trueSight.getBarriers() || trueSight.getLights())) {
60
            return Blocks.BARRIER;
61
        }
62
        return original;
63
    }
64
65
    @Redirect(
66
        method = "doAnimateTick",
67
        at = @At(
68
            value = "INVOKE",
69
            target = "Lnet/minecraft/world/level/block/state/BlockState;getBlock()Lnet/minecraft/world/level/block/Block;",
70
            ordinal = 1
71
        )
72
    )
73
    private Block injectTrueSightMarkerParticle(BlockState state) {
74
        var trueSight = ModuleTrueSight.INSTANCE;
75
        if (!trueSight.getRunning() || (!trueSight.getBarriers() && !trueSight.getLights())) {
76
            return state.getBlock();
77
        }
78
79
        var block = state.getBlock();
80
        // BARRIER only serves as the shared marker target here; the state itself keeps the actual particle texture.
81
        return (trueSight.getBarriers() && block == Blocks.BARRIER)
82
            || (trueSight.getLights() && block == Blocks.LIGHT) ? Blocks.BARRIER : block;
83
    }
84
85
    @Inject(method = "addParticle(Lnet/minecraft/core/particles/ParticleOptions;DDDDDD)V", at = @At("HEAD"), cancellable = true)
86
    private void injectNoExplosionParticles(ParticleOptions parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ, CallbackInfo ci) {
87
        var type = parameters.getType();
88
        if (!ModuleAntiBlind.canRender(DoRender.EXPLOSION_PARTICLES) && (type == ParticleTypes.EXPLOSION || type == ParticleTypes.EXPLOSION_EMITTER)) {
89
            ci.cancel();
90
        }
91
    }
92
93
    @Inject(method = "removeEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;onClientRemoval()V"))
94
    private void injectRemoveEntity(int id, Entity.RemovalReason reason, CallbackInfo ci, @Local(name = "entity") Entity entity) {
95
        EventManager.INSTANCE.callEvent(new WorldEntityRemoveEvent(entity, reason));
96
    }
97
98
    @Inject(method = "trackExplosionEffects", at = @At("HEAD"), cancellable = true)
99
    private void hookAddBlockParticleEffects(
100
        Vec3 center, float radius, int blockCount, WeightedList<ExplosionParticleInfo> particles, CallbackInfo ci) {
101
        if (!ModuleAntiBlind.canRender(DoRender.BLOCK_BREAK_PARTICLES)) {
102
            ci.cancel();
103
        }
104
    }
105
106
    @Inject(method = "addDestroyBlockEffect", at = @At("HEAD"), cancellable = true)
107
    private void hookAddBlockBreakParticles(BlockPos pos, BlockState state, CallbackInfo ci) {
108
        if (!ModuleAntiBlind.canRender(DoRender.BLOCK_BREAK_PARTICLES)) {
109
            ci.cancel();
110
        }
111
    }
112
113
    @Inject(method = "getPushableEntities", at = @At("HEAD"), cancellable = true)
114
    private void hookGetPushableEntities(Entity pusher, AABB boundingBox, CallbackInfoReturnable<List<Entity>> cir) {
115
        if (!ModuleNoPush.canPush(NoPushBy.ENTITIES)) {
116
            cir.setReturnValue(List.of());
117
            cir.cancel();
118
        }
119
    }
120
}
121
MixinClientLevelAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinClientLevelAccessor.javaJava · 34 lines · 1.2 KB
@Mixin(ClientLevel.class)
ModifiesClientLevel
MixinClientLevelAccessor.javaJava · 34 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import net.minecraft.client.multiplayer.ClientLevel;
23
import net.minecraft.client.multiplayer.prediction.BlockStatePredictionHandler;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.gen.Accessor;
26
27
@Mixin(ClientLevel.class)
28
public interface MixinClientLevelAccessor {
29
30
    @Accessor
31
    BlockStatePredictionHandler getBlockStatePredictionHandler();
32
33
}
34
MixinGameNarratorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinGameNarrator.javaJava · 54 lines · 2.0 KB
@Mixin(GameNarrator.class)
ModifiesGameNarrator
MixinGameNarrator.javaJava · 54 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import net.minecraft.client.GameNarrator;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.injection.At;
25
import org.spongepowered.asm.mixin.injection.Inject;
26
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
28
29
/**
30
 * The minecraft narrator is so annoying and always gets enabled it accidentally by pressing the keys.
31
 */
32
@Mixin(GameNarrator.class)
33
public abstract class MixinGameNarrator {
34
35
    /**
36
     * This turns off the narrator
37
     */
38
    @Inject(method = "isActive", at = @At("HEAD"), cancellable = true)
39
    private void notActive(CallbackInfoReturnable<Boolean> callback) {
40
        callback.setReturnValue(false);
41
    }
42
43
    /**
44
     * This removes the narrator notifications
45
     */
46
    @Inject(method = {"saySystemChatQueued(Lnet/minecraft/network/chat/Component;)V",
47
        "saySystemChatQueued(Lnet/minecraft/network/chat/Component;)V",
48
        "saySystemChatQueued(Lnet/minecraft/network/chat/Component;)V", "sayChatQueued"}, at = @At("HEAD"), cancellable = true)
49
    private void cancelToast(CallbackInfo callback) {
50
        callback.cancel();
51
    }
52
53
}
54
MixinGameTypesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinGameType.javaJava · 43 lines · 1.8 KB
@Mixin(GameType.class)
ModifiesGameType
MixinGameType.javaJava · 43 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
20
21
import net.minecraft.world.level.GameType;
22
import org.spongepowered.asm.mixin.Mixin;
23
import org.spongepowered.asm.mixin.injection.At;
24
import org.spongepowered.asm.mixin.injection.ModifyVariable;
25
26
@Mixin(GameType.class)
27
public abstract class MixinGameType {
28
29
    /**
30
     * In 1.8.X, there was a gamemode type called "NOT_SET" which existed in case the game could not spawn a player/bot with an appropriate gamemode.
31
     * <p>
32
     * In newer versions, that has been removed but replaced with a constant variable called DEFAULT which is equals to SURVIVAL.
33
     * However, this puts AntiBot to a disadvantage because it can't know what gamemode type the player/bot actually has.
34
     * <p>
35
     * With this injection though, this is no longer a problem.
36
     */
37
    @ModifyVariable(method = "byName(Ljava/lang/String;Lnet/minecraft/world/level/GameType;)Lnet/minecraft/world/level/GameType;", at = @At("HEAD"), argsOnly = true, name = "defaultMode")
38
    private static GameType setDefaultAsNull(GameType gameMode) {
39
        return null;
40
    }
41
42
}
43
MixinGuisrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinGui.javaJava · 121 lines · 5.0 KB
@Mixin(Gui.class)
ModifiesGui
MixinGui.javaJava · 121 lines · 5.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.ccbluex.liquidbounce.LiquidBounce;
25
import net.ccbluex.liquidbounce.event.EventManager;
26
import net.ccbluex.liquidbounce.event.events.ScreenEvent;
27
import net.ccbluex.liquidbounce.event.events.ScreenRenderEvent;
28
import net.ccbluex.liquidbounce.features.module.modules.movement.inventorymove.ModuleInventoryMove;
29
import net.ccbluex.liquidbounce.features.module.modules.player.cheststealer.features.FeatureSilentScreen;
30
import net.minecraft.client.DeltaTracker;
31
import net.minecraft.client.KeyMapping;
32
import net.minecraft.client.MouseHandler;
33
import net.minecraft.client.gui.Gui;
34
import net.minecraft.client.gui.GuiGraphicsExtractor;
35
import net.minecraft.client.gui.screens.AccessibilityOnboardingScreen;
36
import net.minecraft.client.gui.screens.Screen;
37
import net.minecraft.client.gui.screens.TitleScreen;
38
import org.jspecify.annotations.Nullable;
39
import org.spongepowered.asm.mixin.Mixin;
40
import org.spongepowered.asm.mixin.Shadow;
41
import org.spongepowered.asm.mixin.Unique;
42
import org.spongepowered.asm.mixin.injection.At;
43
import org.spongepowered.asm.mixin.injection.Inject;
44
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
45
46
@Mixin(Gui.class)
47
public abstract class MixinGui {
48
49
    @Shadow
50
    public abstract void setScreen(@Nullable Screen screen);
51
52
    /**
53
     * Fixes recursive screen opening,
54
     * this is usually caused by another mod such as Lunar Client.
55
     * Can also happen when opening a screen during [ScreenEvent].
56
     */
57
    @Unique
58
    private static final ScopedValue<Void> RECURSIVE_SCREEN_OPENING = ScopedValue.newInstance();
59
60
    /**
61
     * Handle opening screens
62
     *
63
     * @param screen       to be opened (null = no screen at all)
64
     * @param callbackInfo callback
65
     */
66
    @Inject(method = "setScreen", at = @At("HEAD"), cancellable = true)
67
    private void hookScreen(@Nullable Screen screen, CallbackInfo callbackInfo) {
68
        if (RECURSIVE_SCREEN_OPENING.isBound()) {
69
            return;
70
        }
71
72
        var event = ScopedValue.where(RECURSIVE_SCREEN_OPENING, null)
73
            .call(() -> EventManager.INSTANCE.callEvent(new ScreenEvent(screen)));
74
75
        if (event.isCancelled()) {
76
            callbackInfo.cancel();
77
        }
78
79
        // Who need this GUI?
80
        if (screen instanceof AccessibilityOnboardingScreen) {
81
            callbackInfo.cancel();
82
            this.setScreen(new TitleScreen(true));
83
        }
84
    }
85
86
    @WrapWithCondition(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MouseHandler;releaseMouse()V"))
87
    private boolean cancelScreenMouseForChestStealer(MouseHandler instance) {
88
        // Allows rotation.
89
        return !LiquidBounce.INSTANCE.isInitialized() ||
90
            !FeatureSilentScreen.INSTANCE.getShouldHide() || FeatureSilentScreen.INSTANCE.getUnlockCursor();
91
    }
92
93
    /**
94
     * Hook screen render event
95
     */
96
    @Inject(method = "extractRenderState", at = @At(value = "INVOKE",
97
        target = "Lnet/minecraft/client/gui/screens/Screen;extractRenderStateWithTooltipAndSubtitles(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V",
98
        shift = At.Shift.AFTER))
99
    public void hookScreenRender(DeltaTracker deltaTracker, boolean shouldRenderLevel, boolean resourcesLoaded,
100
        CallbackInfo ci, @Local(name = "graphics") GuiGraphicsExtractor graphics) {
101
        EventManager.INSTANCE.callEvent(new ScreenRenderEvent(graphics, deltaTracker.getGameTimeDeltaPartialTick(false)));
102
    }
103
104
    @WrapWithCondition(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/KeyMapping;releaseAll()V"))
105
    private boolean cancelSetScreenInventoryMoveUnpressAll() {
106
        return !ModuleInventoryMove.INSTANCE.getRunning();
107
    }
108
109
    @Inject(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;init(II)V", shift = At.Shift.AFTER))
110
    private void injectSetScreenInventoryMoveUnpress(Screen screen, CallbackInfo ci) {
111
        if (ModuleInventoryMove.INSTANCE.getRunning()) {
112
            for (KeyMapping km : KeyMapping.ALL.values()) {
113
                if (ModuleInventoryMove.shouldHandleInputs(km, screen)) continue;
114
115
                km.release();
116
            }
117
        }
118
    }
119
120
}
121
MixinKeyMappingsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyMapping.javaJava · 46 lines · 1.9 KB
@Mixin(KeyMapping.class)
ModifiesKeyMapping
MixinKeyMapping.javaJava · 46 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
20
21
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
22
import com.mojang.blaze3d.platform.InputConstants;
23
import net.ccbluex.liquidbounce.event.EventManager;
24
import net.ccbluex.liquidbounce.event.events.KeybindChangeEvent;
25
import net.ccbluex.liquidbounce.event.events.KeybindIsPressedEvent;
26
import net.minecraft.client.KeyMapping;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
import org.spongepowered.asm.mixin.injection.Inject;
30
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31
32
@Mixin(KeyMapping.class)
33
public abstract class MixinKeyMapping {
34
35
    @Inject(method = "setKey", at = @At("RETURN"))
36
    private void hookSetBoundKey(InputConstants.Key boundKey, CallbackInfo ci) {
37
        EventManager.INSTANCE.callEvent(KeybindChangeEvent.INSTANCE);
38
    }
39
40
    @ModifyReturnValue(method = "isDown", at = @At("RETURN"))
41
    private boolean isPressed(boolean original) {
42
        return EventManager.INSTANCE.callEvent(new KeybindIsPressedEvent((KeyMapping) (Object) this, original)).isPressed();
43
    }
44
45
}
46
MixinKeyboardHandlersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardHandler.javaJava · 89 lines · 4.0 KB
@Mixin(KeyboardHandler.class)
MixinKeyboardHandler.javaJava · 89 lines · 4.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import com.llamalad7.mixinextras.sugar.Share;
25
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
26
import com.mojang.blaze3d.platform.InputConstants;
27
import net.ccbluex.liquidbounce.event.EventManager;
28
import net.ccbluex.liquidbounce.event.events.KeyEvent;
29
import net.ccbluex.liquidbounce.event.events.KeyboardCharEvent;
30
import net.ccbluex.liquidbounce.event.events.KeyboardKeyEvent;
31
import net.ccbluex.liquidbounce.features.module.modules.movement.inventorymove.ModuleInventoryMove;
32
import net.minecraft.client.KeyboardHandler;
33
import net.minecraft.client.Minecraft;
34
import net.minecraft.client.gui.Gui;
35
import net.minecraft.client.gui.screens.Screen;
36
import net.minecraft.client.input.CharacterEvent;
37
import org.spongepowered.asm.mixin.Final;
38
import org.spongepowered.asm.mixin.Mixin;
39
import org.spongepowered.asm.mixin.Shadow;
40
import org.spongepowered.asm.mixin.injection.At;
41
import org.spongepowered.asm.mixin.injection.Inject;
42
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
43
44
@Mixin(KeyboardHandler.class)
45
public abstract class MixinKeyboardHandler {
46
47
    @Shadow
48
    @Final
49
    private Minecraft minecraft;
50
51
    /**
52
     * Hook key event
53
     */
54
    @Inject(method = "keyPress", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;screen()Lnet/minecraft/client/gui/screens/Screen;", shift = At.Shift.BEFORE, ordinal = 0))
55
    private void hookKeyboardKey(long l, int action, net.minecraft.client.input.KeyEvent keyEvent, CallbackInfo ci) {
56
        // does if (window == this.client.getWindow().getHandle())
57
        var inputKey = InputConstants.getKey(keyEvent);
58
59
        EventManager.INSTANCE.callEvent(new KeyboardKeyEvent(
60
            inputKey, keyEvent.key(),
61
            keyEvent.scancode(), action,
62
            keyEvent.modifiers(), this.minecraft.gui.screen()
63
        ));
64
        if (minecraft.gui.screen() == null) {
65
            EventManager.INSTANCE.callEvent(new KeyEvent(inputKey, action));
66
        }
67
    }
68
69
    /**
70
     * Hook char event
71
     */
72
    @Inject(method = "charTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;screen()Lnet/minecraft/client/gui/screens/Screen;", shift = At.Shift.BEFORE))
73
    private void hookKeyboardChar(long window, CharacterEvent input, CallbackInfo ci) {
74
        // does if (window == this.client.getWindow().getHandle())
75
        EventManager.INSTANCE.callEvent(new KeyboardCharEvent(input.codepoint()));
76
    }
77
78
    @Inject(method = "keyPress", at = @At("HEAD"))
79
    private void keyPress(long handle, int action, net.minecraft.client.input.KeyEvent event, CallbackInfo ci, @Share("event") LocalRef<net.minecraft.client.input.KeyEvent> argEvent) {
80
        argEvent.set(event);
81
    }
82
83
    @WrapOperation(method = "keyPress", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;screen()Lnet/minecraft/client/gui/screens/Screen;",  ordinal = 2))
84
    private Screen modifyHandlesGameInput(Gui instance, Operation<Screen> original, @Share("event") LocalRef<net.minecraft.client.input.KeyEvent> argEvent) {
85
        return ModuleInventoryMove.shouldHandleInputs(argEvent.get()) ? null : original.call(instance);
86
    }
87
88
}
89
MixinKeyboardInputsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.javaJava · 103 lines · 4.2 KB
@Mixin(KeyboardInput.class)
MixinKeyboardInput.javaJava · 103 lines · 4.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import net.ccbluex.liquidbounce.event.EventManager;
23
import net.ccbluex.liquidbounce.event.events.MovementInputEvent;
24
import net.ccbluex.liquidbounce.event.events.SprintEvent;
25
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
26
import net.ccbluex.liquidbounce.utils.aiming.features.MovementCorrection;
27
import net.ccbluex.liquidbounce.utils.movement.DirectionalInput;
28
import net.minecraft.client.Minecraft;
29
import net.minecraft.client.player.KeyboardInput;
30
import net.minecraft.util.Mth;
31
import net.minecraft.world.entity.player.Input;
32
import org.spongepowered.asm.mixin.Mixin;
33
import org.spongepowered.asm.mixin.Unique;
34
import org.spongepowered.asm.mixin.injection.At;
35
36
import static net.minecraft.util.Mth.DEG_TO_RAD;
37
38
@Mixin(KeyboardInput.class)
39
public abstract class MixinKeyboardInput extends MixinClientInput {
40
41
    @ModifyExpressionValue(method = "tick", at = @At(value = "NEW", target = "(ZZZZZZZ)Lnet/minecraft/world/entity/player/Input;"))
42
    private Input modifyInput(Input original) {
43
        this.initial = original;
44
45
        var event = new MovementInputEvent(new DirectionalInput(original), original.jump(), original.shift());
46
        EventManager.INSTANCE.callEvent(event);
47
        var untransformedDirectionalInput = event.getDirectionalInput();
48
        var directionalInput = transformDirection(untransformedDirectionalInput);
49
50
        var sprintEvent = new SprintEvent(directionalInput, original.sprint(), SprintEvent.Source.INPUT);
51
        EventManager.INSTANCE.callEvent(sprintEvent);
52
53
        // Store the untransformed input for later use
54
        this.untransformed = new Input(
55
                untransformedDirectionalInput.getForwards(),
56
                untransformedDirectionalInput.getBackwards(),
57
                untransformedDirectionalInput.getLeft(),
58
                untransformedDirectionalInput.getRight(),
59
                event.getJump(),
60
                event.getSneak(),
61
                sprintEvent.getSprint()
62
        );
63
64
        return new Input(
65
                directionalInput.getForwards(),
66
                directionalInput.getBackwards(),
67
                directionalInput.getLeft(),
68
                directionalInput.getRight(),
69
                event.getJump(),
70
                event.getSneak(),
71
                sprintEvent.getSprint()
72
        );
73
    }
74
75
    @Unique
76
    private DirectionalInput transformDirection(DirectionalInput input) {
77
        var player = Minecraft.getInstance().player;
78
        var rotation = RotationManager.INSTANCE.getCurrentRotation();
79
        var configurable = RotationManager.INSTANCE.getActiveRotationTarget();
80
81
        float z = KeyboardInput.calculateImpulse(input.getForwards(), input.getBackwards());
82
        float x = KeyboardInput.calculateImpulse(input.getLeft(), input.getRight());
83
84
        if (configurable == null || configurable.getMovementCorrection() != MovementCorrection.SILENT
85
                || rotation == null || player == null) {
86
            return input;
87
        }
88
89
        float deltaYaw = player.getYRot() - rotation.yRot();
90
91
        float newX = x * Mth.cos(deltaYaw * DEG_TO_RAD) - z *
92
                Mth.sin(deltaYaw * DEG_TO_RAD);
93
        float newZ = z * Mth.cos(deltaYaw * DEG_TO_RAD) + x *
94
                Mth.sin(deltaYaw * DEG_TO_RAD);
95
96
        var movementSideways = Math.round(newX);
97
        var movementForward = Math.round(newZ);
98
99
        return new DirectionalInput(movementForward, movementSideways);
100
    }
101
102
}
103
MixinLevelsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinLevel.javaJava · 74 lines · 3.3 KB
@Mixin(Level.class)
ModifiesLevel
MixinLevel.javaJava · 74 lines · 3.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
20
21
import net.ccbluex.liquidbounce.common.ChunkUpdateFlag;
22
import net.ccbluex.liquidbounce.event.EventManager;
23
import net.ccbluex.liquidbounce.event.events.BlockChangeEvent;
24
import net.ccbluex.liquidbounce.features.module.modules.render.customambience.ModuleCustomAmbience;
25
import net.ccbluex.liquidbounce.utils.block.BlockExtensionsKt;
26
import net.minecraft.client.Minecraft;
27
import net.minecraft.core.BlockPos;
28
import net.minecraft.world.level.Level;
29
import net.minecraft.world.level.block.state.BlockState;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.injection.At;
32
import org.spongepowered.asm.mixin.injection.Inject;
33
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
34
35
@Mixin(Level.class)
36
public abstract class MixinLevel {
37
38
    @Inject(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At("RETURN"))
39
    private void injectBlockStateChange(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, CallbackInfoReturnable<Boolean> cir) {
40
        if (Minecraft.getInstance().level != (Object) this || ChunkUpdateFlag.isChunkDeltaUpdating()) {
41
            return;
42
        }
43
44
        // IMPORTANT: BlockPos might be a BlockPos.Mutable, so we need to create a new BlockPos instance to issues
45
        EventManager.INSTANCE.callEvent(new BlockChangeEvent(BlockExtensionsKt.getImmutable(pos), state));
46
    }
47
48
    @Inject(method = "getRainLevel", cancellable = true, at = @At("HEAD"))
49
    private void injectOverrideWeather(float delta, CallbackInfoReturnable<Float> cir) {
50
        var module = ModuleCustomAmbience.INSTANCE;
51
        var desiredWeather = module.getWeather().get();
52
        if (module.getRunning()) {
53
            switch (desiredWeather) {
54
                case SUNNY -> cir.setReturnValue(0.0f);
55
                case RAINY, THUNDER -> cir.setReturnValue(1.0f);
56
                case SNOWY -> cir.setReturnValue(0.9f);
57
            }
58
        }
59
    }
60
61
    @Inject(method = "getThunderLevel", cancellable = true, at = @At("HEAD"))
62
    private void injectOverrideThunder(float delta, CallbackInfoReturnable<Float> cir) {
63
        var module = ModuleCustomAmbience.INSTANCE;
64
        var desiredWeather = module.getWeather().get();
65
        if (module.getRunning()) {
66
            switch (desiredWeather) {
67
                case SUNNY, RAINY, SNOWY -> cir.setReturnValue(0.0f);
68
                case THUNDER -> cir.setReturnValue(1.0f);
69
            }
70
        }
71
    }
72
73
}
74
MixinLevelInvokersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinLevelInvoker.javaJava · 35 lines · 1.2 KB
@Mixin(Level.class)
ModifiesLevel
MixinLevelInvoker.javaJava · 35 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import net.minecraft.world.entity.Entity;
23
import net.minecraft.world.level.Level;
24
import net.minecraft.world.level.entity.LevelEntityGetter;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.gen.Invoker;
27
28
@Mixin(Level.class)
29
public interface MixinLevelInvoker {
30
31
    @Invoker
32
    LevelEntityGetter<Entity> invokeGetEntities();
33
34
}
35
MixinMinecraftsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMinecraft.javaJava · 495 lines · 21.7 KB
@Mixin(Minecraft.class)
ModifiesMinecraft
MixinMinecraft.javaJava · 495 lines · 21.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.ModifyReceiver;
23
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
24
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
25
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
26
import com.llamalad7.mixinextras.sugar.Local;
27
import com.mojang.blaze3d.platform.Window;
28
import net.ccbluex.liquidbounce.LiquidBounce;
29
import net.ccbluex.liquidbounce.event.CoroutineTicker;
30
import net.ccbluex.liquidbounce.event.EventManager;
31
import net.ccbluex.liquidbounce.event.TickLoopTaskExecutor;
32
import net.ccbluex.liquidbounce.event.events.*;
33
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
34
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleAutoClicker;
35
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleNoMissCooldown;
36
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.features.KillAuraAutoBlock;
37
import net.ccbluex.liquidbounce.features.module.modules.exploit.ModuleMultiActions;
38
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleMiddleClickAction;
39
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleAutoBreak;
40
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleNoBlockInteract;
41
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleReach;
42
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFreeCam;
43
import net.ccbluex.liquidbounce.injection.mixins.minecraft.entity.MixinEntityAccessor;
44
import net.ccbluex.liquidbounce.integration.backend.BrowserBackendManager;
45
import net.ccbluex.liquidbounce.integration.backend.browser.GlobalBrowserSettings;
46
import net.ccbluex.liquidbounce.integration.screen.ScreenManager;
47
import net.ccbluex.liquidbounce.render.ClientTesselator;
48
import net.ccbluex.liquidbounce.render.buffers.StaticGpuBufferPool;
49
import net.ccbluex.liquidbounce.render.mesh.MeshDraw;
50
import net.ccbluex.liquidbounce.render.utils.RenderingDebug;
51
import net.ccbluex.liquidbounce.utils.client.vfp.VfpCompatibility;
52
import net.ccbluex.liquidbounce.utils.combat.CombatManager;
53
import net.minecraft.SharedConstants;
54
import net.minecraft.client.Minecraft;
55
import net.minecraft.client.Options;
56
import net.minecraft.client.User;
57
import net.minecraft.client.gui.Gui;
58
import net.minecraft.client.multiplayer.ClientLevel;
59
import net.minecraft.client.multiplayer.ClientPacketListener;
60
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
61
import net.minecraft.client.multiplayer.ServerData;
62
import net.minecraft.client.player.LocalPlayer;
63
import net.minecraft.client.resources.language.I18n;
64
import net.minecraft.client.server.IntegratedServer;
65
import net.minecraft.util.profiling.ProfilerFiller;
66
import net.minecraft.world.entity.Entity;
67
import net.minecraft.world.entity.LivingEntity;
68
import net.minecraft.world.item.component.AttackRange;
69
import net.minecraft.world.phys.AABB;
70
import net.minecraft.world.phys.BlockHitResult;
71
import net.minecraft.world.phys.HitResult;
72
import net.minecraft.world.phys.Vec3;
73
import org.jspecify.annotations.Nullable;
74
import org.objectweb.asm.Opcodes;
75
import org.spongepowered.asm.mixin.Final;
76
import org.spongepowered.asm.mixin.Mixin;
77
import org.spongepowered.asm.mixin.Shadow;
78
import org.spongepowered.asm.mixin.injection.At;
79
import org.spongepowered.asm.mixin.injection.Inject;
80
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
81
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
82
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
83
84
import static net.ccbluex.liquidbounce.utils.client.ProtocolUtilKt.getUsesViaFabricPlus;
85
86
@Mixin(Minecraft.class)
87
public abstract class MixinMinecraft {
88
89
    @Shadow
90
    @Nullable
91
    public LocalPlayer player;
92
    @Shadow
93
    @Nullable
94
    public HitResult hitResult;
95
    @Shadow
96
    @Final
97
    public Options options;
98
    @Shadow
99
    @Nullable
100
    private IntegratedServer singleplayerServer;
101
    @Shadow
102
    private int rightClickDelay;
103
    @Shadow
104
    @Nullable
105
    public MultiPlayerGameMode gameMode;
106
107
    @Shadow
108
    @Nullable
109
    public abstract ClientPacketListener getConnection();
110
111
    @Shadow
112
    public abstract @Nullable ServerData getCurrentServer();
113
114
    @Shadow
115
    public abstract Window getWindow();
116
117
    @Shadow
118
    public abstract int getFps();
119
120
    @Shadow
121
    public abstract User getUser();
122
123
    @Shadow
124
    protected abstract void continueAttack(boolean breaking);
125
126
    @Shadow
127
    @Nullable
128
    public ClientLevel level;
129
130
    @Shadow
131
    @Final
132
    public Gui gui;
133
134
    /**
135
     * Entry point
136
     */
137
    @Inject(method = "<init>(Lnet/minecraft/client/main/GameConfig;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;resizeGui()V"))
138
    private void startClient(CallbackInfo callback) {
139
        EventManager.INSTANCE.callEvent(ClientStartEvent.INSTANCE);
140
    }
141
142
    /**
143
     * Exit point
144
     */
145
    @Inject(method = "close", at = @At("HEAD"))
146
    private void stopClient(CallbackInfo callback) {
147
        MeshDraw.DefaultUploader.close();
148
        EventManager.INSTANCE.callEvent(ClientShutdownEvent.INSTANCE);
149
    }
150
151
    @Inject(method = "<init>(Lnet/minecraft/client/main/GameConfig;)V", at = @At(value = "FIELD",
152
        target = "Lnet/minecraft/client/Minecraft;profileKeyPairManager:Lnet/minecraft/client/multiplayer/ProfileKeyPairManager;",
153
        ordinal = 0, shift = At.Shift.AFTER, opcode = Opcodes.PUTFIELD))
154
    private void onSessionInit(CallbackInfo callback) {
155
        EventManager.INSTANCE.callEvent(new SessionEvent(getUser()));
156
    }
157
158
    /**
159
     * Modify window title to our client title.
160
     * Example: LiquidBounce v1.0.0 | 1.16.3
161
     *
162
     * @param callback our window title
163
     *                 <p>
164
     *                 todo: modify constant Minecraft instead
165
     */
166
    @Inject(method = "createTitle", at = @At(
167
            value = "INVOKE",
168
            target = "Ljava/lang/StringBuilder;append(Ljava/lang/String;)Ljava/lang/StringBuilder;",
169
            ordinal = 1),
170
            cancellable = true)
171
    private void getClientTitle(CallbackInfoReturnable<String> callback) {
172
        if (SelfDestruct.INSTANCE.isDestructed()) {
173
            return;
174
        }
175
176
        LiquidBounce.INSTANCE.getLogger().debug("Modifying window title");
177
178
        StringBuilder titleBuilder = new StringBuilder(LiquidBounce.CLIENT_NAME);
179
        titleBuilder.append(" v");
180
        titleBuilder.append(LiquidBounce.INSTANCE.getClientVersion());
181
        titleBuilder.append(" ");
182
183
        if (LiquidBounce.IN_DEVELOPMENT) {
184
            titleBuilder.append("(dev) ");
185
        }
186
187
        titleBuilder.append(LiquidBounce.INSTANCE.getClientCommit());
188
189
        titleBuilder.append(" | ");
190
191
        // ViaFabricPlus compatibility
192
        if (getUsesViaFabricPlus()) {
193
            var protocolVersion = VfpCompatibility.INSTANCE.unsafeGetProtocolVersion();
194
195
            if (protocolVersion != null) {
196
                titleBuilder.append(protocolVersion.name());
197
            } else {
198
                titleBuilder.append(SharedConstants.getCurrentVersion().name());
199
            }
200
        } else {
201
            titleBuilder.append(SharedConstants.getCurrentVersion().name());
202
        }
203
204
        // For debugging purposes, will be removed until we have a stable release
205
        var backend = BrowserBackendManager.INSTANCE.getBackend();
206
        if (backend != null && backend.isInitialized() && backend.getAccelerationFlags().isSupported()) {
207
            var accelerated = GlobalBrowserSettings.INSTANCE.getAccelerated();
208
209
            if (accelerated != null && accelerated.get()) {
210
                titleBuilder.append(" | Accelerated Paint is ON");
211
                // Hotkey only works when not in-game
212
                if (this.level == null && this.player == null) {
213
                    titleBuilder.append(" [Hotkey: F12]");
214
                }
215
            }
216
        }
217
218
        ClientPacketListener clientPlayNetworkHandler = this.getConnection();
219
        if (clientPlayNetworkHandler != null && clientPlayNetworkHandler.getConnection().isConnected()) {
220
            titleBuilder.append(" - ");
221
            ServerData serverInfo = this.getCurrentServer();
222
            if (this.singleplayerServer != null && !this.singleplayerServer.isPublished()) {
223
                titleBuilder.append(I18n.get("title.singleplayer"));
224
            } else if (serverInfo != null && serverInfo.isRealm()) {
225
                titleBuilder.append(I18n.get("title.multiplayer.realms"));
226
            } else if (this.singleplayerServer == null && (serverInfo == null || !serverInfo.isLan())) {
227
                titleBuilder.append(I18n.get("title.multiplayer.other"));
228
            } else {
229
                titleBuilder.append(I18n.get("title.multiplayer.lan"));
230
            }
231
        }
232
233
        callback.setReturnValue(titleBuilder.toString());
234
    }
235
236
    /**
237
     * Hook game tick event at HEAD
238
     */
239
    @Inject(method = "tick", at = @At("HEAD"))
240
    private void hookTickEvent(CallbackInfo callbackInfo) {
241
        CoroutineTicker.INSTANCE.beginMinecraftTick();
242
        TickLoopTaskExecutor.INSTANCE.onTickLoopStart();
243
        CoroutineTicker.INSTANCE.tick();
244
        EventManager.INSTANCE.callEvent(GameTickEvent.INSTANCE);
245
    }
246
247
    @Inject(method = "tick", at = @At(
248
        value = "INVOKE",
249
        target = "Lnet/minecraft/client/multiplayer/ClientPacketListener;send(Lnet/minecraft/network/protocol/Packet;)V",
250
        shift = At.Shift.AFTER
251
    ))
252
    private void hookTickLoopCompletedAfterTickEndPacket(CallbackInfo callbackInfo) {
253
        TickLoopTaskExecutor.INSTANCE.onTickLoopCompleted();
254
    }
255
256
    @Inject(method = "tick", at = @At("RETURN"))
257
    private void fallbackCompleteTickLoop(CallbackInfo callbackInfo) {
258
        if (TickLoopTaskExecutor.INSTANCE.isInTickLoop()) {
259
            TickLoopTaskExecutor.INSTANCE.onTickLoopCompleted();
260
        }
261
262
        CoroutineTicker.INSTANCE.endMinecraftTick();
263
    }
264
265
    /**
266
     * Hook game render task queue event
267
     */
268
    @Inject(method = "runTick", at = @At("HEAD"))
269
    private void hookRenderTaskQueue(CallbackInfo callbackInfo) {
270
        EventManager.INSTANCE.callEvent(GameRenderTaskQueueEvent.INSTANCE);
271
    }
272
273
    @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;runAllTasks()V", shift = At.Shift.BEFORE))
274
    private void hookPacketProcess(CallbackInfo callbackInfo) {
275
        EventManager.INSTANCE.callEvent(TickPacketProcessEvent.INSTANCE);
276
    }
277
278
    /**
279
     * Hook input handling
280
     */
281
    @Inject(method = "handleKeybinds", at = @At("RETURN"))
282
    private void hookHandleInputEvent(CallbackInfo callbackInfo) {
283
        EventManager.INSTANCE.callEvent(InputHandleEvent.INSTANCE);
284
    }
285
286
    /**
287
     * Hook item use cooldown
288
     */
289
    @Inject(method = "startUseItem", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;rightClickDelay:I", shift = At.Shift.AFTER, opcode = Opcodes.PUTFIELD))
290
    private void hookItemUseCooldown(CallbackInfo callbackInfo) {
291
        UseCooldownEvent useCooldownEvent = new UseCooldownEvent(rightClickDelay);
292
        EventManager.INSTANCE.callEvent(useCooldownEvent);
293
        rightClickDelay = useCooldownEvent.getCooldown();
294
    }
295
296
    @Inject(method = "pickBlockOrEntity", at = @At("HEAD"), cancellable = true)
297
    private void hookItemPick(CallbackInfo ci) {
298
        if (ModuleMiddleClickAction.Pearl.INSTANCE.cancelPick()) {
299
            ci.cancel();
300
        }
301
    }
302
303
    @ModifyExpressionValue(method = "startAttack",
304
            at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;missTime:I", ordinal = 0, opcode = Opcodes.GETFIELD))
305
    private int injectNoMissCooldown(int original) {
306
        if (ModuleNoMissCooldown.INSTANCE.getRunning() && ModuleNoMissCooldown.INSTANCE.getRemoveAttackCooldown()) {
307
            return 0;
308
        }
309
310
        if (ModuleAutoClicker.AttackButton.INSTANCE.getRunning()) {
311
            var clickAmount = ModuleAutoClicker.AttackButton.INSTANCE.getClicker().getClickAmount();
312
            if (clickAmount != null && clickAmount > 0) {
313
                return 0;
314
            }
315
        }
316
317
        return original;
318
    }
319
320
    @ModifyReceiver(
321
        method = "startAttack",
322
        at = @At(
323
            value = "INVOKE",
324
            target = "Lnet/minecraft/world/item/component/AttackRange;isInRange(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/phys/Vec3;)Z"
325
        )
326
    )
327
    private AttackRange injectReachAttackRange(AttackRange instance, LivingEntity entity, Vec3 pos) {
328
        if (ModuleReach.INSTANCE.getRunning()) {
329
            return ModuleReach.INSTANCE.getEntity().adjustAttackRange(instance);
330
        }
331
332
        return instance;
333
    }
334
335
    @WrapWithCondition(method = "startAttack", at = @At(value = "FIELD",
336
        target = "Lnet/minecraft/client/Minecraft;missTime:I", ordinal = 1, opcode = Opcodes.PUTFIELD))
337
    private boolean disableAttackCooldown(Minecraft instance, int value) {
338
        return !(ModuleNoMissCooldown.INSTANCE.getRunning() && ModuleNoMissCooldown.INSTANCE.getRemoveAttackCooldown());
339
    }
340
341
    @Inject(method = "startAttack", at = @At("HEAD"), cancellable = true)
342
    private void injectCombatPause(CallbackInfoReturnable<Boolean> cir) {
343
        if (player == null || hitResult == null || hitResult.getType() == HitResult.Type.MISS) {
344
            if (ModuleNoMissCooldown.INSTANCE.getRunning() && ModuleNoMissCooldown.INSTANCE.getCancelAttackOnMiss()) {
345
                // Prevent swinging
346
                cir.setReturnValue(true);
347
            }
348
            return;
349
        }
350
351
        if (CombatManager.INSTANCE.getShouldPauseCombat()) {
352
            cir.setReturnValue(false);
353
        }
354
    }
355
356
    @Inject(method = "updateLevelInEngines(Lnet/minecraft/client/multiplayer/ClientLevel;Z)V", at = @At("HEAD"))
357
    private void hookWorldChangeEvent(ClientLevel world, boolean bl, CallbackInfo ci) {
358
        EventManager.INSTANCE.callEvent(new WorldChangeEvent(world));
359
    }
360
361
    @Inject(method = "renderFrame", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;fps:I",
362
        ordinal = 0, shift = At.Shift.AFTER, opcode = Opcodes.PUTSTATIC))
363
    private void hookFpsChange(CallbackInfo ci) {
364
        EventManager.INSTANCE.callEvent(new FpsChangeEvent(this.getFps()));
365
    }
366
367
    @Inject(method = "onResourceLoadFinished", at = @At("HEAD"))
368
    private void onFinishedLoading(CallbackInfo ci) {
369
        EventManager.INSTANCE.callEvent(ResourceReloadEvent.INSTANCE);
370
    }
371
372
    @ModifyExpressionValue(method = "continueAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isUsingItem()Z"))
373
    private boolean injectMultiActionsBreakingWhileUsing(boolean original) {
374
        return original && !ModuleMultiActions.mayBreakWhileUsing();
375
    }
376
377
    @ModifyExpressionValue(method = "startUseItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;isDestroying()Z"))
378
    private boolean injectMultiActionsPlacingWhileBreaking(boolean original) {
379
        return original && !ModuleMultiActions.mayPlaceWhileBreaking();
380
    }
381
382
    /**
383
     * Alternative input handler of [handleInputEvents] while being inside a client-side screen.
384
     */
385
    @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;screen()Lnet/minecraft/client/gui/screens/Screen;", ordinal = 1, shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILSOFT)
386
    private void passthroughInputHandler(CallbackInfo ci, @Local(name = "profiler") ProfilerFiller profiler) {
387
        if (this.gui.overlay() == null && this.player != null && this.level
388
            != null && ScreenManager.isClientScreen(this.gui.screen())) {
389
            profiler.popPush("Keybindings");
390
391
            if (ModuleAutoBreak.INSTANCE.getEnabled()) {
392
                this.continueAttack(this.options.keyAttack.isDown());
393
            }
394
        }
395
    }
396
397
    @ModifyExpressionValue(method = "handleKeybinds", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isUsingItem()Z", ordinal = 0))
398
    private boolean injectMultiActionsAttackingWhileUsingAndEnforcedBlockingState(boolean isUsingItem) {
399
        if (isUsingItem) {
400
            if (!this.options.keyUse.isDown() && !(KillAuraAutoBlock.INSTANCE.getRunning() && KillAuraAutoBlock.INSTANCE.getEnforcedBlockingHand() != null)) {
401
                this.gameMode.releaseUsingItem(this.player);
402
            }
403
404
            if (!ModuleMultiActions.mayAttackWhileUsing()) {
405
                this.options.keyAttack.clickCount = 0;
406
            }
407
408
            this.options.keyPickItem.clickCount = 0;
409
            this.options.keyUse.clickCount = 0;
410
        }
411
412
        return false;
413
    }
414
415
    @WrapWithCondition(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;missTime:I", ordinal = 0, opcode = Opcodes.PUTFIELD))
416
    private boolean injectFixAttackCooldownOnVirtualBrowserScreen(Minecraft instance, int value) {
417
        // Do not reset attack cooldown when we are in the vr/browser screen, as this poses an
418
        // unintended modification to the attack cooldown, which is not intended.
419
        return !ScreenManager.isClientScreen(this.gui.screen());
420
    }
421
422
    @Inject(method = "clearDownloadedResourcePacks", at = @At("HEAD"))
423
    private void handleDisconnection(CallbackInfo ci) {
424
        EventManager.INSTANCE.callEvent(DisconnectEvent.INSTANCE);
425
    }
426
427
    @Inject(method = "startUseItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;useItemOn(Lnet/minecraft/client/player/LocalPlayer;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;"), cancellable = true)
428
    private void hookBlockInteract(CallbackInfo ci) {
429
        final BlockHitResult blockHitResult = (BlockHitResult) this.hitResult;
430
        if (blockHitResult == null) return; // it should never be null
431
432
        if (ModuleNoBlockInteract.INSTANCE.getRunning() &&
433
                ModuleNoBlockInteract.INSTANCE.shouldSneak(blockHitResult)) {
434
435
            ModuleNoBlockInteract.INSTANCE.startSneaking();
436
            ci.cancel();
437
        }
438
    }
439
440
    @Inject(method = "renderFrame", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoder;submit()V", shift = At.Shift.BEFORE))
441
    private void endDynamicGpuBufferFrame(boolean advanceGameTime, CallbackInfo ci) {
442
        MeshDraw.DefaultUploader.endFrame();
443
    }
444
445
    @Inject(method = "renderFrame", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;endFrame()V", shift = At.Shift.AFTER))
446
    private void onFlipFrame(boolean advanceGameTime, CallbackInfo ci) {
447
        RenderingDebug.flipFrame();
448
        ClientTesselator.Shared.clear();
449
        StaticGpuBufferPool.cleanup();
450
    }
451
452
    @WrapOperation(method = "pick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;raycastHitResult(FLnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/phys/HitResult;"))
453
    private HitResult updateTargetedEntityInvoke(LocalPlayer instance, float a, Entity cameraEntity, Operation<HitResult> original) {
454
        HitResult result;
455
        if (cameraEntity == instance && ModuleFreeCam.shouldCameraInteractActive()) {
456
            final Vec3 position = cameraEntity.position();
457
            final AABB boundingBox = cameraEntity.getBoundingBox();
458
            final Vec3 lastPosition = new Vec3(cameraEntity.xo, cameraEntity.yo, cameraEntity.zo);
459
            final float yRot = cameraEntity.getYRot();
460
            final float xRot = cameraEntity.getXRot();
461
            final float yRot0 = cameraEntity.yRotO;
462
            final float xRot0 = cameraEntity.xRotO;
463
464
            final Vec3 cameraPosition = ModuleFreeCam.PositionState.pos.subtract(0.0, cameraEntity.getEyeHeight(), 0.0);
465
            ((MixinEntityAccessor) cameraEntity).position(cameraPosition);
466
            cameraEntity.setBoundingBox(boundingBox.move(cameraPosition.subtract(position)));
467
            cameraEntity.xo = ModuleFreeCam.PositionState.lastPos.x;
468
            cameraEntity.yo = ModuleFreeCam.PositionState.lastPos.y - cameraEntity.getEyeHeight();
469
            cameraEntity.zo = ModuleFreeCam.PositionState.lastPos.z;
470
            ((MixinEntityAccessor) cameraEntity).yRot(ModuleFreeCam.PositionState.rot.yRot());
471
            ((MixinEntityAccessor) cameraEntity).xRot(ModuleFreeCam.PositionState.rot.xRot());
472
            cameraEntity.yRotO = ModuleFreeCam.PositionState.lastRot.yRot();
473
            cameraEntity.xRotO = ModuleFreeCam.PositionState.lastRot.xRot();
474
475
            try {
476
                result = original.call(instance, a, cameraEntity);
477
            } finally {
478
                ((MixinEntityAccessor) cameraEntity).position(position);
479
                cameraEntity.setBoundingBox(boundingBox);
480
                cameraEntity.xo = lastPosition.x;
481
                cameraEntity.yo = lastPosition.y;
482
                cameraEntity.zo = lastPosition.z;
483
                ((MixinEntityAccessor) cameraEntity).yRot(yRot);
484
                ((MixinEntityAccessor) cameraEntity).xRot(xRot);
485
                cameraEntity.yRotO = yRot0;
486
                cameraEntity.xRotO = xRot0;
487
            }
488
        } else {
489
            result = original.call(instance, a, cameraEntity);
490
        }
491
492
        return result;
493
    }
494
}
495
MixinMouseHandlersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMouseHandler.javaJava · 123 lines · 5.3 KB
@Mixin(MouseHandler.class)
ModifiesMouseHandler
MixinMouseHandler.javaJava · 123 lines · 5.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
24
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
25
import com.llamalad7.mixinextras.sugar.Local;
26
import com.mojang.blaze3d.platform.InputConstants;
27
import net.ccbluex.liquidbounce.additions.MouseHandlerAddition;
28
import net.ccbluex.liquidbounce.event.EventManager;
29
import net.ccbluex.liquidbounce.event.events.*;
30
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleZoom;
31
import net.minecraft.client.Minecraft;
32
import net.minecraft.client.MouseHandler;
33
import net.minecraft.client.input.MouseButtonInfo;
34
import net.minecraft.client.player.LocalPlayer;
35
import org.spongepowered.asm.mixin.Final;
36
import org.spongepowered.asm.mixin.Mixin;
37
import org.spongepowered.asm.mixin.Shadow;
38
import org.spongepowered.asm.mixin.Unique;
39
import org.spongepowered.asm.mixin.injection.At;
40
import org.spongepowered.asm.mixin.injection.Inject;
41
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
42
43
@Mixin(MouseHandler.class)
44
public abstract class MixinMouseHandler implements MouseHandlerAddition {
45
46
    @Shadow
47
    @Final
48
    private Minecraft minecraft;
49
50
    @Shadow
51
    private double xpos;
52
53
    @Shadow
54
    private double ypos;
55
56
    @Unique
57
    @Override
58
    public void liquidbounce$setPosition(double x, double y) {
59
        this.xpos = x;
60
        this.ypos = y;
61
        InputConstants.grabOrReleaseMouse(this.minecraft.getWindow(), InputConstants.CURSOR_NORMAL, this.xpos, this.ypos);
62
    }
63
64
    /**
65
     * Hook mouse button event
66
     */
67
    @Inject(method = "onButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;overlay()Lnet/minecraft/client/gui/screens/Overlay;", shift = At.Shift.BEFORE, ordinal = 0))
68
    private void hookMouseButton(long window, MouseButtonInfo input, int action, CallbackInfo ci) {
69
        final var button = input.button();
70
        EventManager.INSTANCE.callEvent(new MouseButtonEvent(
71
                InputConstants.Type.MOUSE.getOrCreate(button),
72
                button,
73
                action,
74
                input.modifiers(),
75
                this.minecraft.gui.screen()
76
        ));
77
    }
78
79
    /**
80
     * Hook mouse scroll event
81
     */
82
    @Inject(method = "onScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;overlay()Lnet/minecraft/client/gui/screens/Overlay;", shift = At.Shift.BEFORE, ordinal = 0))
83
    private void hookMouseScroll(long window, double horizontal, double vertical, CallbackInfo callbackInfo) {
84
        EventManager.INSTANCE.callEvent(new MouseScrollEvent(horizontal, vertical));
85
    }
86
87
    @Inject(method = "onScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isSpectator()Z", shift = At.Shift.BEFORE), cancellable = true)
88
    private void hookMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci, @Local(name = "wheel") int i) {
89
        if (EventManager.INSTANCE.callEvent(new MouseScrollInHotbarEvent(i)).isCancelled()) {
90
            ci.cancel();
91
        }
92
    }
93
94
    /**
95
     * Hook mouse cursor event
96
     */
97
    @Inject(method = "onMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isWindowActive()Z", shift = At.Shift.BEFORE, ordinal = 0))
98
    private void hookCursorPos(long window, double x, double y, CallbackInfo callbackInfo) {
99
        EventManager.INSTANCE.callEvent(new MouseCursorEvent(x, y));
100
    }
101
102
    @ModifyExpressionValue(method = "turnPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/CameraType;isFirstPerson()Z"))
103
    private boolean injectZoomCondition1(boolean original) {
104
        return original || ModuleZoom.INSTANCE.getRunning();
105
    }
106
107
    @ModifyExpressionValue(method = "turnPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isScoping()Z"))
108
    private boolean injectZoomCondition2(boolean original) {
109
        return original || ModuleZoom.INSTANCE.getRunning();
110
    }
111
112
    @WrapOperation(method = "turnPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;turn(DD)V"), require = 1, allow = 1)
113
    private void modifyMouseRotationInput(LocalPlayer instance, double cursorDeltaX, double cursorDeltaY, Operation<Void> original) {
114
        final MouseRotationEvent event = new MouseRotationEvent(cursorDeltaX, cursorDeltaY);
115
        EventManager.INSTANCE.callEvent(event);
116
117
        if (!event.isCancelled()) {
118
            original.call(instance, event.getCursorDeltaX(), event.getCursorDeltaY());
119
        }
120
    }
121
122
}
123
MixinMouseHandlerAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMouseHandlerAccessor.javaJava · 35 lines · 1.3 KB
@Mixin(MouseHandler.class)
ModifiesMouseHandler
MixinMouseHandlerAccessor.javaJava · 35 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import net.minecraft.client.MouseHandler;
23
import net.minecraft.client.input.MouseButtonInfo;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.gen.Accessor;
26
27
@Mixin(MouseHandler.class)
28
public interface MixinMouseHandlerAccessor {
29
    @Accessor("lastClick")
30
    void setLastClick(MouseHandler.LastClick lastMouseClick);
31
32
    @Accessor("lastClickButton")
33
    void setLastClickButton(@MouseButtonInfo.MouseButton int lastMouseButton);
34
}
35
MixinOptionssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinOptions.javaJava · 47 lines · 1.7 KB
@Mixin(Options.class)
ModifiesOptions
MixinOptions.javaJava · 47 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
21
22
import net.minecraft.client.OptionInstance;
23
import net.minecraft.client.Options;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.Inject;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
28
29
@Mixin(Options.class)
30
public abstract class MixinOptions {
31
32
    /**
33
     * Hook GUI scale adjustment
34
     * <p>
35
     * This is used to set the default GUI scale to 2X on AUTO because the default is TOO HUGE.
36
     * On WQHD and HD displays, the default GUI scale is way too big. 4K might be fine, but
37
     * the majority of players are not using 4K displays.
38
     */
39
    @Inject(method = "guiScale", at = @At("RETURN"))
40
    private void injectGuiScale(CallbackInfoReturnable<OptionInstance<Integer>> cir) {
41
        if (cir.getReturnValue().get() == 0) {
42
            cir.getReturnValue().set(2);
43
        }
44
    }
45
46
}
47
MixinStringSplittersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinStringSplitter.javaJava · 63 lines · 2.4 KB
@Mixin(StringSplitter.class)
MixinStringSplitter.javaJava · 63 lines · 2.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
20
21
import net.ccbluex.liquidbounce.features.module.modules.misc.nameprotect.ModuleNameProtect;
22
import net.minecraft.client.StringSplitter;
23
import net.minecraft.network.chat.FormattedText;
24
import net.minecraft.network.chat.Style;
25
import net.minecraft.util.StringDecomposer;
26
import org.apache.commons.lang3.mutable.MutableFloat;
27
import org.spongepowered.asm.mixin.Final;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Shadow;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
33
34
import java.util.Optional;
35
36
@Mixin(StringSplitter.class)
37
public abstract class MixinStringSplitter {
38
39
    @Shadow
40
    @Final
41
    public StringSplitter.WidthProvider widthProvider;
42
43
    @Inject(method = "stringWidth(Lnet/minecraft/network/chat/FormattedText;)F", at = @At("HEAD"), cancellable = true)
44
    private void injectNameProtectWidthB(FormattedText text, CallbackInfoReturnable<Float> cir) {
45
        if (!ModuleNameProtect.INSTANCE.getRunning()) {
46
            return;
47
        }
48
49
        MutableFloat mutableFloat = new MutableFloat();
50
        text.visit((style, asString) -> {
51
            StringDecomposer.iterateFormatted(ModuleNameProtect.INSTANCE.replace(asString), style, (_, stylex, codePoint) -> {
52
                mutableFloat.add(widthProvider.getWidth(codePoint, stylex));
53
                return true;
54
            });
55
56
            return Optional.empty();
57
        }, Style.EMPTY);
58
59
        cir.setReturnValue(mutableFloat.floatValue());
60
    }
61
62
}
63
MixinCommonNetworkHandlersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/network/MixinCommonNetworkHandler.javaJava · 41 lines · 1.7 KB
@Mixin(ClientCommonPacketListenerImpl.class)
MixinCommonNetworkHandler.javaJava · 41 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client.network;
20
21
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleAntiExploit;
22
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
23
import net.minecraft.network.protocol.Packet;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.Inject;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28
29
@Mixin(ClientCommonPacketListenerImpl.class)
30
public abstract class MixinCommonNetworkHandler {
31
32
    @Inject(method = "onPacketError", at = @At(value = "HEAD"), cancellable = true)
33
    private void packetExceptionCancel(Packet<?> packet, Exception cause, CallbackInfo ci) {
34
        var antiExploit = ModuleAntiExploit.INSTANCE;
35
        if (antiExploit.getRunning() && antiExploit.getIgnoreProtocol()) {
36
            ci.cancel();
37
        }
38
    }
39
40
}
41
MixinChatListenersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/network/message/MixinChatListener.javaJava · 95 lines · 4.9 KB
@Mixin(ChatListener.class)
ModifiesChatListener
MixinChatListener.javaJava · 95 lines · 4.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client.network.message;
20
21
import com.mojang.authlib.GameProfile;
22
import net.ccbluex.liquidbounce.event.EventManager;
23
import net.ccbluex.liquidbounce.event.events.ChatReceiveEvent;
24
import net.minecraft.client.multiplayer.chat.ChatListener;
25
import net.minecraft.network.chat.ChatType;
26
import net.minecraft.network.chat.Component;
27
import net.minecraft.network.chat.PlayerChatMessage;
28
import net.minecraft.util.Util;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.Shadow;
31
import org.spongepowered.asm.mixin.Unique;
32
import org.spongepowered.asm.mixin.injection.At;
33
import org.spongepowered.asm.mixin.injection.Inject;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
35
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
36
37
import java.time.Instant;
38
39
@Mixin(ChatListener.class)
40
public abstract class MixinChatListener {
41
42
    @Shadow
43
    private long previousMessageTime;
44
45
    @Inject(method = "lambda$handleDisguisedChatMessage$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/chat/ChatType$Bound;decorate(Lnet/minecraft/network/chat/Component;)Lnet/minecraft/network/chat/Component;", shift = At.Shift.BEFORE), cancellable = true)
46
    private void injectDisguisedChatLambda(ChatType.Bound parameters, Component text, Instant instant, CallbackInfoReturnable<Boolean> cir) {
47
        var result = liquid_bounce$emitChatEvent(parameters, text, ChatReceiveEvent.ChatType.DISGUISED_CHAT_MESSAGE);
48
        if (result) {
49
            previousMessageTime = Util.getMillis();
50
            cir.cancel();
51
        }
52
    }
53
54
    @Inject(method = "showMessageToPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;addPlayerMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;)V", ordinal = 0, shift = At.Shift.BEFORE), cancellable = true)
55
    private void injectChatMessage1(ChatType.Bound parameters, PlayerChatMessage message, Component decorated, GameProfile sender, boolean onlyShowSecureChat, Instant receptionTimestamp, CallbackInfoReturnable<Boolean> cir) {
56
        var result = liquid_bounce$emitChatEvent(null, decorated, ChatReceiveEvent.ChatType.CHAT_MESSAGE);
57
        if (result) {
58
            previousMessageTime = Util.getMillis();
59
            cir.cancel();
60
        }
61
    }
62
63
    @Inject(method = "showMessageToPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;addPlayerMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;)V", ordinal = 1, shift = At.Shift.BEFORE), cancellable = true)
64
    private void injectChatMessage2(ChatType.Bound parameters, PlayerChatMessage message, Component decorated, GameProfile sender, boolean onlyShowSecureChat, Instant receptionTimestamp, CallbackInfoReturnable<Boolean> cir) {
65
        var result = liquid_bounce$emitChatEvent(parameters, decorated, ChatReceiveEvent.ChatType.CHAT_MESSAGE);
66
        if (result) {
67
            previousMessageTime = Util.getMillis();
68
            cir.cancel();
69
        }
70
    }
71
72
    @Inject(method = "handleSystemMessage", at = @At(value = "HEAD"), cancellable = true)
73
    private void injectGameMessage(Component message, boolean overlay, CallbackInfo ci) {
74
        var result = liquid_bounce$emitChatEvent(null, message, overlay ? ChatReceiveEvent.ChatType.DISGUISED_CHAT_MESSAGE : ChatReceiveEvent.ChatType.GAME_MESSAGE);
75
        if (result) {
76
            previousMessageTime = Util.getMillis();
77
            ci.cancel();
78
        }
79
    }
80
81
    @Unique
82
    private boolean liquid_bounce$emitChatEvent(ChatType.Bound parameters, Component text, ChatReceiveEvent.ChatType type) {
83
        var event = new ChatReceiveEvent(text.getString(), text, type, inputText -> {
84
            if (parameters != null) {
85
                return parameters.decorate(text);
86
            } else {
87
                return text;
88
            }
89
        });
90
        EventManager.INSTANCE.callEvent(event);
91
        return event.isCancelled();
92
    }
93
94
}
95
MixinServerListAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/option/MixinServerListAccessor.javaJava · 33 lines · 1.2 KB
@Mixin(ServerList.class)
ModifiesServerList
MixinServerListAccessor.javaJava · 33 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client.option;
20
21
import net.minecraft.client.multiplayer.ServerData;
22
import net.minecraft.client.multiplayer.ServerList;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.gen.Accessor;
25
26
import java.util.List;
27
28
@Mixin(ServerList.class)
29
public interface MixinServerListAccessor {
30
    @Accessor("serverList")
31
    List<ServerData> liquid_bounce$getServerList();
32
}
33
MixinMappableRingBuffersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/renderer/MixinMappableRingBuffer.javaJava · 47 lines · 1.6 KB
@Mixin(MappableRingBuffer.class)
MixinMappableRingBuffer.javaJava · 47 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client.renderer;
21
22
import net.minecraft.client.input.InputQuirks;
23
import net.minecraft.client.renderer.MappableRingBuffer;
24
import org.jspecify.annotations.NullMarked;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.ModifyArg;
28
29
@NullMarked
30
@Mixin(MappableRingBuffer.class)
31
public abstract class MixinMappableRingBuffer {
32
33
    /**
34
     * <a href="https://github.com/CCBlueX/LiquidBounce/issues/7721">GitHub Issue</a>
35
     */
36
    @ModifyArg(
37
        method = "currentBuffer",
38
        at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/buffers/GpuFence;awaitCompletion(J)Z")
39
    )
40
    private long changeAwaitTimeout(long original) {
41
        if (InputQuirks.REPLACE_CTRL_KEY_WITH_CMD_KEY) {
42
            return 50L;
43
        }
44
        return original;
45
    }
46
}
47
MixinShaderManagersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/renderer/MixinShaderManager.javaJava · 38 lines · 1.5 KB
@Mixin(ShaderManager.class)
MixinShaderManager.javaJava · 38 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client.renderer;
21
22
import net.ccbluex.liquidbounce.render.ClientRenderPipelines;
23
import net.minecraft.client.renderer.ShaderManager;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.Inject;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28
29
@Mixin(ShaderManager.class)
30
public abstract class MixinShaderManager {
31
32
    @Inject(method = "apply(Lnet/minecraft/client/renderer/ShaderManager$Configs;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("TAIL"))
33
    private void reloadClientPipelines(CallbackInfo info) {
34
        ClientRenderPipelines.INSTANCE.precompile();
35
    }
36
37
}
38
MixinSoundManagerPreparationssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/sounds/MixinSoundManagerPreparations.javaJava · 43 lines · 1.8 KB
@Mixin(targets = "net.minecraft.client.sounds.SoundManager$Preparations")
MixinSoundManagerPreparations.javaJava · 43 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client.sounds;
20
21
import net.ccbluex.liquidbounce.features.module.modules.render.hitfx.HitFXRegistry;
22
import net.minecraft.client.sounds.SoundEngine;
23
import net.minecraft.client.sounds.WeighedSoundEvents;
24
import net.minecraft.resources.Identifier;
25
import net.minecraft.server.packs.resources.Resource;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
import org.spongepowered.asm.mixin.injection.Inject;
29
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
30
31
import java.util.Map;
32
33
@Mixin(targets = "net.minecraft.client.sounds.SoundManager$Preparations")
34
public abstract class MixinSoundManagerPreparations {
35
36
    @Inject(method = "apply", at = @At("TAIL"))
37
    private void hookClientSounds(Map<Identifier, WeighedSoundEvents> registry, Map<Identifier, Resource> soundCache,
38
                                  SoundEngine engine, CallbackInfo ci) {
39
        HitFXRegistry.registerSounds(registry, soundCache);
40
    }
41
42
}
43
MixinAbstractClientPlayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinAbstractClientPlayer.javaJava · 82 lines · 3.6 KB
@Mixin(AbstractClientPlayer.class)
MixinAbstractClientPlayer.javaJava · 82 lines · 3.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import com.mojang.authlib.GameProfile;
24
import net.ccbluex.liquidbounce.features.module.modules.exploit.disabler.ModuleDisabler;
25
import net.ccbluex.liquidbounce.features.module.modules.exploit.disabler.disablers.DisablerVulcanScaffold;
26
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleNoFov;
27
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleSkinChanger;
28
import net.minecraft.client.Minecraft;
29
import net.minecraft.client.player.AbstractClientPlayer;
30
import net.minecraft.world.entity.player.Player;
31
import net.minecraft.world.entity.player.PlayerSkin;
32
import net.minecraft.world.level.Level;
33
import org.spongepowered.asm.mixin.Mixin;
34
import org.spongepowered.asm.mixin.injection.At;
35
import org.spongepowered.asm.mixin.injection.Inject;
36
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
37
38
@Mixin(AbstractClientPlayer.class)
39
public abstract class MixinAbstractClientPlayer extends Player {
40
41
    public MixinAbstractClientPlayer(Level world, GameProfile gameProfile) {
42
        super(world, gameProfile);
43
    }
44
45
    @ModifyReturnValue(method = "getFieldOfViewModifier", at = @At("RETURN"))
46
    private float injectFovMultiplier(float original) {
47
        if (ModuleNoFov.INSTANCE.getRunning()) {
48
            return ModuleNoFov.INSTANCE.getFovMultiplier(original);
49
        }
50
        return original;
51
    }
52
53
    @ModifyExpressionValue(method = "getFieldOfViewModifier", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/AbstractClientPlayer;getAttributeValue(Lnet/minecraft/core/Holder;)D"))
54
    private double injectAlwaysSprint(double original) {
55
        if (ModuleDisabler.INSTANCE.getRunning() && DisablerVulcanScaffold.INSTANCE.getRunning()) {
56
            return 0.10000000149011612D;
57
        }
58
        return original;
59
    }
60
61
    @Inject(method = "getSkin", at = @At("TAIL"), cancellable = true)
62
    private void injectCustomSkinTextures(CallbackInfoReturnable<PlayerSkin> cir) {
63
        Minecraft client = Minecraft.getInstance();
64
        if (client.level == null || client.player == null) return;
65
66
        if (this.getUUID().equals(client.player.getUUID()) && ModuleSkinChanger.shouldApplyChanges()) {
67
            var customSupplier = ModuleSkinChanger.INSTANCE.getSkinTextures();
68
            if (customSupplier != null) {
69
                PlayerSkin original = cir.getReturnValue();
70
                PlayerSkin customTextures = customSupplier.get();
71
                cir.setReturnValue(new PlayerSkin(
72
                        customTextures.body(),
73
                        original.cape(),
74
                        customTextures.elytra(),
75
                        customTextures.model(),
76
                        customTextures.secure()
77
                ));
78
            }
79
        }
80
    }
81
}
82
MixinAvatarsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinAvatar.javaJava · 45 lines · 1.9 KB
@Mixin(Avatar.class)
ModifiesAvatar
MixinAvatar.javaJava · 45 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleNoPose;
23
import net.minecraft.world.entity.Avatar;
24
import net.minecraft.world.entity.EntityDimensions;
25
import net.minecraft.world.entity.Pose;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
import org.spongepowered.asm.mixin.injection.Inject;
29
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
30
31
@Mixin(Avatar.class)
32
public abstract class MixinAvatar {
33
    /**
34
     * Sneak height fix
35
     * @see net.ccbluex.liquidbounce.features.module.modules.movement.ModuleNoPose
36
     */
37
    @Inject(method = "getDefaultDimensions", at = @At("RETURN"), cancellable = true)
38
    private void hookGetBaseDimensions(Pose pose, CallbackInfoReturnable<EntityDimensions> cir) {
39
        if (pose == Pose.CROUCHING) {
40
            var dimensions = ModuleNoPose.INSTANCE.modifySneakHeight();  /* If module/setting is not enabled, modifySneakHeight() returns null */
41
            if (dimensions != null) cir.setReturnValue(dimensions);
42
        }
43
    }
44
}
45
MixinClientAvatarStatesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinClientAvatarState.javaJava · 48 lines · 1.7 KB
@Mixin(ClientAvatarState.class)
MixinClientAvatarState.javaJava · 48 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import net.ccbluex.liquidbounce.event.EventManager;
23
import net.ccbluex.liquidbounce.event.events.PlayerStrideEvent;
24
import net.minecraft.client.entity.ClientAvatarState;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.Shadow;
27
import org.spongepowered.asm.mixin.injection.At;
28
import org.spongepowered.asm.mixin.injection.Inject;
29
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
30
31
@Mixin(ClientAvatarState.class)
32
public abstract class MixinClientAvatarState {
33
34
    @Shadow
35
    private float bob;
36
37
    /**
38
     * Hook player stride event
39
     */
40
    @Inject(method = "updateBob", at = @At(value = "RETURN"))
41
    private void hookStrideForce(float movement, CallbackInfo ci) {
42
        final PlayerStrideEvent event = new PlayerStrideEvent(this.bob);
43
        EventManager.INSTANCE.callEvent(event);
44
        this.bob = event.getStrideForce();
45
    }
46
47
}
48
MixinColorParticleOptionAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinColorParticleOptionAccessor.javaJava · 33 lines · 1.1 KB
@Mixin(ColorParticleOption.class)
MixinColorParticleOptionAccessor.javaJava · 33 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import net.minecraft.core.particles.ColorParticleOption;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.gen.Accessor;
25
26
@Mixin(ColorParticleOption.class)
27
public interface MixinColorParticleOptionAccessor {
28
29
    @Accessor("color")
30
    int getColor();
31
32
}
33
MixinCustomHeadLayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinCustomHeadLayer.javaJava · 46 lines · 2.2 KB
@Mixin(CustomHeadLayer.class)
MixinCustomHeadLayer.javaJava · 46 lines · 2.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import com.mojang.blaze3d.vertex.PoseStack;
23
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
24
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
25
import net.minecraft.client.renderer.SubmitNodeCollector;
26
import net.minecraft.client.renderer.entity.layers.CustomHeadLayer;
27
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
28
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33
34
@Mixin(CustomHeadLayer.class)
35
public abstract class MixinCustomHeadLayer<S extends LivingEntityRenderState> {
36
    @Inject(
37
            method = "submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;FF)V",
38
            at = @At("HEAD"),
39
            cancellable = true
40
    ) private void onRender(PoseStack matrixStack, SubmitNodeCollector orderedRenderCommandQueue, int i, S livingEntityRenderState, float f, float g, CallbackInfo ci) {
41
        if (livingEntityRenderState instanceof AvatarRenderState && !ModuleAntiBlind.canRender(DoRender.ARMOR)) {
42
            ci.cancel();
43
        }
44
    }
45
}
46
MixinEntitysrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinEntity.javaJava · 222 lines · 9.4 KB
@Mixin(Entity.class)
ModifiesEntity
MixinEntity.javaJava · 222 lines · 9.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
24
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
25
import com.llamalad7.mixinextras.sugar.Local;
26
import net.ccbluex.liquidbounce.event.EventManager;
27
import net.ccbluex.liquidbounce.event.events.*;
28
import net.ccbluex.liquidbounce.features.module.modules.exploit.ModuleNoPitchLimit;
29
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleAntiBounce;
30
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleNoPose;
31
import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.slime.NoSlowSlime;
32
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFreeCam;
33
import net.minecraft.client.Minecraft;
34
import net.minecraft.tags.TagKey;
35
import net.minecraft.world.entity.Entity;
36
import net.minecraft.world.entity.Pose;
37
import net.minecraft.world.level.Level;
38
import net.minecraft.world.level.block.SlimeBlock;
39
import net.minecraft.world.level.block.state.BlockState;
40
import net.minecraft.world.level.material.Fluid;
41
import net.minecraft.world.phys.Vec3;
42
import org.objectweb.asm.Opcodes;
43
import org.spongepowered.asm.mixin.Mixin;
44
import org.spongepowered.asm.mixin.Shadow;
45
import org.spongepowered.asm.mixin.Unique;
46
import org.spongepowered.asm.mixin.injection.At;
47
import org.spongepowered.asm.mixin.injection.Inject;
48
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
49
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
50
51
@Mixin(Entity.class)
52
public abstract class MixinEntity {
53
54
    @Shadow
55
    public boolean noPhysics;
56
57
    @Shadow
58
    public abstract boolean onGround();
59
60
    @Shadow
61
    public abstract boolean isPassenger();
62
63
    @Shadow
64
    public abstract Level level();
65
66
    @Shadow
67
    public abstract double getX();
68
69
    @Shadow
70
    public abstract double getY();
71
72
    @Shadow
73
    public abstract double getZ();
74
75
    @Shadow public abstract float getYRot();
76
77
    @Unique
78
    protected boolean liquid_bounce$isClientPlayer() {
79
        return (Object) this == Minecraft.getInstance().player;
80
    }
81
82
    @ModifyExpressionValue(method = "isSuppressingBounce", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;isShiftKeyDown()Z"))
83
    private boolean hookAntiBounce(boolean original) {
84
        return ModuleAntiBounce.INSTANCE.getRunning() || original;
85
    }
86
87
    @ModifyExpressionValue(method = "restituteMovementAfterCollisions", at = @At(value = "INVOKE", target = "Ljava/lang/Math;max(DD)D", remap = false))
88
    private double hookSlimeBounce(double original, @Local(argsOnly = true, name = "effectState") BlockState effectState) {
89
        // TODO(26.2): Re-check the old exact Y-velocity conditions after vanilla moved slime bounce into Entity restitution.
90
        if (NoSlowSlime.INSTANCE.getRunning() && effectState.getBlock() instanceof SlimeBlock) {
91
            return 0.0;
92
        }
93
94
        return original;
95
    }
96
97
    /**
98
     * Hook entity margin modification event
99
     */
100
    @Inject(method = "getPickRadius", at = @At("RETURN"), cancellable = true)
101
    private void hookMargin(CallbackInfoReturnable<Float> callback) {
102
        EntityMarginEvent marginEvent = new EntityMarginEvent((Entity) (Object) this, callback.getReturnValue());
103
        EventManager.INSTANCE.callEvent(marginEvent);
104
        callback.setReturnValue(marginEvent.getMargin());
105
    }
106
107
    /**
108
     * Hook no pitch limit exploit
109
     */
110
    @WrapOperation(method = {"turn", "absSnapRotationTo"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;clamp(FFF)F"))
111
    public float hookNoPitchLimit1(float value, float min, float max, Operation<Float> original) {
112
        boolean noLimit = ModuleNoPitchLimit.INSTANCE.getRunning();
113
        return noLimit ? value : original.call(value, min, max);
114
    }
115
116
    @WrapOperation(method = "setXRot", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Entity;xRot:F", opcode = Opcodes.PUTFIELD))
117
    public void hookNoPitchLimit2(Entity instance, float clamped, Operation<Void> original, @Local(argsOnly = true, name = "xRot") float xRot) {
118
        boolean noLimit = ModuleNoPitchLimit.INSTANCE.getRunning();
119
        original.call(instance, noLimit ? xRot : clamped);
120
    }
121
122
    @ModifyExpressionValue(method = "moveRelative", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getInputVector(Lnet/minecraft/world/phys/Vec3;FF)Lnet/minecraft/world/phys/Vec3;"))
123
    public Vec3 hookVelocity(Vec3 original, @Local(argsOnly = true, name = "input") Vec3 input, @Local(argsOnly = true, name = "speed") float speed) {
124
        if (!liquid_bounce$isClientPlayer()) {
125
            return original;
126
        }
127
128
        var event = new PlayerVelocityStrafe(input, speed, this.getYRot(), original);
129
        EventManager.INSTANCE.callEvent(event);
130
        return event.getVelocity();
131
    }
132
133
    @ModifyExpressionValue(method = "collide(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;maxUpStep()F"))
134
    private float hookStepHeight(float original) {
135
        if (!liquid_bounce$isClientPlayer()) {
136
            return original;
137
        }
138
139
        var stepEvent = new PlayerStepEvent(original);
140
        EventManager.INSTANCE.callEvent(stepEvent);
141
        return stepEvent.getHeight();
142
    }
143
144
    @Inject(method = "collide(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;",
145
            at = @At(value = "RETURN", ordinal = 0), cancellable = true)
146
    private void hookStepHeight(Vec3 movement, CallbackInfoReturnable<Vec3> cir) {
147
        if (liquid_bounce$isClientPlayer()) {
148
            PlayerStepSuccessEvent movementCollisionsEvent = new PlayerStepSuccessEvent(movement, cir.getReturnValue());
149
            EventManager.INSTANCE.callEvent(movementCollisionsEvent);
150
            cir.setReturnValue(movementCollisionsEvent.getAdjustedVec());
151
        }
152
    }
153
154
    /**
155
     * When modules that modify player's velocity are enabled while on a vehicle, the game essentially gets screwed up, making the player unable to move.
156
     * <p>
157
     * With this injection, the issue is solved.
158
     */
159
    @Inject(method = "setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V", at = @At("HEAD"), cancellable = true)
160
    private void hookVelocityDuringRidingPrevention(Vec3 velocity, CallbackInfo ci) {
161
        if (!liquid_bounce$isClientPlayer()) {
162
            return;
163
        }
164
165
        if (isPassenger()) {
166
            ci.cancel();
167
        }
168
    }
169
170
    @Inject(method = "isEyeInFluid", at = @At("HEAD"), cancellable = true)
171
    private void hookIsSubmergedIn(TagKey<Fluid> fluidTag, CallbackInfoReturnable<Boolean> cir) {
172
        if (liquid_bounce$isClientPlayer()) {
173
            var event = EventManager.INSTANCE.callEvent(new PlayerFluidCollisionCheckEvent(fluidTag));
174
175
            if (event.isCancelled()) {
176
                cir.setReturnValue(false);
177
            }
178
        }
179
    }
180
181
    /**
182
     * Restores client-side fall distance calculation that was disabled
183
     * after Minecraft 1.21.4 (or 1.21.3, I don't know)
184
     * <p>
185
     * The vanilla game stopped calculating fall distance on the client side due to
186
     * PlayerEntity always returning true for isControlledByPlayer(). This modification
187
     * enables fall distance calculation by returning false when the entity is
188
     * the client's player instance.
189
     * <p>
190
     * Because we don't know if this might also break something else, when we would overwrite
191
     * the function to always return false, we only return false on fall distance calculation.
192
     *
193
     * @return false if the entity is the client's player, otherwise returns the original value
194
     */
195
    @ModifyExpressionValue(method = "isLocalInstanceAuthoritative", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;isClientAuthoritative()Z"))
196
    private boolean fixFallDistanceCalculation(boolean original) {
197
        if (liquid_bounce$isClientPlayer()) {
198
            return false;
199
        }
200
201
        return original;
202
    }
203
204
    @Inject(method = "setPose", at = @At("HEAD"), cancellable = true)
205
    private void setPose(Pose pose, CallbackInfo ci) {
206
        /* Cancel pose if needed */
207
        if (liquid_bounce$isClientPlayer() && ModuleNoPose.INSTANCE.shouldCancelPose(pose))
208
            ci.cancel();
209
    }
210
211
    @Inject(method = "turn", at = @At("HEAD"), cancellable = true)
212
    private void hookFreeCamRotation(double xo, double yo, CallbackInfo ci) {
213
        if ((Object) this != Minecraft.getInstance().player) return;
214
215
        if (ModuleFreeCam.PositionState.INSTANCE.getAvailable()) {
216
            ModuleFreeCam.PositionState.INSTANCE.rotation(xo * 0.15f, yo * 0.15f);
217
            ci.cancel();
218
        }
219
    }
220
221
}
222
MixinEntityAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinEntityAccessor.javaJava · 38 lines · 1.2 KB
@Mixin(Entity.class)
ModifiesEntity
MixinEntityAccessor.javaJava · 38 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import net.minecraft.world.entity.Entity;
23
import net.minecraft.world.phys.Vec3;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.gen.Accessor;
26
27
@Mixin(Entity.class)
28
public interface MixinEntityAccessor {
29
    @Accessor("position")
30
    void position(Vec3 position);
31
32
    @Accessor("xRot")
33
    void xRot(float xRot);
34
35
    @Accessor("yRot")
36
    void yRot(float yRot);
37
}
38
MixinEntityFluidInteractionsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinEntityFluidInteraction.javaJava · 68 lines · 2.8 KB
@Mixin(EntityFluidInteraction.class)
MixinEntityFluidInteraction.javaJava · 68 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.ccbluex.liquidbounce.event.EventManager;
25
import net.ccbluex.liquidbounce.event.events.PlayerFluidCollisionCheckEvent;
26
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleNoPush;
27
import net.ccbluex.liquidbounce.features.module.modules.movement.NoPushBy;
28
import net.minecraft.client.Minecraft;
29
import net.minecraft.tags.TagKey;
30
import net.minecraft.world.entity.Entity;
31
import net.minecraft.world.entity.EntityFluidInteraction;
32
import net.minecraft.world.level.material.Fluid;
33
import net.minecraft.world.phys.Vec3;
34
import org.jspecify.annotations.NullMarked;
35
import org.spongepowered.asm.mixin.Mixin;
36
import org.spongepowered.asm.mixin.injection.At;
37
import org.spongepowered.asm.mixin.injection.Inject;
38
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
39
40
@NullMarked
41
@Mixin(EntityFluidInteraction.class)
42
public abstract class MixinEntityFluidInteraction {
43
44
    @Inject(method = "applyCurrentTo", at = @At(value = "HEAD"), cancellable = true)
45
    private void hookFluidMovement(TagKey<Fluid> fluid, Entity entity, double scale, CallbackInfo ci) {
46
        if (entity != Minecraft.getInstance().player) {
47
            return;
48
        }
49
50
        var event = EventManager.INSTANCE.callEvent(new PlayerFluidCollisionCheckEvent(fluid));
51
52
        if (event.isCancelled()) {
53
            ci.cancel();
54
        }
55
    }
56
57
    @ModifyExpressionValue(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/material/FluidState;getFlow(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;"))
58
    private Vec3 hookNoPushInLiquids(Vec3 original, @Local(argsOnly = true, name = "entity") Entity entity) {
59
        if (entity != Minecraft.getInstance().player) {
60
            return original;
61
        }
62
63
        return ModuleNoPush.canPush(NoPushBy.LIQUIDS)
64
            ? original : Vec3.ZERO;
65
    }
66
67
}
68
MixinEntityFluidInteractionAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinEntityFluidInteractionAccessor.javaJava · 38 lines · 1.3 KB
@Mixin(EntityFluidInteraction.class)
MixinEntityFluidInteractionAccessor.javaJava · 38 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import java.util.Map;
23
import net.minecraft.tags.TagKey;
24
import net.minecraft.world.entity.EntityFluidInteraction;
25
import net.minecraft.world.level.material.Fluid;
26
import org.jspecify.annotations.NullMarked;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.gen.Accessor;
29
30
@NullMarked
31
@Mixin(EntityFluidInteraction.class)
32
public interface MixinEntityFluidInteractionAccessor {
33
34
    @Accessor("trackerByFluid")
35
    Map<TagKey<Fluid>, Object> trackerByFluid();
36
37
}
38
MixinEntityFluidInteractionTrackerAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinEntityFluidInteractionTrackerAccessor.javaJava · 56 lines · 1.6 KB
@Mixin(targets = "net.minecraft.world.entity.EntityFluidInteraction$Tracker")
MixinEntityFluidInteractionTrackerAccessor.javaJava · 56 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import net.minecraft.world.phys.Vec3;
23
import org.jspecify.annotations.NullMarked;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.gen.Accessor;
26
27
@NullMarked
28
@Mixin(targets = "net.minecraft.world.entity.EntityFluidInteraction$Tracker")
29
public interface MixinEntityFluidInteractionTrackerAccessor {
30
31
    @Accessor("height")
32
    double height();
33
34
    @Accessor("height")
35
    void height(double height);
36
37
    @Accessor("eyesInside")
38
    boolean eyesInside();
39
40
    @Accessor("eyesInside")
41
    void eyesInside(boolean eyesInside);
42
43
    @Accessor("accumulatedCurrent")
44
    Vec3 accumulatedCurrent();
45
46
    @Accessor("accumulatedCurrent")
47
    void accumulatedCurrent(Vec3 accumulatedCurrent);
48
49
    @Accessor("currentCount")
50
    int currentCount();
51
52
    @Accessor("currentCount")
53
    void currentCount(int currentCount);
54
55
}
56
MixinExperienceOrbAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinExperienceOrbAccessor.javaJava · 32 lines · 1.1 KB
@Mixin(ExperienceOrb.class)
MixinExperienceOrbAccessor.javaJava · 32 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import net.minecraft.world.entity.ExperienceOrb;
23
import net.minecraft.world.entity.player.Player;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.gen.Accessor;
26
27
@Mixin(ExperienceOrb.class)
28
public interface MixinExperienceOrbAccessor {
29
    @Accessor("followingPlayer")
30
    Player getFollowingPlayer();
31
}
32
MixinFoodDatasrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinFoodData.javaJava · 37 lines · 1.3 KB
@Mixin(FoodData.class)
ModifiesFoodData
MixinFoodData.javaJava · 37 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleSprint;
24
import net.minecraft.world.food.FoodData;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
28
@Mixin(FoodData.class)
29
public abstract class MixinFoodData {
30
31
    @ModifyReturnValue(method = "hasEnoughFood", at = @At("RETURN"))
32
    private boolean canSprint(boolean original) {
33
        return original || ModuleSprint.INSTANCE.getShouldIgnoreHunger();
34
    }
35
36
}
37
MixinHumanoidArmorLayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinHumanoidArmorLayer.javaJava · 48 lines · 2.1 KB
@Mixin(HumanoidArmorLayer.class)
MixinHumanoidArmorLayer.javaJava · 48 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import com.mojang.blaze3d.vertex.PoseStack;
23
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
24
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
25
import net.minecraft.client.renderer.SubmitNodeCollector;
26
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
27
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
28
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
29
import net.minecraft.world.entity.EquipmentSlot;
30
import net.minecraft.world.item.ItemStack;
31
import org.spongepowered.asm.mixin.Mixin;
32
import org.spongepowered.asm.mixin.injection.At;
33
import org.spongepowered.asm.mixin.injection.Inject;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
35
36
@Mixin(HumanoidArmorLayer.class)
37
public abstract class MixinHumanoidArmorLayer<S extends HumanoidRenderState> {
38
    @Inject(
39
            method = "renderArmorPiece",
40
            at = @At("HEAD"),
41
            cancellable = true
42
    ) private void onRender(PoseStack matrices, SubmitNodeCollector orderedRenderCommandQueue, ItemStack stack, EquipmentSlot slot, int light, S bipedEntityRenderState, CallbackInfo ci) {
43
        if (bipedEntityRenderState instanceof AvatarRenderState && !ModuleAntiBlind.canRender(DoRender.ARMOR)) {
44
            ci.cancel();
45
        }
46
    }
47
}
48
MixinInterpolationHandlersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinInterpolationHandler.javaJava · 47 lines · 1.7 KB
@Mixin(InterpolationHandler.class)
MixinInterpolationHandler.javaJava · 47 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import net.ccbluex.liquidbounce.features.module.modules.world.ModuleNoInterpolation;
23
import net.minecraft.world.entity.InterpolationHandler;
24
import org.objectweb.asm.Opcodes;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
28
@Mixin(InterpolationHandler.class)
29
public abstract class MixinInterpolationHandler {
30
31
    @ModifyExpressionValue(
32
        method = "interpolateTo",
33
        at = @At(
34
            value = "FIELD",
35
            target = "Lnet/minecraft/world/entity/InterpolationHandler;interpolationSteps:I",
36
            opcode = Opcodes.GETFIELD
37
        )
38
    )
39
    private int hookInterpolationSteps(int original) {
40
        if (ModuleNoInterpolation.INSTANCE.getRunning()) {
41
            return Math.max(original - ModuleNoInterpolation.INSTANCE.getValue(), 0);
42
        }
43
        return original;
44
    }
45
46
}
47
MixinInventorysrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinInventory.javaJava · 64 lines · 2.4 KB
@Mixin(Inventory.class)
ModifiesInventory
MixinInventory.javaJava · 64 lines · 2.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import net.ccbluex.liquidbounce.additions.InventoryAddition;
24
import net.ccbluex.liquidbounce.utils.client.SilentHotbar;
25
import net.minecraft.client.Minecraft;
26
import net.minecraft.world.entity.player.Inventory;
27
import net.minecraft.world.entity.player.Player;
28
import org.objectweb.asm.Opcodes;
29
import org.spongepowered.asm.mixin.Final;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.Shadow;
32
import org.spongepowered.asm.mixin.Unique;
33
import org.spongepowered.asm.mixin.injection.At;
34
35
@Mixin(Inventory.class)
36
public abstract class MixinInventory implements InventoryAddition {
37
38
    @Shadow
39
    private int selected;
40
    @Shadow
41
    @Final
42
    public Player player;
43
44
    /**
45
     * Override the original slot based on the server-side slot information.
46
     *
47
     * @see net.minecraft.world.entity.player.Inventory#getSelectedItem()
48
     * @see net.minecraft.world.entity.player.Inventory#setSelectedItem(net.minecraft.world.item.ItemStack)
49
     */
50
    @ModifyExpressionValue(
51
            method = {"removeFromSelected", "tick", "getSelectedItem", "setSelectedItem"},
52
            at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/player/Inventory;selected:I", opcode = Opcodes.GETFIELD)
53
    )
54
    private int hookOverrideOriginalSlot(int original) {
55
        return ((Inventory) (Object) this).player == Minecraft.getInstance().player ? SilentHotbar.INSTANCE.getServersideSlot() : original;
56
    }
57
58
    @Unique
59
    @Override
60
    public int liquid_bounce$getRealSelectedSlot() {
61
        return this.selected;
62
    }
63
}
64
MixinLivingEntitysrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinLivingEntity.javaJava · 381 lines · 14.3 KB
@Mixin(LivingEntity.class)
ModifiesLivingEntity
MixinLivingEntity.javaJava · 381 lines · 14.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import net.ccbluex.liquidbounce.event.EventManager;
24
import net.ccbluex.liquidbounce.event.events.EntityEquipmentChangeEvent;
25
import net.ccbluex.liquidbounce.event.events.EntityHealthUpdateEvent;
26
import net.ccbluex.liquidbounce.event.events.PlayerAfterJumpEvent;
27
import net.ccbluex.liquidbounce.event.events.PlayerJumpEvent;
28
import net.ccbluex.liquidbounce.features.module.modules.combat.elytratarget.ModuleElytraTarget;
29
import net.ccbluex.liquidbounce.features.module.modules.movement.*;
30
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
31
import net.ccbluex.liquidbounce.features.module.modules.render.animations.ModuleAnimations;
32
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
33
import net.ccbluex.liquidbounce.features.module.modules.render.hitfx.ModuleHitFX;
34
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold;
35
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.tower.ScaffoldTowerNone;
36
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
37
import net.ccbluex.liquidbounce.utils.aiming.features.MovementCorrection;
38
import net.ccbluex.liquidbounce.utils.client.SilentHotbar;
39
import net.minecraft.client.Minecraft;
40
import net.minecraft.client.player.LocalPlayer;
41
import net.minecraft.core.Holder;
42
import net.minecraft.core.component.DataComponents;
43
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
44
import net.minecraft.sounds.SoundEvent;
45
import net.minecraft.sounds.SoundEvents;
46
import net.minecraft.sounds.SoundSource;
47
import net.minecraft.util.Mth;
48
import net.minecraft.world.InteractionHand;
49
import net.minecraft.world.effect.MobEffect;
50
import net.minecraft.world.effect.MobEffectInstance;
51
import net.minecraft.world.effect.MobEffects;
52
import net.minecraft.world.entity.EquipmentSlot;
53
import net.minecraft.world.entity.LivingEntity;
54
import net.minecraft.world.item.ItemStack;
55
import net.minecraft.world.phys.Vec3;
56
import org.jspecify.annotations.Nullable;
57
import org.objectweb.asm.Opcodes;
58
import org.spongepowered.asm.mixin.Mixin;
59
import org.spongepowered.asm.mixin.Shadow;
60
import org.spongepowered.asm.mixin.Unique;
61
import org.spongepowered.asm.mixin.injection.At;
62
import org.spongepowered.asm.mixin.injection.Inject;
63
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
64
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
65
66
@Mixin(LivingEntity.class)
67
public abstract class MixinLivingEntity extends MixinEntity {
68
69
    @Shadow
70
    public boolean jumping;
71
72
    @Shadow
73
    public int noJumpDelay;
74
75
    @Shadow
76
    public abstract float getJumpPower();
77
78
    @Shadow
79
    public abstract void jumpFromGround();
80
81
    @Shadow
82
    public abstract boolean hasEffect(Holder<MobEffect> effect);
83
84
    @Shadow
85
    public abstract void tick();
86
87
    @Shadow
88
    public abstract void swing(InteractionHand hand, boolean sendToSwingingEntity);
89
90
    @Shadow
91
    public abstract void setHealth(float health);
92
93
    @Shadow
94
    public abstract boolean isFallFlying();
95
96
    @Shadow
97
    protected abstract boolean canGlide();
98
99
    @Shadow
100
    public abstract float getHealth();
101
102
    @Shadow
103
    public abstract float getMaxHealth();
104
105
    @ModifyReturnValue(method = "getMainHandItem", at = @At("RETURN"))
106
    private ItemStack applySilentHotbarForMainHand(ItemStack original) {
107
        var player = Minecraft.getInstance().player;
108
        if ((Object) this == player) {
109
            return player.getInventory().getNonEquipmentItems().get(SilentHotbar.INSTANCE.getServersideSlot());
110
        }
111
112
        return original;
113
    }
114
115
    /**
116
     * Disable [StatusEffects.LEVITATION] effect when [ModuleAntiLevitation] is enabled
117
     */
118
    @ModifyExpressionValue(
119
            method = "travelInAir",
120
            at = @At(
121
                    value = "INVOKE",
122
                    target = "Lnet/minecraft/world/entity/LivingEntity;getEffect(Lnet/minecraft/core/Holder;)Lnet/minecraft/world/effect/MobEffectInstance;",
123
                    ordinal = 0
124
            ),
125
            require = 1,
126
            allow = 1
127
    )
128
    public @Nullable MobEffectInstance hookTravelStatusEffect(@Nullable MobEffectInstance original) {
129
        if (original == null) {
130
            return null;
131
        }
132
133
        // If we get anything other than levitation, the injection went wrong
134
        assert original.getEffect() == MobEffects.LEVITATION;
135
136
        if (ModuleAntiLevitation.INSTANCE.getRunning()) {
137
            return null;
138
        }
139
140
        return original;
141
    }
142
143
    /**
144
     * Disable [StatusEffects.SLOW_FALLING] effect when [ModuleAntiLevitation] is enabled
145
     */
146
    @ModifyExpressionValue(
147
            method = "getEffectiveGravity",
148
            at = @At(
149
                    value = "INVOKE",
150
                    target = "Lnet/minecraft/world/entity/LivingEntity;hasEffect(Lnet/minecraft/core/Holder;)Z",
151
                    ordinal = 0
152
            ),
153
            require = 1,
154
            allow = 1
155
    )
156
    public boolean hookTravelStatusEffect(boolean original) {
157
        if (ModuleAntiLevitation.INSTANCE.getRunning()) {
158
            return false;
159
        }
160
161
        return original;
162
    }
163
164
    @Unique
165
    private PlayerJumpEvent jumpEvent;
166
167
    @Inject(method = "jumpFromGround", at = @At("HEAD"), cancellable = true)
168
    private void hookJumpEvent(CallbackInfo ci) {
169
        if (!liquid_bounce$isClientPlayer()) {
170
            return;
171
        }
172
173
        jumpEvent = EventManager.INSTANCE.callEvent(new PlayerJumpEvent(getJumpPower(), this.getYRot()));
174
        if (jumpEvent.isCancelled()) {
175
            ci.cancel();
176
        }
177
    }
178
179
    @ModifyExpressionValue(method = "jumpFromGround", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getJumpPower()F"))
180
    private float hookJumpEvent(float original) {
181
        // Replaces ((Object) this) != MinecraftClient.getInstance().player
182
        if (jumpEvent == null) {
183
            return original;
184
        }
185
186
        return jumpEvent.getMotion();
187
    }
188
189
    @ModifyExpressionValue(method = "jumpFromGround", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getYRot()F"))
190
    private float hookJumpYaw(float original) {
191
        // Replaces ((Object) this) != MinecraftClient.getInstance().player
192
        if (jumpEvent == null) {
193
            return original;
194
        }
195
196
        return jumpEvent.getYaw();
197
    }
198
199
    @Inject(method = "jumpFromGround", at = @At("RETURN"))
200
    private void hookAfterJumpEvent(CallbackInfo ci) {
201
        jumpEvent = null;
202
203
        if (!liquid_bounce$isClientPlayer()) {
204
            return;
205
        }
206
207
        EventManager.INSTANCE.callEvent(PlayerAfterJumpEvent.INSTANCE);
208
    }
209
210
    /**
211
     * Hook velocity rotation modification
212
     * <p>
213
     * Jump according to modified rotation. Prevents detection by movement sensitive anticheats.
214
     */
215
    @ModifyExpressionValue(method = "jumpFromGround", at = @At(value = "NEW", target = "(DDD)Lnet/minecraft/world/phys/Vec3;"))
216
    private Vec3 hookFixRotation(Vec3 original) {
217
        var rotation = RotationManager.INSTANCE.getCurrentRotation();
218
        var rotationTarget = RotationManager.INSTANCE.getActiveRotationTarget();
219
220
        if (!liquid_bounce$isClientPlayer()) {
221
            return original;
222
        }
223
224
        if (rotationTarget == null || rotationTarget.getMovementCorrection() == MovementCorrection.OFF || rotation == null) {
225
            return original;
226
        }
227
228
        float yaw = rotation.yaw() * Mth.DEG_TO_RAD;
229
230
        return new Vec3(-Mth.sin(yaw) * 0.2F, 0.0, Mth.cos(yaw) * 0.2F);
231
    }
232
233
    @Inject(method = "aiStep", at = @At("HEAD"))
234
    private void hookTickMovement(CallbackInfo callbackInfo) {
235
        // We don't want NoJumpDelay to interfere with AirJump which would lead to a Jetpack-like behavior
236
        var noJumpDelay = ModuleNoJumpDelay.INSTANCE.getRunning() && !ModuleAirJump.INSTANCE.getAllowJump();
237
238
        // The jumping cooldown would lead to very slow tower building
239
        var towerActive = ModuleScaffold.INSTANCE.getRunning() &&
240
                ModuleScaffold.INSTANCE.getTowerMode().getActiveMode() != ScaffoldTowerNone.INSTANCE &&
241
                ModuleScaffold.INSTANCE.getTowerMode().getActiveMode().getRunning();
242
243
        if (noJumpDelay || towerActive) {
244
            this.noJumpDelay = 0;
245
        }
246
    }
247
248
    @Inject(method = "aiStep", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/LivingEntity;jumping:Z", opcode = Opcodes.GETFIELD))
249
    private void hookAirJump(CallbackInfo callbackInfo) {
250
        if (ModuleAirJump.INSTANCE.getAllowJump() && jumping && noJumpDelay == 0) {
251
            this.jumpFromGround();
252
            noJumpDelay = 10;
253
        }
254
    }
255
256
    @Unique
257
    private boolean previousElytra = false;
258
259
    @Inject(method = "aiStep", at = @At("TAIL"))
260
    public void recastIfLanded(CallbackInfo callbackInfo) {
261
        if (!liquid_bounce$isClientPlayer()) {
262
            return;
263
        }
264
265
        var elytra = isFallFlying();
266
        if (ModuleElytraRecast.INSTANCE.getRunning() && previousElytra && !elytra) {
267
            Minecraft.getInstance().getSoundManager().stop(SoundEvents.ELYTRA_FLYING.location(),
268
                    SoundSource.PLAYERS);
269
            ModuleElytraRecast.INSTANCE.recastElytra();
270
            noJumpDelay = 0;
271
        }
272
273
        previousElytra = elytra;
274
    }
275
276
    /**
277
     * Gliding using modified-rotation
278
     */
279
    @ModifyExpressionValue(method = "updateFallFlyingMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getXRot()F"))
280
    private float hookModifyFallFlyingPitch(float original) {
281
        if (!liquid_bounce$isClientPlayer()) {
282
            return original;
283
        }
284
285
        var rotation = RotationManager.INSTANCE.getCurrentRotation();
286
        var rotationTarget = RotationManager.INSTANCE.getActiveRotationTarget();
287
288
        if (rotation == null || rotationTarget == null || rotationTarget.getMovementCorrection() == MovementCorrection.OFF) {
289
            return original;
290
        }
291
292
        return rotation.pitch();
293
    }
294
295
    @Inject(method = "spawnItemParticles", at = @At("HEAD"), cancellable = true)
296
    private void hookEatParticles(ItemStack itemStack, int count, CallbackInfo ci) {
297
        if (itemStack.getComponents().has(DataComponents.FOOD) && !ModuleAntiBlind.canRender(DoRender.EAT_PARTICLES)) {
298
            ci.cancel();
299
        }
300
    }
301
302
    /**
303
     * Gliding using modified-rotation
304
     */
305
    @ModifyExpressionValue(method = "updateFallFlyingMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getLookAngle()Lnet/minecraft/world/phys/Vec3;"))
306
    private Vec3 hookModifyFallFlyingRotationVector(Vec3 original) {
307
        if (!liquid_bounce$isClientPlayer()) {
308
            return original;
309
        }
310
311
        var rotation = RotationManager.INSTANCE.getCurrentRotation();
312
        var rotationTarget = RotationManager.INSTANCE.getActiveRotationTarget();
313
314
        if (rotation == null || rotationTarget == null || rotationTarget.getMovementCorrection() == MovementCorrection.OFF) {
315
            return original;
316
        }
317
318
        return rotation.directionVector();
319
    }
320
321
    @Unique
322
    private boolean previousIsGliding = false;
323
324
    @Inject(method = "isFallFlying", at = @At("RETURN"), cancellable = true)
325
    private void hookIsGliding(CallbackInfoReturnable<Boolean> cir) {
326
        if (!liquid_bounce$isClientPlayer()) {
327
            return;
328
        }
329
330
        var player = (LocalPlayer) (Object) this;
331
        var gliding = cir.getReturnValue();
332
333
        if (previousIsGliding && !gliding) {
334
            var flag = ModuleElytraTarget.canAlwaysGlide();
335
            if (flag) {
336
                player.startFallFlying();
337
                player.connection.send(new ServerboundPlayerCommandPacket(player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
338
            }
339
340
            cir.setReturnValue(flag);
341
        }
342
343
        previousIsGliding = gliding;
344
    }
345
346
    @Inject(method = "setHealth", at = @At("HEAD"))
347
    private void hookSetHealth(float health, CallbackInfo callbackInfo) {
348
        var oldHealth = this.getHealth();
349
        var maxHealth = this.getMaxHealth();
350
        var newHealth = Math.clamp(health, 0.0F, maxHealth);
351
352
        if (oldHealth != newHealth) {
353
            EventManager.INSTANCE.callEvent(new EntityHealthUpdateEvent((LivingEntity) (Object) this, oldHealth, newHealth, maxHealth));
354
        }
355
    }
356
357
    @Inject(method = "setItemSlot", at = @At("HEAD"))
358
    private void hookEquipmentChange(EquipmentSlot slot, ItemStack itemStack, CallbackInfo ci) {
359
        EventManager.INSTANCE.callEvent(new EntityEquipmentChangeEvent((LivingEntity) (Object) this, slot, itemStack));
360
    }
361
362
    @ModifyExpressionValue(method = "getCurrentSwingDuration", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/component/SwingAnimation;duration()I"), require = 0)
363
    private int hookSwingSpeed(int duration) {
364
        var animations = ModuleAnimations.INSTANCE;
365
        return animations.getRunning() && liquid_bounce$isClientPlayer() ? animations.getSwingDuration() : duration;
366
    }
367
368
    @ModifyExpressionValue(method = "handleDamageEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getHurtSound(Lnet/minecraft/world/damagesource/DamageSource;)Lnet/minecraft/sounds/SoundEvent;"))
369
    private SoundEvent hookHitFxSound(SoundEvent original) {
370
        if (liquid_bounce$isClientPlayer() && ModuleHitFX.INSTANCE.getRunning()) {
371
            var hitFxSound = ModuleHitFX.INSTANCE.getSelfSound();
372
            if (hitFxSound != null) {
373
                return hitFxSound;
374
            }
375
        }
376
377
        return original;
378
    }
379
380
}
381
MixinLocalPlayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinLocalPlayer.javaJava · 504 lines · 21.6 KB
@Mixin(LocalPlayer.class)
ModifiesLocalPlayer
MixinLocalPlayer.javaJava · 504 lines · 21.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
24
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
25
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
26
import net.ccbluex.liquidbounce.event.EventManager;
27
import net.ccbluex.liquidbounce.event.EventState;
28
import net.ccbluex.liquidbounce.event.events.*;
29
import net.ccbluex.liquidbounce.features.module.modules.exploit.ModulePortalMenu;
30
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleEntityControl;
31
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleNoPush;
32
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleSprint;
33
import net.ccbluex.liquidbounce.features.module.modules.movement.NoPushBy;
34
import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.ModuleNoSlow;
35
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleNoEntityInteract;
36
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleReach;
37
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFreeCam;
38
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleNoSwing;
39
import net.ccbluex.liquidbounce.features.module.modules.world.ModuleLiquidPlace;
40
import net.ccbluex.liquidbounce.integration.interop.protocol.rest.v1.game.PlayerData;
41
import net.ccbluex.liquidbounce.integration.interop.protocol.rest.v1.game.PlayerInventoryData;
42
import net.ccbluex.liquidbounce.integration.screen.ScreenManager;
43
import net.ccbluex.liquidbounce.interfaces.LocalPlayerAddition;
44
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
45
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation;
46
import net.ccbluex.liquidbounce.utils.movement.DirectionalInput;
47
import net.ccbluex.liquidbounce.utils.raytracing.EntityRaytracingKt;
48
import net.ccbluex.liquidbounce.utils.raytracing.RaytracingKt;
49
import net.minecraft.client.Minecraft;
50
import net.minecraft.client.gui.Gui;
51
import net.minecraft.client.gui.screens.Screen;
52
import net.minecraft.client.multiplayer.ClientPacketListener;
53
import net.minecraft.client.player.ClientInput;
54
import net.minecraft.client.player.LocalPlayer;
55
import net.minecraft.network.protocol.game.ServerboundSwingPacket;
56
import net.minecraft.world.InteractionHand;
57
import net.minecraft.world.entity.Entity;
58
import net.minecraft.world.entity.MoverType;
59
import net.minecraft.world.level.ClipContext;
60
import net.minecraft.world.phys.EntityHitResult;
61
import net.minecraft.world.phys.HitResult;
62
import net.minecraft.world.phys.Vec2;
63
import net.minecraft.world.phys.Vec3;
64
import org.jspecify.annotations.Nullable;
65
import org.objectweb.asm.Opcodes;
66
import org.spongepowered.asm.mixin.Final;
67
import org.spongepowered.asm.mixin.Mixin;
68
import org.spongepowered.asm.mixin.Shadow;
69
import org.spongepowered.asm.mixin.Unique;
70
import org.spongepowered.asm.mixin.injection.At;
71
import org.spongepowered.asm.mixin.injection.Inject;
72
import org.spongepowered.asm.mixin.injection.ModifyVariable;
73
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
74
75
@Mixin(LocalPlayer.class)
76
public abstract class MixinLocalPlayer extends MixinPlayer implements LocalPlayerAddition {
77
78
    @Shadow
79
    public ClientInput input;
80
81
    @Shadow
82
    @Final
83
    public ClientPacketListener connection;
84
85
    @Shadow
86
    public abstract boolean isUnderWater();
87
88
    @Unique
89
    private PlayerData lastKnownStatistics = null;
90
91
    @Unique
92
    private PlayerInventoryData lastKnownInventory = null;
93
94
    @Unique
95
    private PlayerNetworkMovementTickEvent eventMotion;
96
97
    @Unique
98
    private int onGroundTicks = 0;
99
    @Unique
100
    private int airTicks = 0;
101
102
    /**
103
     * Hook entity tick event
104
     */
105
    @Inject(method = "tick", at = @At(value = "INVOKE",
106
            target = "Lnet/minecraft/client/player/AbstractClientPlayer;tick()V",
107
            shift = At.Shift.BEFORE,
108
            ordinal = 0),
109
            cancellable = true)
110
    private void hookTickEvent(CallbackInfo ci) {
111
        var tickEvent = new PlayerTickEvent();
112
        EventManager.INSTANCE.callEvent(tickEvent);
113
114
        if (tickEvent.isCancelled()) {
115
            ci.cancel();
116
        }
117
    }
118
119
    @Inject(method = "tick", at = @At(value = "INVOKE",
120
            target = "Lnet/minecraft/client/player/AbstractClientPlayer;tick()V",
121
            shift = At.Shift.AFTER,
122
            ordinal = 0))
123
    private void hookPostTickEvent(CallbackInfo ci) {
124
        EventManager.INSTANCE.callEvent(PlayerPostTickEvent.INSTANCE);
125
126
        // Call player statistics change event when statistics change
127
        var statistics = PlayerData.Companion.fromPlayer((LocalPlayer) (Object) this);
128
        if (lastKnownStatistics == null || !lastKnownStatistics.equals(statistics)) {
129
            EventManager.INSTANCE.callEvent(new ClientPlayerDataEvent(statistics));
130
        }
131
        this.lastKnownStatistics = statistics;
132
133
        // Call player inventory event when inventory changes
134
        var playerInventory = PlayerInventoryData.Companion.fromPlayer((LocalPlayer) (Object) this);
135
        if (lastKnownInventory == null || !lastKnownInventory.equals(playerInventory)) {
136
            EventManager.INSTANCE.callEvent(new ClientPlayerInventoryEvent(playerInventory));
137
        }
138
        this.lastKnownInventory = playerInventory;
139
    }
140
141
    /**
142
     * Hook entity movement tick event
143
     */
144
    @Inject(method = "aiStep", at = @At("HEAD"), cancellable = true)
145
    private void hookMovementTickEvent(CallbackInfo callbackInfo) {
146
        var movementTickEvent = new PlayerMovementTickEvent();
147
        EventManager.INSTANCE.callEvent(movementTickEvent);
148
149
        if (movementTickEvent.isCancelled()) {
150
            callbackInfo.cancel();
151
        }
152
    }
153
154
    /**
155
     * Hook entity movement tick event at HEAD and call out PRE tick movement event
156
     */
157
    @Inject(method = "sendPosition", at = @At("HEAD"), cancellable = true)
158
    private void hookMovementPre(CallbackInfo callbackInfo) {
159
        LocalPlayer player = (LocalPlayer) (Object) this;
160
        eventMotion = new PlayerNetworkMovementTickEvent(EventState.PRE, player.getX(), player.getY(), player.getZ(), player.onGround());
161
        EventManager.INSTANCE.callEvent(eventMotion);
162
163
        if (eventMotion.isCancelled()) {
164
            callbackInfo.cancel();
165
        }
166
    }
167
168
    @ModifyExpressionValue(method = "sendPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getX()D"))
169
    private double modifyXPosition(double original) {
170
        return eventMotion.getX();
171
    }
172
173
    @ModifyExpressionValue(method = "sendPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getY()D"))
174
    private double modifyYPosition(double original) {
175
        return eventMotion.getY();
176
    }
177
178
    @ModifyExpressionValue(method = "sendPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getZ()D"))
179
    private double modifyZPosition(double original) {
180
        return eventMotion.getZ();
181
    }
182
183
    @ModifyExpressionValue(method = "sendPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;onGround()Z"))
184
    private boolean modifyOnGround(boolean original) {
185
        return eventMotion.getGround();
186
    }
187
188
    /**
189
     * Hook entity movement tick event at RETURN and call out POST tick movement event
190
     */
191
    @Inject(method = "sendPosition", at = @At("RETURN"))
192
    private void hookMovementPost(CallbackInfo callbackInfo) {
193
        LocalPlayer player = (LocalPlayer) (Object) this;
194
        EventManager.INSTANCE.callEvent(new PlayerNetworkMovementTickEvent(EventState.POST, player.getX(), player.getY(), player.getZ(), player.onGround()));
195
    }
196
197
    /**
198
     * Hook moveTowardsClosestSpace at HEAD and call PlayerPushoutEvent
199
     */
200
    @Inject(method = "moveTowardsClosestSpace", at = @At("HEAD"), cancellable = true)
201
    private void hookPushOut(double x, double z, CallbackInfo ci) {
202
        if (!ModuleNoPush.canPush(NoPushBy.BLOCKS)) {
203
            ci.cancel();
204
            return;
205
        }
206
207
        final PlayerPushOutEvent pushOutEvent = new PlayerPushOutEvent();
208
        EventManager.INSTANCE.callEvent(pushOutEvent);
209
        if (pushOutEvent.isCancelled()) {
210
            ci.cancel();
211
        }
212
    }
213
214
    /**
215
     * Hook move function to modify movement
216
     */
217
    @ModifyVariable(method = "move", at = @At("HEAD"), name = "delta", argsOnly = true)
218
    private Vec3 hookMove(Vec3 movement, MoverType type) {
219
        return EventManager.INSTANCE.callEvent(new PlayerMoveEvent(type, movement)).getMovement();
220
    }
221
222
    /**
223
     * Hook counter for on ground and air ticks
224
     */
225
    @Inject(method = "move", at = @At("RETURN"))
226
    private void hookGroundAirTimeCounters(CallbackInfo ci) {
227
        if (this.onGround()) {
228
            onGroundTicks++;
229
            airTicks = 0;
230
        } else {
231
            airTicks++;
232
            onGroundTicks = 0;
233
        }
234
    }
235
236
    @Override
237
    public int liquid_bounce$getOnGroundTicks() {
238
        return onGroundTicks;
239
    }
240
241
    @Override
242
    public int liquid_bounce$getAirTicks() {
243
        return airTicks;
244
    }
245
246
    /**
247
     * Hook portal menu module to make opening menus in portals possible
248
     */
249
    @ModifyExpressionValue(method = "handlePortalTransitionEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;isAllowedInPortal()Z"))
250
    private boolean hookNetherClosingScreen(boolean original) {
251
        if (ModulePortalMenu.INSTANCE.getRunning()) {
252
            return true;
253
        }
254
255
        return original;
256
    }
257
258
    /**
259
     * We change crossHairTarget according to server side rotations
260
     */
261
    @ModifyExpressionValue(method = "pick(Lnet/minecraft/world/entity/Entity;DDF)Lnet/minecraft/world/phys/HitResult;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;pick(DFZ)Lnet/minecraft/world/phys/HitResult;"))
262
    private static HitResult hookRaycast(HitResult original, Entity camera, double blockInteractionRange, double entityInteractionRange, float tickDelta) {
263
        if (camera != Minecraft.getInstance().player) {
264
            return original;
265
        }
266
267
        var cameraRotation = new Rotation(camera.getViewYRot(tickDelta), camera.getViewXRot(tickDelta), true);
268
269
        Rotation rotation;
270
        if (ModuleFreeCam.INSTANCE.getRunning()) {
271
            var serverRotation = RotationManager.INSTANCE.getServerRotation();
272
            rotation = ModuleFreeCam.INSTANCE.shouldDisableCameraInteract() ? serverRotation : cameraRotation;
273
        } else if (RotationManager.INSTANCE.getCurrentRotation() != null) {
274
            rotation = RotationManager.INSTANCE.getCurrentRotation();
275
        } else {
276
            rotation = cameraRotation;
277
        }
278
279
        // Through Walls Reach
280
        if (ModuleReach.INSTANCE.getRunning()) {
281
            var throughWallsRange = ModuleReach.INSTANCE.getEntity().getInteractionThroughWallsRange();
282
283
            if (throughWallsRange > 0.0) {
284
                var hitEntityResult = EntityRaytracingKt.findEntityInCrosshair(throughWallsRange, rotation, null);
285
286
                if (hitEntityResult != null && hitEntityResult.getType() == HitResult.Type.ENTITY) {
287
                    return hitEntityResult;
288
                }
289
            }
290
        }
291
292
293
        return RaytracingKt.traceFromPlayer(
294
            rotation,
295
            Math.max(blockInteractionRange, entityInteractionRange),
296
            ClipContext.Block.OUTLINE,
297
            ModuleLiquidPlace.INSTANCE.getRunning() ? ClipContext.Fluid.ANY : ClipContext.Fluid.NONE,
298
            tickDelta
299
        );
300
    }
301
302
    @ModifyExpressionValue(method = "pick(Lnet/minecraft/world/entity/Entity;DDF)Lnet/minecraft/world/phys/HitResult;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getViewVector(F)Lnet/minecraft/world/phys/Vec3;"))
303
    private static Vec3 hookRotationVector(Vec3 original, Entity camera, double blockInteractionRange, double entityInteractionRange, float tickDelta) {
304
        if (camera != Minecraft.getInstance().player) {
305
            return original;
306
        }
307
308
        var rotation = RotationManager.INSTANCE.getCurrentRotation();
309
        return rotation != null ? rotation.directionVector() : original;
310
    }
311
312
    @ModifyExpressionValue(method = "pick(Lnet/minecraft/world/entity/Entity;DDF)Lnet/minecraft/world/phys/HitResult;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/projectile/ProjectileUtil;getEntityHitResult(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;D)Lnet/minecraft/world/phys/EntityHitResult;"))
313
    private static @Nullable EntityHitResult hookEntityHitResult(@Nullable EntityHitResult original) {
314
        return original == null || !ModuleNoEntityInteract.INSTANCE.test(original) ? null : original;
315
    }
316
317
    /**
318
     * Hook custom sneaking multiplier
319
     */
320
    @ModifyExpressionValue(method = "modifyInput", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getAttributeValue(Lnet/minecraft/core/Holder;)D"))
321
    private double hookCustomSneakingMultiplier(double original) {
322
        var playerSneakMultiplier = new PlayerSneakMultiplier(original);
323
        EventManager.INSTANCE.callEvent(playerSneakMultiplier);
324
        return playerSneakMultiplier.getMultiplier();
325
    }
326
327
    /**
328
     * Hook custom multiplier
329
     *
330
     * <pre>
331
     * if (this.isUsingItem() && !this.hasVehicle()) {
332
     *     vec2f = vec2f.multiply(this.getActiveItemSpeedMultiplier());
333
     * }
334
     * </pre>
335
     */
336
    @WrapOperation(method = "modifyInput", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec2;scale(F)Lnet/minecraft/world/phys/Vec2;", ordinal = 1))
337
    private Vec2 hookCustomMultiplier(Vec2 instance, float value, Operation<Vec2> original) {
338
        var playerUseMultiplier = new PlayerUseMultiplier(value, value);
339
        EventManager.INSTANCE.callEvent(playerUseMultiplier);
340
        return new Vec2(
341
            instance.x * playerUseMultiplier.getSideways(),
342
            instance.y * playerUseMultiplier.getForward()
343
        );
344
    }
345
346
    /**
347
     * Hook sprint effect from NoSlow module
348
     */
349
    @ModifyExpressionValue(method = "isSlowDueToUsingItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isUsingItem()Z"))
350
    private boolean hookSprintAffectStart(boolean original) {
351
        if (ModuleNoSlow.INSTANCE.getRunning()) {
352
            return false;
353
        }
354
355
        return original;
356
    }
357
358
    // Silent rotations (Rotation Manager)
359
360
    @ModifyExpressionValue(method = {"sendPosition",
361
        "tick"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getYRot()F"))
362
    private float hookSilentRotationYaw(float original) {
363
        Rotation rotation = RotationManager.INSTANCE.getCurrentRotation();
364
        if (rotation == null) {
365
            return original;
366
        }
367
368
        return rotation.yRot();
369
    }
370
371
    @ModifyExpressionValue(method = {"sendPosition",
372
        "tick"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getXRot()F"))
373
    private float hookSilentRotationPitch(float original) {
374
        Rotation rotation = RotationManager.INSTANCE.getCurrentRotation();
375
        if (rotation == null) {
376
            return original;
377
        }
378
379
        return rotation.xRot();
380
    }
381
382
    @ModifyReturnValue(method = "isAutoJumpEnabled", at = @At("RETURN"))
383
    private boolean injectAutoJumpAllowed(boolean original) {
384
        return EventManager.INSTANCE.callEvent(new AllowAutoJumpEvent(original)).isAllowed();
385
    }
386
387
    @Inject(method = "swing", at = @At("HEAD"), cancellable = true)
388
    private void swingHand(InteractionHand hand, CallbackInfo ci) {
389
        if (ModuleNoSwing.INSTANCE.getRunning()) {
390
            if (!ModuleNoSwing.INSTANCE.shouldHideForServer()) {
391
                connection.send(new ServerboundSwingPacket(hand));
392
            }
393
            if (!ModuleNoSwing.INSTANCE.shouldHideForClient()) {
394
                swing(hand, false);
395
            }
396
397
            ci.cancel();
398
        }
399
    }
400
401
    @ModifyReturnValue(method = "getJumpRidingScale", at = @At("RETURN"))
402
    private float hookMountJumpStrength(float original) {
403
        if (ModuleEntityControl.getEnforceJumpStrength()) {
404
            return 1f;
405
        }
406
407
        return original;
408
    }
409
410
    @ModifyExpressionValue(method = "aiStep", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/player/Abilities;mayfly:Z", opcode = Opcodes.GETFIELD))
411
    private boolean hookFreeCamPreventCreativeFly(boolean original) {
412
        return !ModuleFreeCam.INSTANCE.getRunning() && original;
413
    }
414
415
    @ModifyVariable(method = "sendPosition", at = @At("STORE"), name = "rot")
416
    private boolean hookFreeCamPreventRotations(boolean bl4) {
417
        // Prevent rotation changes when free cam is active, unless a rotation is being set via the rotation manager
418
        return (!ModuleFreeCam.INSTANCE.getRunning() ||
419
                RotationManager.INSTANCE.getCurrentRotation() != null) && bl4;
420
    }
421
422
    @ModifyExpressionValue(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;canStartSprinting()Z"))
423
    private boolean hookSprint0(boolean original) {
424
        var event = new SprintEvent(new DirectionalInput(input), original, SprintEvent.Source.MOVEMENT_TICK);
425
        EventManager.INSTANCE.callEvent(event);
426
        return event.getSprint();
427
    }
428
429
    @ModifyExpressionValue(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Input;sprint()Z"))
430
    private boolean hookSprint1(boolean original) {
431
        var event = new SprintEvent(new DirectionalInput(input), original, SprintEvent.Source.MOVEMENT_TICK);
432
        EventManager.INSTANCE.callEvent(event);
433
        return event.getSprint();
434
    }
435
436
    @ModifyExpressionValue(method = "shouldStopRunSprinting", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;horizontalCollision:Z", opcode = Opcodes.GETFIELD))
437
    private boolean hookSprintIgnoreCollision(boolean original) {
438
        return !ModuleSprint.INSTANCE.getShouldIgnoreCollision() && original;
439
    }
440
441
    @ModifyReturnValue(method = "shouldStopRunSprinting", at = @At("RETURN"))
442
    private boolean hookForceStopSprinting(boolean shouldStop) {
443
        return shouldStop || liquid_bounce$shouldForceStopSprinting();
444
    }
445
446
    /**
447
     * ViaFabricPlus injects at HEAD of shouldStopRunSprinting with cancellable=true,
448
     * bypassing the RETURN instruction so @ModifyReturnValue never fires.
449
     * Intercepting the call site within aiStep works around this.
450
     * @see <a href="https://github.com/ViaVersion/ViaFabricPlus/blob/618332d/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/movement/sprinting_and_sneaking/MixinLocalPlayer.java#L262-L270">ViaFabricPlus changeStopSprintingConditions</a>
451
     */
452
    @ModifyExpressionValue(
453
        method = "aiStep",
454
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;shouldStopRunSprinting()Z")
455
    )
456
    private boolean hookVfpSprintStop(boolean shouldStop) {
457
        return shouldStop || liquid_bounce$shouldForceStopSprinting();
458
    }
459
460
    @Unique
461
    private boolean liquid_bounce$shouldForceStopSprinting() {
462
        var event = new SprintEvent(
463
            new DirectionalInput(input),
464
            true,
465
            SprintEvent.Source.MOVEMENT_TICK
466
        );
467
468
        EventManager.INSTANCE.callEvent(event);
469
        return !event.getSprint();
470
    }
471
472
    @ModifyExpressionValue(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/ClientInput;hasForwardImpulse()Z"))
473
    private boolean hookIsWalking(boolean original) {
474
        if (!ModuleSprint.INSTANCE.getShouldSprintOmnidirectional()) {
475
            return original;
476
        }
477
478
        float movementForward = input.getMoveVector().y;
479
        float movementSideways = input.getMoveVector().x;
480
        var hasMovement = Math.abs(movementForward) > 1.0E-5F ||
481
                Math.abs(movementSideways) > 1.0E-5F;
482
        var isWalking = (double) Math.abs(movementForward) >= 0.8 ||
483
                (double) Math.abs(movementSideways) >= 0.8;
484
        return this.isUnderWater() ? hasMovement : isWalking;
485
    }
486
487
    @ModifyExpressionValue(method = "sendIsSprintingIfNeeded", at = @At(
488
            value = "INVOKE",
489
            target = "Lnet/minecraft/client/player/LocalPlayer;isSprinting()Z")
490
    )
491
    private boolean hookNetworkSprint(boolean original) {
492
        var event = new SprintEvent(new DirectionalInput(input), original, SprintEvent.Source.NETWORK);
493
        EventManager.INSTANCE.callEvent(event);
494
        return event.getSprint();
495
    }
496
497
    @WrapWithCondition(method = "clientSideCloseContainer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V"))
498
    private boolean preventCloseScreen(Gui instance, Screen screen) {
499
        // Prevent closing screen if the current screen is a client screen
500
        return !ScreenManager.isClientScreen(screen);
501
    }
502
503
}
504
MixinMobsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinMob.javaJava · 36 lines · 1.3 KB
@Mixin(Mob.class)
ModifiesMob
MixinMob.javaJava · 36 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
20
21
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
22
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleEntityControl;
23
import net.minecraft.world.entity.Mob;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.injection.At;
26
27
@Mixin(Mob.class)
28
public abstract class MixinMob {
29
30
    @ModifyReturnValue(method = "isSaddled", at = @At("RETURN"))
31
    private boolean isSaddled(boolean original) {
32
        return ModuleEntityControl.getEnforceSaddled() || original;
33
    }
34
35
}
36
MixinPlayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayer.javaJava · 271 lines · 12.0 KB
@Mixin(Player.class)
ModifiesPlayer
MixinPlayer.javaJava · 271 lines · 12.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
24
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
25
import net.ccbluex.liquidbounce.event.EventManager;
26
import net.ccbluex.liquidbounce.event.events.PlayerSafeWalkEvent;
27
import net.ccbluex.liquidbounce.features.command.commands.ingame.fakeplayer.FakePlayer;
28
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleAutoWeapon;
29
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleKeepSprint;
30
import net.ccbluex.liquidbounce.features.module.modules.combat.criticals.modes.CriticalsNoGround;
31
import net.ccbluex.liquidbounce.features.module.modules.exploit.ModuleAntiReducedDebugInfo;
32
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleNoClip;
33
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleSprint;
34
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleReach;
35
import net.ccbluex.liquidbounce.features.module.modules.player.nofall.modes.NoFallNoGround;
36
import net.ccbluex.liquidbounce.features.module.modules.render.hitfx.ModuleHitFX;
37
import net.ccbluex.liquidbounce.features.module.modules.world.ModuleNoSlowBreak;
38
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
39
import net.ccbluex.liquidbounce.utils.aiming.features.MovementCorrection;
40
import net.minecraft.sounds.SoundEvent;
41
import net.minecraft.sounds.SoundEvents;
42
import net.minecraft.sounds.SoundSource;
43
import net.minecraft.world.damagesource.DamageSource;
44
import net.minecraft.world.entity.Entity;
45
import net.minecraft.world.entity.player.Player;
46
import org.spongepowered.asm.mixin.Mixin;
47
import org.spongepowered.asm.mixin.Shadow;
48
import org.spongepowered.asm.mixin.Unique;
49
import org.spongepowered.asm.mixin.injection.At;
50
import org.spongepowered.asm.mixin.injection.Inject;
51
import org.spongepowered.asm.mixin.injection.ModifyArgs;
52
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
53
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
54
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
55
56
@Mixin(Player.class)
57
public abstract class MixinPlayer extends MixinLivingEntity {
58
59
    @Shadow
60
    public abstract void tick();
61
62
    @Shadow
63
    public abstract SoundSource getSoundSource();
64
65
    /**
66
     * Hook safe walk event
67
     */
68
    @ModifyReturnValue(method = "isStayingOnGroundSurface", at = @At("RETURN"))
69
    private boolean hookSafeWalk(boolean original) {
70
        final var event = EventManager.INSTANCE.callEvent(new PlayerSafeWalkEvent());
71
        return original || event.isSafeWalk();
72
    }
73
74
    /**
75
     * Hook velocity rotation modification
76
     * <p>
77
     * There are a few velocity changes when attacking an entity, which could be easily detected by anti-cheats when a different server-side rotation is applied.
78
     */
79
    @ModifyExpressionValue(method = {"causeExtraKnockback",
80
        "doSweepAttack"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;getYRot()F"))
81
    private float hookFixRotation(float original) {
82
        if (!liquid_bounce$isClientPlayer()) {
83
            return original;
84
        }
85
86
        var rotationManager = RotationManager.INSTANCE;
87
        var rotation = rotationManager.getCurrentRotation();
88
        var rotationTarget = rotationManager.getActiveRotationTarget();
89
90
        if (rotationTarget == null || rotationTarget.getMovementCorrection() == MovementCorrection.OFF || rotation == null) {
91
            return original;
92
        }
93
94
        return rotation.yRot();
95
    }
96
97
    @Inject(method = "isReducedDebugInfo", at = @At("HEAD"), cancellable = true)
98
    private void injectReducedDebugInfo(CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
99
        if (ModuleAntiReducedDebugInfo.INSTANCE.getRunning()) {
100
            callbackInfoReturnable.setReturnValue(false);
101
        }
102
    }
103
104
    @Inject(method = "isMobilityRestricted", at = @At("HEAD"), cancellable = true)
105
    private void hookSprintIgnoreBlindness(CallbackInfoReturnable<Boolean> cir) {
106
        if (liquid_bounce$isClientPlayer() && ModuleSprint.INSTANCE.getShouldIgnoreBlindness()) {
107
            cir.setReturnValue(false);
108
        }
109
    }
110
111
    @Inject(method = "tick", at = @At(value = "INVOKE",
112
            target = "Lnet/minecraft/world/entity/player/Player;isSpectator()Z",
113
            ordinal = 1,
114
            shift = At.Shift.BEFORE))
115
    private void hookNoClip(CallbackInfo ci) {
116
        var clip = ModuleNoClip.INSTANCE;
117
        if (!this.noPhysics && clip.getRunning() && !clip.paused()) {
118
            this.noPhysics = true;
119
        }
120
    }
121
122
    @ModifyExpressionValue(method = "getDestroySpeed", at = @At(value = "INVOKE",
123
            target = "Lnet/minecraft/world/entity/player/Player;hasEffect(Lnet/minecraft/core/Holder;)Z"))
124
    private boolean injectFatigueNoSlow(boolean original) {
125
        if (liquid_bounce$isClientPlayer() && ModuleNoSlowBreak.getMiningFatigue()) {
126
            return false;
127
        }
128
129
        return original;
130
    }
131
132
133
    @ModifyExpressionValue(method = "getDestroySpeed", at = @At(value = "INVOKE",
134
            target = "Lnet/minecraft/world/entity/player/Player;isEyeInFluid(Lnet/minecraft/tags/TagKey;)Z"))
135
    private boolean injectWaterNoSlow(boolean original) {
136
        if (liquid_bounce$isClientPlayer() && ModuleNoSlowBreak.getWater()) {
137
            return false;
138
        }
139
140
        return original;
141
    }
142
143
    @ModifyExpressionValue(method = "getDestroySpeed", at = @At(value = "INVOKE",
144
            target = "Lnet/minecraft/world/entity/player/Player;onGround()Z"))
145
    private boolean injectOnAirNoSlow(boolean original) {
146
        if (liquid_bounce$isClientPlayer()) {
147
            if (ModuleNoSlowBreak.getOnAir()) {
148
                return true;
149
            }
150
151
            if (NoFallNoGround.INSTANCE.getRunning()) {
152
                return false;
153
            }
154
155
            if (CriticalsNoGround.INSTANCE.getRunning()) {
156
                return false;
157
            }
158
        }
159
160
        return original;
161
    }
162
163
    @ModifyArgs(method = "causeExtraKnockback", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;multiply(DDD)Lnet/minecraft/world/phys/Vec3;"))
164
    private void hookSlowVelocity(Args args) {
165
        if (liquid_bounce$isClientPlayer() && ModuleKeepSprint.INSTANCE.getRunning()) {
166
            double motion = ModuleKeepSprint.INSTANCE.getMotion();
167
            args.set(0, motion); // x
168
            args.set(2, motion); // z
169
        }
170
    }
171
172
    /**
173
     * for: attack, pierce
174
     */
175
    @WrapWithCondition(method = "causeExtraKnockback", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;setSprinting(Z)V", ordinal = 0))
176
    private boolean hookSlowVelocity(Player instance, boolean b) {
177
        if (liquid_bounce$isClientPlayer()) {
178
            ModuleKeepSprint.INSTANCE.setSprinting(b);
179
            return !ModuleKeepSprint.INSTANCE.getRunning() || b;
180
        }
181
182
        return true;
183
    }
184
185
    @ModifyExpressionValue(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;isSprinting()Z"))
186
    private boolean hookSlowVelocity(boolean original) {
187
        if (liquid_bounce$isClientPlayer() && ModuleKeepSprint.INSTANCE.getRunning()) {
188
            return ModuleKeepSprint.INSTANCE.getSprinting();
189
        }
190
191
        return original;
192
    }
193
194
    @ModifyReturnValue(method = "entityInteractionRange", at = @At("RETURN"))
195
    private double hookEntityInteractionRange(double original) {
196
        if (liquid_bounce$isClientPlayer() && ModuleReach.INSTANCE.getRunning()) {
197
            return ModuleReach.INSTANCE.getEntity().getInteractionRange();
198
        }
199
200
        return original;
201
    }
202
203
    @ModifyReturnValue(method = "blockInteractionRange", at = @At("RETURN"))
204
    private double hookBlockInteractionRange(double original) {
205
        if (liquid_bounce$isClientPlayer() && ModuleReach.INSTANCE.getRunning()) {
206
            return ModuleReach.INSTANCE.getBlockRangeIncrease() + original;
207
        }
208
209
        return original;
210
    }
211
212
    @ModifyExpressionValue(method = "getCurrentItemAttackStrengthDelay", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;getAttributeValue(Lnet/minecraft/core/Holder;)D"))
213
    private double hookAutoWeaponAttackSpeed(double original) {
214
        if (liquid_bounce$isClientPlayer() && ModuleReach.INSTANCE.getRunning()) {
215
            return original;
216
        }
217
218
        return ModuleAutoWeapon.INSTANCE.getAttackSpeed(original);
219
    }
220
221
    /*
222
     * Sadly, mixins don't allow capturing parameters when redirecting,
223
     * so there needs to be an extra injection for every sound.
224
     */
225
    @Inject(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;playServerSideSound(Lnet/minecraft/sounds/SoundEvent;)V", ordinal = 0))
226
    private void hookPlaySound(Entity target, CallbackInfo ci) {
227
        if (!ModuleHitFX.INSTANCE.getRunning()) {
228
            liquid_bounce$playSoundIfFakePlayer(target, SoundEvents.PLAYER_ATTACK_KNOCKBACK);
229
        }
230
    }
231
232
    @Inject(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;playServerSideSound(Lnet/minecraft/sounds/SoundEvent;)V", ordinal = 1))
233
    private void hookPlaySound1(Entity target, CallbackInfo ci) {
234
        if (!ModuleHitFX.INSTANCE.getRunning()) {
235
            liquid_bounce$playSoundIfFakePlayer(target, SoundEvents.PLAYER_ATTACK_NODAMAGE);
236
        }
237
    }
238
239
    @Inject(method = "attackVisualEffects", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;playServerSideSound(Lnet/minecraft/sounds/SoundEvent;)V", ordinal = 0))
240
    private void hookPlaySound2(Entity target, boolean criticalHit, boolean sweeping, boolean cooldownPassed, boolean pierce, float enchantDamage, CallbackInfo ci) {
241
        if (!ModuleHitFX.INSTANCE.getRunning()) {
242
            liquid_bounce$playSoundIfFakePlayer(target, SoundEvents.PLAYER_ATTACK_CRIT);
243
        }
244
245
    }
246
247
    @Inject(method = "attackVisualEffects", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;playServerSideSound(Lnet/minecraft/sounds/SoundEvent;)V", ordinal = 1))
248
    private void hookPlaySound3(Entity target, boolean criticalHit, boolean sweeping, boolean cooldownPassed, boolean pierce, float enchantDamage, CallbackInfo ci) {
249
        if(!ModuleHitFX.INSTANCE.getRunning()) {
250
            liquid_bounce$playSoundIfFakePlayer(target, cooldownPassed ? SoundEvents.PLAYER_ATTACK_STRONG : SoundEvents.PLAYER_ATTACK_WEAK);
251
        }
252
    }
253
254
    @Inject(method = "doSweepAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;playServerSideSound(Lnet/minecraft/sounds/SoundEvent;)V", ordinal = 0))
255
    private void hookPlaySound4(Entity target, float damage, DamageSource damageSource, float cooldownProgress, CallbackInfo ci) {
256
        if(!ModuleHitFX.INSTANCE.getRunning()) {
257
            liquid_bounce$playSoundIfFakePlayer(target, SoundEvents.PLAYER_ATTACK_SWEEP);
258
        }
259
    }
260
261
    /**
262
     * When the target is a fake player, this method will play a client side sound.
263
     */
264
    @Unique
265
    private void liquid_bounce$playSoundIfFakePlayer(Entity target, SoundEvent soundEvent) {
266
        if (target instanceof FakePlayer) {
267
            level().playSound(Player.class.cast(this), getX(), getY(), getZ(), soundEvent, getSoundSource(), 1F, 1F);
268
        }
269
    }
270
}
271
MixinFireworkRocketEntitysrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/projectile/MixinFireworkRocketEntity.javaJava · 78 lines · 3.5 KB
@Mixin(FireworkRocketEntity.class)
MixinFireworkRocketEntity.javaJava · 78 lines · 3.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
21
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity.projectile;
22
23
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
24
import com.llamalad7.mixinextras.sugar.Local;
25
import net.ccbluex.liquidbounce.additions.FireworkRocketEntityAddition;
26
import net.ccbluex.liquidbounce.features.module.modules.exploit.ModuleExtendedFirework;
27
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
28
import net.ccbluex.liquidbounce.utils.aiming.features.MovementCorrection;
29
import net.minecraft.client.Minecraft;
30
import net.minecraft.world.entity.LivingEntity;
31
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
32
import net.minecraft.world.phys.Vec3;
33
import org.jspecify.annotations.Nullable;
34
import org.spongepowered.asm.mixin.Mixin;
35
import org.spongepowered.asm.mixin.Shadow;
36
import org.spongepowered.asm.mixin.injection.At;
37
import org.spongepowered.asm.mixin.injection.ModifyArgs;
38
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
39
40
@Mixin(FireworkRocketEntity.class)
41
public abstract class MixinFireworkRocketEntity implements FireworkRocketEntityAddition {
42
    @Shadow
43
    private LivingEntity attachedToEntity;
44
45
    @ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getLookAngle()Lnet/minecraft/world/phys/Vec3;"))
46
    private Vec3 getRotationVector(Vec3 original) {
47
        if (attachedToEntity != Minecraft.getInstance().player) {
48
            return original;
49
        }
50
51
        var rotation = RotationManager.INSTANCE.getCurrentRotation();
52
        var rotationTarget = RotationManager.INSTANCE.getActiveRotationTarget();
53
54
        if (rotation == null || rotationTarget == null || rotationTarget.getMovementCorrection() == MovementCorrection.OFF) {
55
            return original;
56
        }
57
58
        return rotation.directionVector();
59
    }
60
61
    @ModifyArgs(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;", ordinal = 0))
62
    private void hookExtendedFirework(Args args, @Local(name = "lookAngle") Vec3 lookAngle, @Local(name = "movement") Vec3 movement) {
63
        if (attachedToEntity != Minecraft.getInstance().player
64
                || !ModuleExtendedFirework.INSTANCE.getRunning()
65
        ) return;
66
67
        var multiplier = ModuleExtendedFirework.getVelocityMultiplier();
68
        args.set(0, lookAngle.x * multiplier.x + (lookAngle.x * multiplier.y - movement.x) * multiplier.z);
69
        args.set(1, lookAngle.y * multiplier.x + (lookAngle.y * multiplier.y - movement.y) * multiplier.z);
70
        args.set(2, lookAngle.z * multiplier.x + (lookAngle.z * multiplier.y - movement.z) * multiplier.z);
71
    }
72
73
    @Override
74
    public @Nullable LivingEntity liquidbounce$getShooter() {
75
        return attachedToEntity;
76
    }
77
}
78
MixinFishingHooksrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/projectile/MixinFishingHook.javaJava · 45 lines · 1.8 KB
@Mixin(FishingHook.class)
ModifiesFishingHook
MixinFishingHook.javaJava · 45 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity.projectile;
20
21
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
22
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleNoPush;
23
import net.ccbluex.liquidbounce.features.module.modules.movement.NoPushBy;
24
import net.minecraft.client.Minecraft;
25
import net.minecraft.world.entity.Entity;
26
import net.minecraft.world.entity.projectile.FishingHook;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
30
/**
31
 * MixinFishingBobberEntity
32
 *
33
 * @author sqlerrorthing, 1zun4
34
 * @since 12/28/2024
35
 **/
36
@Mixin(FishingHook.class)
37
public abstract class MixinFishingHook {
38
39
    @WrapWithCondition(method = "handleEntityEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/projectile/FishingHook;pullEntity(Lnet/minecraft/world/entity/Entity;)V"))
40
    private boolean hookNoPushByFishingRod(FishingHook instance, Entity entity) {
41
        return entity != Minecraft.getInstance().player || ModuleNoPush.canPush(NoPushBy.FISHING_ROD);
42
    }
43
44
}
45
MixinProjectileUtilsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/projectile/MixinProjectileUtil.javaJava · 48 lines · 2.1 KB
@Mixin(ProjectileUtil.class)
MixinProjectileUtil.javaJava · 48 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity.projectile;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleHitbox;
25
import net.minecraft.client.Minecraft;
26
import net.minecraft.world.entity.Entity;
27
import net.minecraft.world.entity.projectile.ProjectileUtil;
28
import org.jspecify.annotations.NullMarked;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
32
@NullMarked
33
@Mixin(ProjectileUtil.class)
34
public abstract class MixinProjectileUtil {
35
36
    @ModifyExpressionValue(
37
        method = "getHitEntitiesAlong(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/component/AttackRange;Ljava/util/function/Predicate;Lnet/minecraft/world/level/ClipContext$Block;)Lcom/mojang/datafixers/util/Either;",
38
        at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/component/AttackRange;hitboxMargin()F")
39
    )
40
    private static float applyHitboxMargin(float original, @Local(argsOnly = true, name = "attacker") Entity entity) {
41
        if (entity == Minecraft.getInstance().player && ModuleHitbox.INSTANCE.getRunning() && ModuleHitbox.INSTANCE.getApplyToComponent()) {
42
            return ModuleHitbox.INSTANCE.getSize() + original;
43
        }
44
        return original;
45
    }
46
47
}
48
MixinFlowingFluidsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/fluid/MixinFlowingFluid.javaJava · 44 lines · 1.7 KB
@Mixin(FlowingFluid.class)
ModifiesFlowingFluid
MixinFlowingFluid.javaJava · 44 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.fluid;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import net.ccbluex.liquidbounce.event.EventManager;
23
import net.ccbluex.liquidbounce.event.events.FluidPushEvent;
24
import net.minecraft.world.level.material.FlowingFluid;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
28
@Mixin(FlowingFluid.class)
29
public abstract class MixinFlowingFluid {
30
31
    @ModifyExpressionValue(method = "getFlow", at = @At(value = "INVOKE", target = "Ljava/util/Iterator;hasNext()Z", ordinal = 0))
32
    private boolean hookLiquidPush(boolean original) {
33
        // If there is no next element, we can already return false and skip the event
34
        if (!original) {
35
            return false;
36
        }
37
38
        final FluidPushEvent fluidPushEvent = new FluidPushEvent();
39
        EventManager.INSTANCE.callEvent(fluidPushEvent);
40
        return !fluidPushEvent.isCancelled();
41
    }
42
43
}
44
MixinAbstractContainerScreensrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinAbstractContainerScreen.javaJava · 151 lines · 6.2 KB
@Mixin(AbstractContainerScreen.class)
MixinAbstractContainerScreen.javaJava · 151 lines · 6.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import com.mojang.blaze3d.platform.InputConstants;
23
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleItemScroller;
24
import net.ccbluex.liquidbounce.features.module.modules.player.cheststealer.features.FeatureSilentScreen;
25
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleBetterInventory;
26
import net.ccbluex.liquidbounce.injection.mixins.minecraft.client.MixinMouseHandlerAccessor;
27
import net.minecraft.client.MouseHandler;
28
import net.minecraft.client.gui.GuiGraphicsExtractor;
29
import net.minecraft.client.gui.screens.Screen;
30
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
31
import net.minecraft.client.input.MouseButtonEvent;
32
import net.minecraft.util.Util;
33
import net.minecraft.world.inventory.AbstractContainerMenu;
34
import net.minecraft.world.inventory.ContainerInput;
35
import net.minecraft.world.inventory.Slot;
36
import net.minecraft.world.item.ItemStack;
37
import org.jspecify.annotations.Nullable;
38
import org.spongepowered.asm.mixin.Final;
39
import org.spongepowered.asm.mixin.Mixin;
40
import org.spongepowered.asm.mixin.Shadow;
41
import org.spongepowered.asm.mixin.Unique;
42
import org.spongepowered.asm.mixin.injection.At;
43
import org.spongepowered.asm.mixin.injection.Inject;
44
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
45
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
46
47
@Mixin(AbstractContainerScreen.class)
48
public abstract class MixinAbstractContainerScreen<T extends AbstractContainerMenu> extends MixinScreen {
49
50
    @Shadow
51
    @Final
52
    protected T menu;
53
54
    @Shadow
55
    @Nullable
56
    protected abstract Slot getHoveredSlot(double mouseX, double mouseY);
57
58
    @Shadow
59
    private ItemStack lastQuickMoved;
60
61
    @Shadow
62
    protected abstract void slotClicked(Slot slot, int id, int button, ContainerInput actionType);
63
64
    @Shadow
65
    private boolean skipNextRelease;
66
67
    @Shadow
68
    private @Nullable Slot lastClickSlot;
69
70
    @Shadow
71
    protected int leftPos;
72
73
    @Shadow
74
    protected int topPos;
75
76
    @Inject(method = "slotClicked(Lnet/minecraft/world/inventory/Slot;IILnet/minecraft/world/inventory/ContainerInput;)V", at = @At("HEAD"), cancellable = true)
77
    private void cancelMouseClick(Slot slot, int slotId, int button, ContainerInput actionType, CallbackInfo ci) {
78
        if (FeatureSilentScreen.INSTANCE.getShouldHide()) {
79
            ci.cancel();
80
        }
81
    }
82
83
    // Before `if (itemStack.isEmpty() && slot.isActive()) {`
84
    @Inject(method = "extractSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;isEmpty()Z", ordinal = 0))
85
    private void drawSlotOutline(GuiGraphicsExtractor context, Slot slot, int mouseX, int mouseY, CallbackInfo ci) {
86
        ModuleBetterInventory.INSTANCE.drawHighlightSlot(context, slot);
87
    }
88
89
    @Inject(method = "extractContents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;extractSlots(Lnet/minecraft/client/gui/GuiGraphicsExtractor;II)V", shift = At.Shift.AFTER))
90
    private void hookDrawSlot(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
91
        var cursorStack = this.menu.getCarried();
92
        var slot = getHoveredSlot(mouseX, mouseY);
93
94
        if (!cursorStack.isEmpty() || slot == null) {
95
            return;
96
        }
97
98
        var stack = slot.getItem();
99
        if (!ModuleBetterInventory.INSTANCE.drawContainerItemView(context, cursorStack, this.leftPos, this.topPos, mouseX, mouseY)) {
100
            ModuleBetterInventory.INSTANCE.drawContainerItemView(context, stack, this.leftPos, this.topPos, mouseX, mouseY);
101
        }
102
103
        if (matchingItemScrollerMoveConditions(mouseX, mouseY)) {
104
            this.lastQuickMoved = stack.isEmpty() ? ItemStack.EMPTY : stack.copy();
105
106
            ModuleItemScroller.getClickMode().getAction().invoke(this.menu, slot, this::slotClicked);
107
108
            this.skipNextRelease = true;
109
110
            this.lastClickSlot = slot;
111
            // See Mouse.onMouseButton
112
            /*
113
            <pre>
114
             long l = Util.getMeasuringTimeMs();
115
             boolean bl2 = this.lastMouseClick != null
116
             && l - this.lastMouseClick.time() < 250L
117
             && this.lastMouseClick.screen() == screen
118
             && this.lastMouseButton == click.button();
119
             if (screen.mouseClicked(click, bl2)) {
120
             this.lastMouseClick = new Mouse.MouseClickTime(l, screen);
121
             this.lastMouseButton = mouseInput.button();
122
             return;
123
             }
124
             </pre>
125
             */
126
            var mouse = (MixinMouseHandlerAccessor) this.minecraft.mouseHandler;
127
            mouse.setLastClick(new MouseHandler.LastClick(Util.getMillis(), (Screen) (Object) this));
128
            mouse.setLastClickButton(InputConstants.MOUSE_BUTTON_LEFT);
129
130
            ModuleItemScroller.INSTANCE.resetChronometer();
131
        }
132
    }
133
134
    @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true)
135
    private void hookMouseClicked(MouseButtonEvent click, boolean doubled, CallbackInfoReturnable<Boolean> cir) {
136
        /*
137
         * We move the item by itself, we don't need this action by Minecraft
138
         */
139
        if (matchingItemScrollerMoveConditions(click.x(), click.y())) {
140
            cir.cancel();
141
        }
142
    }
143
144
    @Unique
145
    private boolean matchingItemScrollerMoveConditions(double mouseX, double mouseY) {
146
        return getHoveredSlot(mouseX, mouseY) != null
147
            && ModuleItemScroller.INSTANCE.canPerformScroll(this.minecraft.getWindow());
148
    }
149
150
}
151
MixinBossHealthOverlaysrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinBossHealthOverlay.javaJava · 40 lines · 1.6 KB
@Mixin(BossHealthOverlay.class)
MixinBossHealthOverlay.javaJava · 40 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
20
21
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
22
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
23
import net.minecraft.client.gui.components.BossHealthOverlay;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.Inject;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28
29
@Mixin(BossHealthOverlay.class)
30
public abstract class MixinBossHealthOverlay {
31
32
    @Inject(method = "extractRenderState", at = @At("HEAD"), cancellable = true)
33
    private void hookRenderStatusEffectOverlay(CallbackInfo ci) {
34
        if (!ModuleAntiBlind.canRender(DoRender.BOSS_BARS)) {
35
            ci.cancel();
36
        }
37
    }
38
39
}
40
MixinChatComponentsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinChatComponent.javaJava · 217 lines · 8.0 KB
@Mixin(ChatComponent.class)
MixinChatComponent.javaJava · 217 lines · 8.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.sugar.Local;
23
import net.ccbluex.liquidbounce.features.module.modules.misc.betterchat.ModuleBetterChat;
24
import net.ccbluex.liquidbounce.interfaces.GuiMessageLineAddition;
25
import net.minecraft.client.Minecraft;
26
import net.minecraft.client.gui.Font;
27
import net.minecraft.client.gui.GuiGraphicsExtractor;
28
import net.minecraft.client.gui.components.ChatComponent;
29
import net.minecraft.client.multiplayer.chat.GuiMessage;
30
import net.minecraft.util.ArrayListDeque;
31
import net.minecraft.util.FormattedCharSequence;
32
import org.spongepowered.asm.mixin.*;
33
import org.spongepowered.asm.mixin.injection.At;
34
import org.spongepowered.asm.mixin.injection.Inject;
35
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
36
37
import java.util.List;
38
39
@Mixin(ChatComponent.class)
40
public abstract class MixinChatComponent {
41
42
    @Shadow
43
    @Final
44
    private Minecraft minecraft;
45
46
    @Mutable
47
    @Shadow
48
    @Final
49
    public List<GuiMessage> allMessages;
50
51
    @Mutable
52
    @Shadow
53
    @Final
54
    public List<GuiMessage.Line> trimmedMessages;
55
56
    @Shadow
57
    public abstract boolean isChatFocused();
58
59
    @Shadow
60
    private int chatScrollbarPos;
61
62
    @Shadow
63
    private boolean newMessageSinceScroll;
64
65
    @Shadow
66
    public abstract void scrollChat(int scroll);
67
68
    @Inject(method = "<init>(Lnet/minecraft/client/Minecraft;)V", at = @At(value = "TAIL"))
69
    public void hookNewArrayList2(Minecraft minecraft, CallbackInfo ci) {
70
        allMessages = new ArrayListDeque<>(100);
71
        // ArrayDeque for addFirst operations
72
        trimmedMessages = new ArrayListDeque<>(100);
73
    }
74
75
    /**
76
     * Spoofs the message size to be empty to avoid deletion.
77
     * <pre>
78
     * while(this.messages.size() > 100) {
79
     *     this.messages.removeLast();
80
     * }
81
     * </pre>
82
     */
83
    @ModifyExpressionValue(method = "addMessageToQueue", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 0, remap = false))
84
    public int hookGetSize2(int original) {
85
        var betterChat = ModuleBetterChat.INSTANCE;
86
        if (betterChat.getRunning() && betterChat.getInfiniteLength()) {
87
            return 0;
88
        }
89
90
        return original;
91
    }
92
93
    /**
94
     * Cancels the message clearing.
95
     */
96
    @Inject(method = "clearMessages", at = @At(value = "HEAD"), cancellable = true)
97
    public void hookClear(boolean clearHistory, CallbackInfo ci) {
98
        var betterChat = ModuleBetterChat.INSTANCE;
99
        if (betterChat.getRunning() && betterChat.getAntiClear() && !betterChat.getAntiChatClearPaused()) {
100
            ci.cancel();
101
        }
102
    }
103
104
    /**
105
     * Modifies {@link ChatComponent#addMessageToDisplayQueue(GuiMessage)} so, that the id is
106
     * forwarded and if {@link ModuleBetterChat} is enabled, older lines won't be removed.
107
     */
108
    @Inject(method = "addMessageToDisplayQueue", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;isChatFocused()Z", shift = At.Shift.BEFORE), cancellable = true)
109
    public void hookAddVisibleMessage(GuiMessage message, CallbackInfo ci, @Local(name = "lines") List<FormattedCharSequence> lines) {
110
        var focused = isChatFocused();
111
        var removable = ((GuiMessageLineAddition) (Object) message);
112
        //noinspection DataFlowIssue
113
        var id = removable.liquid_bounce$getId();
114
115
        for (int j = 0; j < lines.size(); ++j) {
116
            FormattedCharSequence orderedText = lines.get(j);
117
            if (focused && chatScrollbarPos > 0) {
118
                newMessageSinceScroll = true;
119
                scrollChat(1);
120
            }
121
122
            boolean last = j == lines.size() - 1;
123
            var visible = new GuiMessage.Line(message, orderedText, last);
124
            //noinspection DataFlowIssue
125
            ((GuiMessageLineAddition) (Object) visible).liquid_bounce$setId(id);
126
            trimmedMessages.addFirst(visible);
127
        }
128
129
        var betterChat = ModuleBetterChat.INSTANCE;
130
        if (!betterChat.getRunning() || !betterChat.getInfiniteLength()) {
131
            if (trimmedMessages.size() > 100) {
132
                trimmedMessages.subList(100, trimmedMessages.size()).clear();
133
            }
134
        }
135
136
        ci.cancel();
137
    }
138
139
    @Inject(method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/gui/Font;IIILnet/minecraft/client/gui/components/ChatComponent$DisplayMode;Z)V", at = @At("TAIL"))
140
    private void hookRenderCopyHighlight(
141
        GuiGraphicsExtractor graphics,
142
        Font font,
143
        int tickCount,
144
        int globalMouseX,
145
        int globalMouseY,
146
        ChatComponent.DisplayMode displayMode,
147
        boolean changeCursorOnInsertions,
148
        CallbackInfo ci
149
    ) {
150
        if (!displayMode.foreground) {
151
            return;
152
        }
153
154
        var betterChat = ModuleBetterChat.INSTANCE;
155
        if (!(betterChat.getRunning() && ModuleBetterChat.Copy.INSTANCE.getRunning() && ModuleBetterChat.Copy.INSTANCE.getHighlight())) {
156
            return;
157
        }
158
159
        if (trimmedMessages.isEmpty()) {
160
            return;
161
        }
162
163
        var accessor = (MixinChatComponentAccessor) this;
164
        double chatScale = accessor.invokeGetScale();
165
        if (chatScale <= 0.0) {
166
            return;
167
        }
168
169
        int chatWidth = (int) Math.ceil(accessor.invokeGetWidth() / chatScale);
170
        double localMouseX = globalMouseX / chatScale - 4.0;
171
        if (localMouseX < 0.0 || localMouseX > chatWidth) {
172
            return;
173
        }
174
175
        int lineHeight = accessor.invokeGetLineHeight();
176
        if (lineHeight <= 0) {
177
            return;
178
        }
179
180
        int guiHeight = minecraft.getWindow().getGuiScaledHeight();
181
        int chatBottom = (int) Math.floor((guiHeight - 40) / chatScale);
182
        double localMouseY = chatBottom - globalMouseY / chatScale;
183
        if (localMouseY < 0.0) {
184
            return;
185
        }
186
187
        int lineIndex = (int) Math.floor(localMouseY / lineHeight);
188
        int visibleLineCount = Math.min(accessor.invokeGetLinesPerPage(), trimmedMessages.size() - chatScrollbarPos);
189
        if (lineIndex < 0 || lineIndex >= visibleLineCount) {
190
            return;
191
        }
192
193
        int messageIndex = lineIndex + chatScrollbarPos;
194
        if (messageIndex < 0 || messageIndex >= trimmedMessages.size()) {
195
            return;
196
        }
197
198
        var messageBounds = ModuleBetterChat.resolveMessageBounds(trimmedMessages, messageIndex);
199
        int visibleStart = chatScrollbarPos;
200
        int visibleEnd = visibleStart + visibleLineCount - 1;
201
        int highlightedStart = Math.max(messageBounds.getStart(), visibleStart);
202
        int highlightedEnd = Math.min(messageBounds.getEndInclusive(), visibleEnd);
203
        if (highlightedStart > highlightedEnd) {
204
            return;
205
        }
206
207
        int startLineIndex = highlightedStart - visibleStart;
208
        int endLineIndex = highlightedEnd - visibleStart;
209
        int left = (int) Math.floor(4.0 * chatScale);
210
        int right = (int) Math.ceil((chatWidth + 4.0) * chatScale);
211
        int top = (int) Math.floor((chatBottom - (endLineIndex + 1) * lineHeight) * chatScale);
212
        int bottom = (int) Math.ceil((chatBottom - startLineIndex * lineHeight) * chatScale);
213
        graphics.fill(left, top, right, bottom, 0x4422AAFF);
214
    }
215
216
}
217
MixinChatComponentAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinChatComponentAccessor.javaJava · 55 lines · 1.6 KB
@Mixin(ChatComponent.class)
MixinChatComponentAccessor.javaJava · 55 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import net.minecraft.client.gui.components.ChatComponent;
23
import net.minecraft.client.multiplayer.chat.GuiMessage;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.gen.Accessor;
26
import org.spongepowered.asm.mixin.gen.Invoker;
27
28
import java.util.List;
29
30
/**
31
 * @author 00101110001100010111000101111
32
 * @since 12/18/2024
33
 **/
34
@Mixin(ChatComponent.class)
35
public interface MixinChatComponentAccessor {
36
37
    @Invoker("getLineHeight")
38
    int invokeGetLineHeight();
39
40
    @Invoker("getScale")
41
    double invokeGetScale();
42
43
    @Invoker("getWidth")
44
    int invokeGetWidth();
45
46
    @Invoker("getLinesPerPage")
47
    int invokeGetLinesPerPage();
48
49
    @Accessor
50
    List<GuiMessage.Line> getTrimmedMessages();
51
52
    @Accessor("chatScrollbarPos")
53
    int getChatScrollbarPos();
54
}
55
MixinChatScreensrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinChatScreen.javaJava · 121 lines · 4.8 KB
@Mixin(ChatScreen.class)
ModifiesChatScreen
MixinChatScreen.javaJava · 121 lines · 4.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
20
21
import net.ccbluex.liquidbounce.event.EventManager;
22
import net.ccbluex.liquidbounce.event.events.ChatSendEvent;
23
import net.ccbluex.liquidbounce.features.module.modules.misc.betterchat.ModuleBetterChat;
24
import net.minecraft.client.gui.screens.ChatScreen;
25
import net.minecraft.client.input.MouseButtonEvent;
26
import net.minecraft.client.multiplayer.chat.GuiMessage;
27
import net.minecraft.util.ArrayListDeque;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Unique;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
34
35
import java.util.OptionalInt;
36
37
@Mixin(ChatScreen.class)
38
public abstract class MixinChatScreen extends MixinScreen {
39
40
    /**
41
     * Handle user chat messages
42
     *
43
     * @param chatText chat message by client user
44
     */
45
    @Inject(method = "handleChatInput", at = @At("HEAD"), cancellable = true)
46
    private void handleChatMessage(String chatText, boolean addToHistory, CallbackInfo ci) {
47
        if (EventManager.INSTANCE.callEvent(new ChatSendEvent(chatText)).isCancelled()) {
48
            minecraft.gui.hud.getChat().addRecentChat(chatText);
49
            ci.cancel();
50
        }
51
    }
52
53
    @Inject(method = "mouseClicked", at = @At("HEAD"))
54
    private void hookMouseClicked(MouseButtonEvent click, boolean doubled, CallbackInfoReturnable<Boolean> cir) {
55
        if (!(ModuleBetterChat.INSTANCE.getRunning() && ModuleBetterChat.Copy.INSTANCE.getRunning())) {
56
            return;
57
        }
58
59
        var activeMessage = getActiveMessage(click);
60
61
        if (activeMessage.isEmpty()) {
62
            return;
63
        }
64
65
        var chatHud = (MixinChatComponentAccessor) this.minecraft.gui.hud.getChat();
66
67
        var visibleMessages = chatHud.getTrimmedMessages();
68
        var messageBounds = ModuleBetterChat.resolveMessageBounds(visibleMessages, activeMessage.getAsInt());
69
        var messageParts = new ArrayListDeque<GuiMessage.Line>(messageBounds.getEndInclusive() - messageBounds.getStart() + 1);
70
        for (int index = messageBounds.getEndInclusive(); index >= messageBounds.getStart(); index--) {
71
            messageParts.addLast(visibleMessages.get(index));
72
        }
73
74
        if (messageParts.isEmpty())
75
            return;
76
77
        ModuleBetterChat.Copy.copyMessage(messageParts, click.button());
78
    }
79
80
    @Unique
81
    private OptionalInt getActiveMessage(MouseButtonEvent click) {
82
        var chatHud = (MixinChatComponentAccessor) this.minecraft.gui.hud.getChat();
83
        var visibleMessages = chatHud.getTrimmedMessages();
84
        if (visibleMessages.isEmpty()) {
85
            return OptionalInt.empty();
86
        }
87
88
        double chatScale = chatHud.invokeGetScale();
89
        if (chatScale <= 0.0) {
90
            return OptionalInt.empty();
91
        }
92
93
        int chatWidth = (int) Math.ceil(chatHud.invokeGetWidth() / chatScale);
94
        double localMouseX = click.x() / chatScale - 4.0;
95
        if (localMouseX < 0.0 || localMouseX > chatWidth) {
96
            return OptionalInt.empty();
97
        }
98
99
        int lineHeight = chatHud.invokeGetLineHeight();
100
        if (lineHeight <= 0) {
101
            return OptionalInt.empty();
102
        }
103
104
        int guiHeight = this.minecraft.getWindow().getGuiScaledHeight();
105
        int chatBottom = (int) Math.floor((guiHeight - 40) / chatScale);
106
        double localMouseY = chatBottom - click.y() / chatScale;
107
        if (localMouseY < 0.0) {
108
            return OptionalInt.empty();
109
        }
110
111
        int lineIndex = (int) Math.floor(localMouseY / lineHeight);
112
        int visibleLineCount = Math.min(chatHud.invokeGetLinesPerPage(), visibleMessages.size() - chatHud.getChatScrollbarPos());
113
        if (lineIndex < 0 || lineIndex >= visibleLineCount) {
114
            return OptionalInt.empty();
115
        }
116
117
        int messageIndex = lineIndex + chatHud.getChatScrollbarPos();
118
        return messageIndex >= 0 && messageIndex < visibleMessages.size() ? OptionalInt.of(messageIndex) : OptionalInt.empty();
119
    }
120
}
121
MixinChatScreenAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinChatScreenAccessor.javaJava · 32 lines · 1.1 KB
@Mixin(ChatScreen.class)
ModifiesChatScreen
MixinChatScreenAccessor.javaJava · 32 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import net.minecraft.client.gui.components.EditBox;
23
import net.minecraft.client.gui.screens.ChatScreen;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.gen.Accessor;
26
27
@Mixin(ChatScreen.class)
28
public interface MixinChatScreenAccessor {
29
    @Accessor("input")
30
    EditBox getInput();
31
}
32
MixinCommandSuggestionssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinCommandSuggestions.javaJava · 70 lines · 2.7 KB
@Mixin(CommandSuggestions.class)
MixinCommandSuggestions.javaJava · 70 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import com.mojang.brigadier.ParseResults;
23
import com.mojang.brigadier.suggestion.Suggestions;
24
import net.ccbluex.liquidbounce.features.command.CommandManager;
25
import net.minecraft.client.gui.components.CommandSuggestions;
26
import net.minecraft.client.gui.components.EditBox;
27
import net.minecraft.commands.SharedSuggestionProvider;
28
import org.jspecify.annotations.Nullable;
29
import org.spongepowered.asm.mixin.Final;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.Shadow;
32
import org.spongepowered.asm.mixin.injection.At;
33
import org.spongepowered.asm.mixin.injection.Inject;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
35
36
import java.util.concurrent.CompletableFuture;
37
38
@Mixin(CommandSuggestions.class)
39
public abstract class MixinCommandSuggestions {
40
    @Shadow
41
    @Final
42
    private EditBox input;
43
    @Shadow
44
    private CompletableFuture<Suggestions> pendingSuggestions;
45
    @Shadow
46
    private ParseResults<SharedSuggestionProvider> currentParse;
47
    @Shadow
48
    public abstract void showSuggestions(boolean narrateFirstSuggestion);
49
50
    @Shadow
51
    private CommandSuggestions.@Nullable SuggestionsList suggestions;
52
53
    @Inject(method = "updateCommandInfo", at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/StringReader;canRead()Z", remap = false), cancellable = true)
54
    private void injectAutoCompletionB(CallbackInfo ci) {
55
        if (this.input.getValue().startsWith(CommandManager.GlobalSettings.INSTANCE.getPrefix())) {
56
            this.pendingSuggestions = CommandManager.INSTANCE.autoComplete(this.input.getValue(), this.input.getCursorPosition());
57
            this.pendingSuggestions.thenRun(() -> {
58
                if (this.pendingSuggestions.isDone() && suggestions == null) {
59
                    this.showSuggestions(false);
60
                }
61
            });
62
63
            this.currentParse = null;
64
65
            ci.cancel();
66
        }
67
    }
68
69
}
70
MixinGuiGraphicsExtractorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinGuiGraphicsExtractor.javaJava · 67 lines · 2.6 KB
@Mixin(GuiGraphicsExtractor.class)
MixinGuiGraphicsExtractor.javaJava · 67 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
20
21
import net.ccbluex.liquidbounce.additions.GuiGraphicsExtractorAddition;
22
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleBetterInventory;
23
import net.minecraft.client.gui.Font;
24
import net.minecraft.client.gui.GuiGraphicsExtractor;
25
import net.minecraft.world.item.ItemStack;
26
import org.jspecify.annotations.Nullable;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.Shadow;
29
import org.spongepowered.asm.mixin.injection.At;
30
import org.spongepowered.asm.mixin.injection.Inject;
31
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
32
33
@Mixin(GuiGraphicsExtractor.class)
34
public abstract class MixinGuiGraphicsExtractor implements GuiGraphicsExtractorAddition {
35
36
    @Shadow
37
    protected abstract void itemBar(ItemStack stack, int x, int y);
38
39
    @Shadow
40
    protected abstract void itemCount(Font textRenderer, ItemStack stack, int x, int y,
41
        @Nullable String stackCountText);
42
43
    @Shadow
44
    protected abstract void itemCooldown(ItemStack stack, int x, int y);
45
46
    @Inject(method = "itemCooldown", at = @At("TAIL"))
47
    private void drawCooldownProgress(ItemStack stack, int x, int y, CallbackInfo ci) {
48
        ModuleBetterInventory.INSTANCE.drawTextCooldownProgress((GuiGraphicsExtractor) (Object) this, stack, x, y);
49
    }
50
51
    @Override
52
    public void liquidbounce$drawItemBar(ItemStack stack, int x, int y) {
53
        itemBar(stack, x, y);
54
    }
55
56
    @Override
57
    public void liquidbounce$drawStackCount(Font textRenderer, ItemStack stack, int x, int y,
58
            @Nullable String stackCountText) {
59
        itemCount(textRenderer, stack, x, y, stackCountText);
60
    }
61
62
    @Override
63
    public void liquidbounce$drawCooldownProgress(ItemStack stack, int x, int y) {
64
        itemCooldown(stack, x, y);
65
    }
66
}
67
MixinGuiRenderStatesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinGuiRenderState.javaJava · 87 lines · 3.1 KB
@Mixin(GuiRenderState.class)
MixinGuiRenderState.javaJava · 87 lines · 3.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import net.ccbluex.liquidbounce.render.gui.element.RecyclableGuiElementRenderState;
23
import net.minecraft.client.renderer.state.gui.GuiRenderState;
24
import net.minecraft.client.renderer.state.gui.ScreenArea;
25
import org.spongepowered.asm.mixin.Final;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.Shadow;
28
import org.spongepowered.asm.mixin.Unique;
29
import org.spongepowered.asm.mixin.injection.At;
30
import org.spongepowered.asm.mixin.injection.Inject;
31
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
32
33
import java.util.ArrayList;
34
import java.util.List;
35
import java.util.function.Consumer;
36
37
import static net.ccbluex.liquidbounce.utils.collection.GenericPools.ARRAY_LIST;
38
39
@SuppressWarnings("rawtypes")
40
@Mixin(GuiRenderState.class)
41
public abstract class MixinGuiRenderState {
42
43
    @Shadow
44
    @Final
45
    private List<GuiRenderState.Node> strata;
46
47
    @Inject(method = "reset", at = @At("HEAD"))
48
    private void clear(CallbackInfo ci) {
49
        for (GuiRenderState.Node layer : strata) {
50
            if (layer.elementStates != null) {
51
                layer.elementStates.forEach(liquid_bounce$tryRecycle);
52
                ARRAY_LIST.recycle((ArrayList) layer.elementStates);
53
                layer.elementStates = null;
54
            }
55
56
            if (layer.glyphStates != null) {
57
                layer.glyphStates.forEach(liquid_bounce$tryRecycle);
58
                ARRAY_LIST.recycle((ArrayList) layer.glyphStates);
59
                layer.glyphStates = null;
60
            }
61
62
            if (layer.itemStates != null) {
63
                ARRAY_LIST.recycle((ArrayList) layer.itemStates);
64
                layer.itemStates = null;
65
            }
66
67
            if (layer.textStates != null) {
68
                ARRAY_LIST.recycle((ArrayList) layer.textStates);
69
                layer.textStates = null;
70
            }
71
72
            if (layer.picturesInPictureStates != null) {
73
                ARRAY_LIST.recycle((ArrayList) layer.picturesInPictureStates);
74
                layer.picturesInPictureStates = null;
75
            }
76
        }
77
    }
78
79
    @Unique
80
    private static final Consumer<ScreenArea> liquid_bounce$tryRecycle = element -> {
81
        if (element instanceof RecyclableGuiElementRenderState recyclable) {
82
            recyclable.recycle();
83
        }
84
    };
85
86
}
87
MixinGuiRenderStateLayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinGuiRenderStateLayer.javaJava · 62 lines · 2.4 KB
@Mixin(GuiRenderState.Node.class)
MixinGuiRenderStateLayer.javaJava · 62 lines · 2.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import net.minecraft.client.renderer.state.gui.GuiRenderState;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
28
import java.util.ArrayList;
29
30
import static net.ccbluex.liquidbounce.utils.collection.GenericPools.ARRAY_LIST;
31
32
@SuppressWarnings("rawtypes")
33
@Mixin(GuiRenderState.Node.class)
34
public abstract class MixinGuiRenderStateLayer {
35
36
    @WrapOperation(method = "addItem", at = @At(value = "NEW", target = "()Ljava/util/ArrayList;"))
37
    private ArrayList reuseList$addItem(Operation<ArrayList> original) {
38
        return ARRAY_LIST.borrow();
39
    }
40
41
    @WrapOperation(method = "addText", at = @At(value = "NEW", target = "()Ljava/util/ArrayList;"))
42
    private ArrayList reuseList$addText(Operation<ArrayList> original) {
43
        return ARRAY_LIST.borrow();
44
    }
45
46
    @WrapOperation(method = "addPicturesInPictureState", at = @At(value = "NEW", target = "()Ljava/util/ArrayList;"))
47
    private ArrayList reuseList$addSpecialElement(Operation<ArrayList> original) {
48
        return ARRAY_LIST.borrow();
49
    }
50
51
    @WrapOperation(method = "addGuiElement", at = @At(value = "NEW", target = "()Ljava/util/ArrayList;"))
52
    private ArrayList reuseList$addSimpleElement(Operation<ArrayList> original) {
53
        return ARRAY_LIST.borrow();
54
    }
55
56
    @WrapOperation(method = "addGlyph", at = @At(value = "NEW", target = "()Ljava/util/ArrayList;"))
57
    private ArrayList reuseList$addPreparedText(Operation<ArrayList> original) {
58
        return ARRAY_LIST.borrow();
59
    }
60
61
}
62
MixinGuiRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinGuiRenderer.javaJava · 69 lines · 3.0 KB
@Mixin(GuiRenderer.class)
ModifiesGuiRenderer
MixinGuiRenderer.javaJava · 69 lines · 3.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
24
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
25
import com.llamalad7.mixinextras.sugar.Local;
26
import com.mojang.blaze3d.pipeline.RenderPipeline;
27
import com.mojang.blaze3d.pipeline.RenderTarget;
28
import net.ccbluex.liquidbounce.render.engine.BlurEffectRenderer;
29
import net.ccbluex.liquidbounce.render.gui.GuiCircleLutAtlas;
30
import net.minecraft.client.gui.render.GuiRenderer;
31
import net.minecraft.client.renderer.GameRenderer;
32
import org.jspecify.annotations.NullMarked;
33
import org.spongepowered.asm.mixin.Mixin;
34
import org.spongepowered.asm.mixin.injection.At;
35
import org.spongepowered.asm.mixin.injection.Inject;
36
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
37
38
@NullMarked
39
@Mixin(GuiRenderer.class)
40
public abstract class MixinGuiRenderer {
41
42
    @ModifyExpressionValue(method = "addElementToMesh", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/render/GuiRenderer;scissorChanged(Lnet/minecraft/client/gui/navigation/ScreenRectangle;Lnet/minecraft/client/gui/navigation/ScreenRectangle;)Z"))
43
    private boolean uploadPrimitivesIndividually(boolean original, @Local(name = "pipeline") RenderPipeline pipeline) {
44
        return original || pipeline.getPrimitiveTopology().connectedPrimitives;
45
    }
46
47
    @WrapOperation(
48
        method = "draw",
49
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;mainRenderTarget()Lcom/mojang/blaze3d/pipeline/RenderTarget;")
50
    )
51
    private RenderTarget injectBlurRenderTarget(GameRenderer instance, Operation<RenderTarget> original) {
52
        BlurEffectRenderer blurEffectRenderer = BlurEffectRenderer.INSTANCE;
53
        if (blurEffectRenderer.shouldDrawBlur()) {
54
            blurEffectRenderer.setDrawingHudFramebuffer(true);
55
            return blurEffectRenderer.getOverlayRenderTargetHolder().initAndGet();
56
        }
57
        return original.call(instance);
58
    }
59
60
    @Inject(
61
        method = "draw", at = @At("RETURN")
62
    )
63
    private void afterRenderBlurOverlay(CallbackInfo ci) {
64
        GuiCircleLutAtlas.INSTANCE.resetForNextDraw();
65
        BlurEffectRenderer.INSTANCE.blitBlurOverlay();
66
    }
67
68
}
69
MixinHudsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinHud.javaJava · 283 lines · 11.9 KB
@Mixin(Hud.class)
ModifiesHud
MixinHud.javaJava · 283 lines · 11.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.ModifyReceiver;
23
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
24
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
25
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
26
import net.ccbluex.liquidbounce.event.EventManager;
27
import net.ccbluex.liquidbounce.event.events.OverlayMessageEvent;
28
import net.ccbluex.liquidbounce.event.events.OverlayRenderEvent;
29
import net.ccbluex.liquidbounce.event.events.PerspectiveEvent;
30
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleSwordBlock;
31
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleReach;
32
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
33
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
34
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFreeCam;
35
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleHud;
36
import net.ccbluex.liquidbounce.features.module.modules.render.crosshair.ModuleCrosshair;
37
import net.ccbluex.liquidbounce.integration.theme.component.HudComponent;
38
import net.ccbluex.liquidbounce.integration.theme.component.HudComponentManager;
39
import net.ccbluex.liquidbounce.integration.theme.component.HudComponentTweak;
40
import net.minecraft.client.CameraType;
41
import net.minecraft.client.DeltaTracker;
42
import net.minecraft.client.Minecraft;
43
import net.minecraft.client.gui.GuiGraphicsExtractor;
44
import net.minecraft.client.gui.Hud;
45
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
46
import net.minecraft.network.chat.Component;
47
import net.minecraft.resources.Identifier;
48
import net.minecraft.world.entity.LivingEntity;
49
import net.minecraft.world.entity.player.Inventory;
50
import net.minecraft.world.entity.player.Player;
51
import net.minecraft.world.item.ItemStack;
52
import net.minecraft.world.item.component.AttackRange;
53
import net.minecraft.world.level.GameType;
54
import net.minecraft.world.phys.Vec3;
55
import org.jspecify.annotations.Nullable;
56
import org.spongepowered.asm.mixin.Final;
57
import org.spongepowered.asm.mixin.Mixin;
58
import org.spongepowered.asm.mixin.Shadow;
59
import org.spongepowered.asm.mixin.Unique;
60
import org.spongepowered.asm.mixin.injection.At;
61
import org.spongepowered.asm.mixin.injection.Inject;
62
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
63
64
import java.util.List;
65
66
@Mixin(Hud.class)
67
public abstract class MixinHud {
68
69
    @Final
70
    @Shadow
71
    private static Identifier POWDER_SNOW_OUTLINE_LOCATION;
72
73
    @Shadow
74
    @Nullable
75
    protected abstract Player getCameraPlayer();
76
77
    @Shadow
78
    @Final
79
    private Minecraft minecraft;
80
81
    @Shadow
82
    protected abstract void extractSlot(GuiGraphicsExtractor context, int x, int y, DeltaTracker tickCounter, Player player, ItemStack stack, int seed);
83
84
    /**
85
     * Hook render hud event at the top layer
86
     */
87
    @Inject(method = "extractHotbarAndDecorations", at = @At("HEAD"))
88
    private void hookRenderEventStart(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
89
        EventManager.INSTANCE.callEvent(new OverlayRenderEvent(context, tickCounter.getGameTimeDeltaPartialTick(false)));
90
91
        // Draw after overlay event
92
        var component = HudComponentManager.getComponentWithTweak(HudComponentTweak.TWEAK_HOTBAR);
93
        if (component != null && component.getRunning() &&
94
                minecraft.gameMode.getPlayerMode() != GameType.SPECTATOR) {
95
            extractHotbarForHud(context, tickCounter, component);
96
        }
97
    }
98
99
    @Inject(method = "extractSpyglassOverlay", at = @At("HEAD"), cancellable = true)
100
    private void hookRenderSpyglassOverlay(GuiGraphicsExtractor context, float scale, CallbackInfo ci) {
101
        if (!ModuleAntiBlind.canRender(DoRender.SPYGLASS_OVERLAY)) {
102
            ci.cancel();
103
        }
104
    }
105
106
    @Inject(method = "extractTextureOverlay", at = @At("HEAD"), cancellable = true)
107
    private void injectPumpkinBlur(GuiGraphicsExtractor context, Identifier texture, float opacity, CallbackInfo callback) {
108
        if (!ModuleAntiBlind.INSTANCE.getRunning()) {
109
            return;
110
        }
111
112
        if (!ModuleAntiBlind.canRender(DoRender.PUMPKIN_BLUR) && ModuleAntiBlind.TEXTURE_PUMPKIN_BLUR.equals(texture)) {
113
            callback.cancel();
114
            return;
115
        }
116
117
        if (!ModuleAntiBlind.canRender(DoRender.POWDER_SNOW_FOG) && POWDER_SNOW_OUTLINE_LOCATION.equals(texture)) {
118
            callback.cancel();
119
        }
120
    }
121
122
    @Inject(method = "extractCrosshair", at = @At("HEAD"), cancellable = true)
123
    private void hookFreeCamRenderCrosshairInThirdPerson(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
124
        if ((ModuleFreeCam.INSTANCE.getRunning() && ModuleFreeCam.INSTANCE.shouldDisableCameraInteract())
125
                || HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_CROSSHAIR) || ModuleCrosshair.INSTANCE.getEnabled()) {
126
            ci.cancel();
127
        }
128
    }
129
130
    @Inject(method = "extractPortalOverlay", at = @At("HEAD"), cancellable = true)
131
    private void hookRenderPortalOverlay(CallbackInfo ci) {
132
        if (!ModuleAntiBlind.canRender(DoRender.PORTAL_OVERLAY)) {
133
            ci.cancel();
134
        }
135
    }
136
137
    @Inject(method = "extractScoreboardSidebar", at = @At("HEAD"), cancellable = true)
138
    private void renderScoreboardSidebar(CallbackInfo ci) {
139
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_SCOREBOARD)) {
140
            ci.cancel();
141
        }
142
    }
143
144
    @Inject(method = "extractItemHotbar", at = @At("HEAD"), cancellable = true)
145
    private void hookRenderHotbar(CallbackInfo ci) {
146
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.TWEAK_HOTBAR)) {
147
            ci.cancel();
148
        }
149
    }
150
151
    @Inject(method = "extractPlayerHealth", at = @At("HEAD"), cancellable = true)
152
    private void hookRenderStatusBars(CallbackInfo ci) {
153
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_STATUS_BAR)) {
154
            ci.cancel();
155
        }
156
    }
157
158
    @ModifyReturnValue(method = "nextContextualInfoState", at = @At("RETURN"))
159
    private Hud.ContextualInfo tweakExpBar(Hud.ContextualInfo original) {
160
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_EXP_BAR) && original == Hud.ContextualInfo.EXPERIENCE) {
161
            return Hud.ContextualInfo.EMPTY;
162
        }
163
        return original;
164
    }
165
166
    @WrapOperation(method = "extractHotbarAndDecorations", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;hasExperience()Z"))
167
    private boolean tweakExpLevelText(MultiPlayerGameMode instance, Operation<Boolean> original) {
168
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_EXP_BAR)) {
169
            return false;
170
        }
171
        return original.call(instance);
172
    }
173
174
    @Inject(method = "extractSelectedItemName", at = @At("HEAD"), cancellable = true)
175
    private void hookRenderHeldItemTooltip(CallbackInfo ci) {
176
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_HELD_ITEM_TOOL_TIP)) {
177
            ci.cancel();
178
        }
179
    }
180
181
    @Inject(method = "setOverlayMessage", at = @At("HEAD"), cancellable = true)
182
    private void hookSetOverlayMessage(Component message, boolean tinted, CallbackInfo ci) {
183
        EventManager.INSTANCE.callEvent(new OverlayMessageEvent(message, tinted));
184
185
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_OVERLAY_MESSAGE)) {
186
            ci.cancel();
187
        }
188
    }
189
190
    @Inject(method = "extractEffects", at = @At("HEAD"), cancellable = true)
191
    private void hookRenderStatusEffectOverlay(CallbackInfo ci) {
192
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_STATUS_EFFECT_OVERLAY)) {
193
            ci.cancel();
194
        }
195
    }
196
197
    @ModifyExpressionValue(method = "extractItemHotbar", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;isEmpty()Z"))
198
    private boolean hookOffhandItem(boolean original) {
199
        return original || ModuleSwordBlock.INSTANCE.shouldHideOffhand() && ModuleSwordBlock.INSTANCE.getHideShieldSlot();
200
    }
201
202
    @Unique
203
    private void extractHotbarForHud(GuiGraphicsExtractor context, DeltaTracker tickCounter, HudComponent hudComponent) {
204
        var playerEntity = this.getCameraPlayer();
205
        if (playerEntity == null) {
206
            return;
207
        }
208
209
        // All values are measured, not calculated (with scale 2)
210
        // TODO: fix scaled positions
211
        final float guiScale = this.minecraft.getWindow().getGuiScale();
212
213
        float slotWidth = 22.5F;
214
        int offset = 98;
215
        var bounds = hudComponent.getAlignment().getBounds(203f, 25f);
216
217
        int xCenter = (int) bounds.xCenter();
218
        float y = bounds.yMin() + 5f;
219
220
        int seed = 1;
221
        List<ItemStack> items = playerEntity.getInventory().getNonEquipmentItems();
222
        for (int m = 0; m < Inventory.SELECTION_SIZE; ++m) {
223
            float x = xCenter - offset + m * slotWidth;
224
            this.extractSlot(context, (int) x, (int) y, tickCounter, playerEntity, items.get(m), seed++);
225
        }
226
227
        ItemStack offHandStack = playerEntity.getOffhandItem();
228
        if (!hookOffhandItem(offHandStack.isEmpty())) {
229
            this.extractSlot(context, xCenter - offset - 32, (int) y, tickCounter, playerEntity, offHandStack, seed);
230
        }
231
    }
232
233
    @ModifyExpressionValue(method = "extractCrosshair",
234
            at = @At(
235
                    value = "INVOKE",
236
                    target = "Lnet/minecraft/client/Options;getCameraType()Lnet/minecraft/client/CameraType;"
237
            )
238
    )
239
    private CameraType hookPerspectiveEventOnCrosshair(CameraType original) {
240
        return PerspectiveEvent.INSTANCE.getPerspective();
241
    }
242
243
    @ModifyExpressionValue(method = "extractCameraOverlays",
244
            at = @At(
245
                    value = "INVOKE",
246
                    target = "Lnet/minecraft/client/Options;getCameraType()Lnet/minecraft/client/CameraType;"
247
            )
248
    )
249
    private CameraType hookPerspectiveEventOnMiscOverlays(CameraType original) {
250
        return PerspectiveEvent.INSTANCE.getPerspective();
251
    }
252
253
    @Inject(method = "extractTitle", at = @At("HEAD"), cancellable = true)
254
    private void hookRenderTitleAndSubtitle(CallbackInfo ci) {
255
        if (!ModuleAntiBlind.canRender(DoRender.TITLE)) {
256
            ci.cancel();
257
        }
258
    }
259
260
    @Inject(method = "extractConfusionOverlay", at = @At("HEAD"), cancellable = true)
261
    private void hookNauseaOverlay(GuiGraphicsExtractor context, float distortionStrength, CallbackInfo ci) {
262
        if (!ModuleAntiBlind.canRender(DoRender.NAUSEA)) {
263
            ci.cancel();
264
        }
265
    }
266
267
    @ModifyReceiver(
268
        method = "extractCrosshair",
269
        at = @At(
270
            value = "INVOKE",
271
            target = "Lnet/minecraft/world/item/component/AttackRange;isInRange(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/phys/Vec3;)Z"
272
        )
273
    )
274
    private AttackRange injectReachAttackRange(AttackRange instance, LivingEntity entity, Vec3 pos) {
275
        if (ModuleReach.INSTANCE.getRunning()) {
276
            return ModuleReach.INSTANCE.getEntity().adjustAttackRange(instance);
277
        }
278
279
        return instance;
280
    }
281
282
}
283
MixinHudAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinHudAccessor.javaJava · 44 lines · 1.4 KB
@Mixin(Hud.class)
ModifiesHud
MixinHudAccessor.javaJava · 44 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import net.minecraft.client.gui.Hud;
23
import net.minecraft.resources.Identifier;
24
import net.minecraft.world.scores.PlayerScoreEntry;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.gen.Accessor;
27
28
import java.util.Comparator;
29
30
@Mixin(Hud.class)
31
public interface MixinHudAccessor {
32
33
    @Accessor("HOTBAR_SELECTION_SPRITE")
34
    static Identifier getHotbarSelectionTexture() {
35
        throw new AssertionError();
36
    }
37
38
    @Accessor("SCORE_DISPLAY_ORDER")
39
    static Comparator<PlayerScoreEntry> getScoreboardEntryComparator() {
40
        throw new AssertionError();
41
    }
42
43
}
44
MixinLoadingOverlaysrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinLoadingOverlay.javaJava · 117 lines · 4.9 KB
@Mixin(LoadingOverlay.class)
MixinLoadingOverlay.javaJava · 117 lines · 4.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
24
import com.llamalad7.mixinextras.sugar.Local;
25
import com.mojang.blaze3d.pipeline.RenderPipeline;
26
import net.ccbluex.liquidbounce.common.ClientLogoTexture;
27
import net.ccbluex.liquidbounce.event.EventManager;
28
import net.ccbluex.liquidbounce.event.events.ScreenRenderEvent;
29
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
30
import net.ccbluex.liquidbounce.render.ClientRenderPipelines;
31
import net.minecraft.client.gui.GuiGraphicsExtractor;
32
import net.minecraft.client.gui.screens.LoadingOverlay;
33
import net.minecraft.client.renderer.texture.TextureManager;
34
import net.minecraft.resources.Identifier;
35
import net.minecraft.util.ARGB;
36
import org.objectweb.asm.Opcodes;
37
import org.spongepowered.asm.mixin.Mixin;
38
import org.spongepowered.asm.mixin.Unique;
39
import org.spongepowered.asm.mixin.injection.At;
40
import org.spongepowered.asm.mixin.injection.Inject;
41
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
42
43
import java.util.function.IntSupplier;
44
45
/**
46
 * LiquidBounce Splash Screen
47
 */
48
@Mixin(LoadingOverlay.class)
49
public abstract class MixinLoadingOverlay {
50
51
    @Unique
52
    private static final IntSupplier CLIENT_ARGB = () -> ARGB.color(255, 24, 26, 27);
53
54
    @Inject(method = "registerTextures", at = @At("RETURN"))
55
    private static void initializeTexture(TextureManager textureManager, CallbackInfo ci) {
56
        textureManager.registerAndLoad(ClientLogoTexture.CLIENT_LOGO, new ClientLogoTexture());
57
    }
58
59
    @Inject(method = "extractRenderState", at = @At("RETURN"))
60
    private void render(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
61
        EventManager.INSTANCE.callEvent(new ScreenRenderEvent(context, delta));
62
    }
63
64
    @WrapWithCondition(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blit(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIFFIIIIIII)V"))
65
    private boolean drawMojangLogo(GuiGraphicsExtractor instance, RenderPipeline renderPipeline, Identifier sprite, int x, int y, float u, float v, int width, int height, int regionWidth, int regionHeight, int textureWidth, int textureHeight, int color) {
66
        return SelfDestruct.INSTANCE.isDestructed();
67
    }
68
69
    @Inject(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/resources/ReloadInstance;getActualProgress()F"))
70
    private void drawClientLogo(
71
            GuiGraphicsExtractor graphics,
72
            int mouseX,
73
            int mouseY,
74
            float a,
75
            CallbackInfo ci,
76
            @Local(name = "color") int color
77
    ) {
78
        if (SelfDestruct.INSTANCE.isDestructed()) {
79
            return;
80
        }
81
82
        int screenWidth = graphics.guiWidth();
83
        int screenHeight = graphics.guiHeight();
84
85
        float scaleFactor = Math.min(screenWidth * 0.4f / ClientLogoTexture.WIDTH, screenHeight * 0.25f / ClientLogoTexture.HEIGHT);
86
87
        int displayWidth = (int)(ClientLogoTexture.WIDTH * scaleFactor);
88
        int displayHeight = (int)(ClientLogoTexture.HEIGHT * scaleFactor);
89
90
        int x = (screenWidth - displayWidth) / 2;
91
        int y = (screenHeight - displayHeight) / 2;
92
93
        // TODO: Draw as SVG instead of PNG
94
        graphics.blit(
95
            ClientRenderPipelines.JCEF.SMOOTH_TEXTURE,
96
                ClientLogoTexture.CLIENT_LOGO,
97
                x,
98
                y,
99
                0.0F,
100
                0.0F,
101
                displayWidth,
102
                displayHeight,
103
                ClientLogoTexture.WIDTH,
104
                ClientLogoTexture.HEIGHT,
105
                ClientLogoTexture.WIDTH,
106
                ClientLogoTexture.HEIGHT,
107
                color
108
        );
109
    }
110
111
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screens/LoadingOverlay;BRAND_BACKGROUND:Ljava/util/function/IntSupplier;", opcode = Opcodes.GETSTATIC))
112
    private IntSupplier withClientColor(IntSupplier original) {
113
        return SelfDestruct.INSTANCE.isDestructed() ? original : CLIENT_ARGB;
114
    }
115
116
}
117
MixinLocatorBarsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinLocatorBar.javaJava · 48 lines · 1.9 KB
@Mixin(LocatorBar.class)
ModifiesLocatorBar
MixinLocatorBar.javaJava · 48 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import net.ccbluex.liquidbounce.integration.theme.component.HudComponentManager;
23
import net.ccbluex.liquidbounce.integration.theme.component.HudComponentTweak;
24
import net.minecraft.client.gui.contextualbar.LocatorBar;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
30
@Mixin(LocatorBar.class)
31
public abstract class MixinLocatorBar {
32
33
    @Inject(method = "extractRenderState", at = @At("HEAD"), cancellable = true)
34
    private void hookDisableLocatorBarTweak(final CallbackInfo ci) {
35
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_LOCATOR_BAR)) {
36
            ci.cancel();
37
        }
38
    }
39
40
    @Inject(method = "extractBackground", at = @At("HEAD"), cancellable = true)
41
    private void hookDisableLocatorBarTweakOnBackground(final CallbackInfo ci) {
42
        if (HudComponentManager.isTweakEnabled(HudComponentTweak.DISABLE_LOCATOR_BAR)) {
43
            ci.cancel();
44
        }
45
    }
46
47
}
48
MixinPlayerTabOverlaysrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinPlayerTabOverlay.javaJava · 205 lines · 10.6 KB
@Mixin(PlayerTabOverlay.class)
MixinPlayerTabOverlay.javaJava · 205 lines · 10.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
20
21
import static net.ccbluex.liquidbounce.utils.entity.EntityExtensionsKt.shortName;
22
23
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
24
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
25
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
26
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
27
import com.llamalad7.mixinextras.sugar.Local;
28
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
29
import net.ccbluex.liquidbounce.features.misc.FriendManager;
30
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleAntiStaff;
31
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleBetterTab;
32
import net.ccbluex.liquidbounce.features.module.modules.misc.Visibility;
33
import net.ccbluex.liquidbounce.utils.text.PlainText;
34
import net.ccbluex.liquidbounce.utils.text.TextBuilder;
35
import net.minecraft.client.Minecraft;
36
import net.minecraft.client.gui.GuiGraphicsExtractor;
37
import net.minecraft.client.gui.components.PlayerTabOverlay;
38
import net.minecraft.client.multiplayer.PlayerInfo;
39
import net.minecraft.network.chat.Component;
40
import net.minecraft.network.chat.TextColor;
41
import net.minecraft.util.CommonColors;
42
import net.minecraft.util.Mth;
43
import org.objectweb.asm.Opcodes;
44
import org.spongepowered.asm.mixin.Mixin;
45
import org.spongepowered.asm.mixin.Shadow;
46
import org.spongepowered.asm.mixin.injection.At;
47
import org.spongepowered.asm.mixin.injection.Inject;
48
import org.spongepowered.asm.mixin.injection.ModifyArg;
49
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
50
51
import java.util.Comparator;
52
import java.util.List;
53
import java.util.Objects;
54
import java.util.stream.Stream;
55
56
@Mixin(PlayerTabOverlay.class)
57
public abstract class MixinPlayerTabOverlay {
58
59
    @Shadow
60
    protected abstract List<PlayerInfo> getPlayerInfos();
61
62
    @WrapOperation(method = "getPlayerInfos", at = @At(value = "INVOKE", target = "Ljava/util/stream/Stream;limit(J)Ljava/util/stream/Stream;"))
63
    private Stream<PlayerInfo> injectTabSize(Stream<PlayerInfo> instance, long l, Operation<Stream<PlayerInfo>> original) {
64
        long size = ModuleBetterTab.INSTANCE.getRunning() ? ModuleBetterTab.Limits.INSTANCE.getTabSize() : l;
65
        return original.call(instance, size);
66
    }
67
68
    @WrapOperation(method = "getPlayerInfos", at = @At(value = "INVOKE", target = "Ljava/util/stream/Stream;sorted(Ljava/util/Comparator;)Ljava/util/stream/Stream;"))
69
    private Stream<PlayerInfo> hookSort(Stream<PlayerInfo> instance, Comparator<PlayerInfo> defaultComparator, Operation<Stream<PlayerInfo>> original) {
70
        var betterTab = ModuleBetterTab.INSTANCE;
71
72
        var running = betterTab.getRunning();
73
        var customComparator = betterTab.getSorting().getComparator();
74
75
        var comparator = running ? (customComparator != null ? customComparator : defaultComparator) : defaultComparator;
76
77
        var playerHider = ModuleBetterTab.PlayerHider.INSTANCE;
78
        var hidden = running && playerHider.getRunning() ? instance.filter(player -> !playerHider.getFilter().isInFilter(player)) : instance;
79
80
        return original.call(hidden, comparator);
81
    }
82
83
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/components/PlayerTabOverlay;header:Lnet/minecraft/network/chat/Component;", ordinal = 0, opcode = Opcodes.GETFIELD))
84
    private Component hookHeader(Component original) {
85
        if (!ModuleBetterTab.INSTANCE.getRunning()) {
86
            return original;
87
        }
88
89
        return ModuleBetterTab.isVisible(Visibility.HEADER) ? original : null;
90
    }
91
92
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/components/PlayerTabOverlay;footer:Lnet/minecraft/network/chat/Component;", ordinal = 0, opcode = Opcodes.GETFIELD))
93
    private Component hookFooter(Component original) {
94
        if (!ModuleBetterTab.INSTANCE.getRunning()) {
95
            return original;
96
        }
97
98
        return ModuleBetterTab.isVisible(Visibility.FOOTER) ? original : null;
99
    }
100
101
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/components/PlayerTabOverlay$ScoreDisplayEntry;name:Lnet/minecraft/network/chat/Component;", opcode = Opcodes.GETFIELD))
102
    private Component hookVisibilityName(Component original, @Local(name = "info") PlayerInfo entry) {
103
        if (!ModuleBetterTab.INSTANCE.getRunning()) {
104
            return original;
105
        }
106
107
        return ModuleBetterTab.isVisible(Visibility.NAME_ONLY) ? Component.nullToEmpty(entry.getProfile().name()) : original;
108
109
    }
110
111
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/PlayerTabOverlay;getNameForDisplay(Lnet/minecraft/client/multiplayer/PlayerInfo;)Lnet/minecraft/network/chat/Component;"))
112
    private Component hookWidthVisibilityName(Component original, @Local(name = "info") PlayerInfo entry) {
113
        if (!ModuleBetterTab.INSTANCE.getRunning()) {
114
            return original;
115
        }
116
117
        return ModuleBetterTab.isVisible(Visibility.NAME_ONLY) ? Component.nullToEmpty(entry.getProfile().name()) : original;
118
    }
119
120
    @Inject(method = "extractRenderState", at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(II)I", shift = At.Shift.BEFORE))
121
    private void hookTabColumnHeight(CallbackInfo ci, @Local(name = "rows") LocalIntRef o, @Local(name = "cols") LocalIntRef p) {
122
        if (!ModuleBetterTab.INSTANCE.getRunning()) {
123
            return;
124
        }
125
126
        int playerCount = getPlayerInfos().size();
127
        int height = Math.max(1, ModuleBetterTab.Limits.INSTANCE.getHeight());
128
        int columns = Math.max(1, Mth.ceil((double) playerCount / height));
129
        int rows = Mth.ceil((double) playerCount / columns);
130
        o.set(rows);
131
        p.set(columns);
132
    }
133
134
    /**
135
     * @source <a href="https://github.com/MeteorDevelopment/meteor-client/blob/2025789457e5b4c0671f04f0d3c7e0d91a31765c/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListHudMixin.java#L46-L51">code section</a>
136
     * @contributor sqlerrorthing (<a href="https://github.com/CCBlueX/LiquidBounce/pull/5077">pull request</a>)
137
     * @author Paul1365972 (on Meteor Client)
138
     */
139
    @ModifyArg(method = "extractRenderState", at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(II)I"), index = 0)
140
    private int hookWidth(int width) {
141
        return ModuleBetterTab.INSTANCE.getRunning() && ModuleBetterTab.AccurateLatency.INSTANCE.getRunning() ? width + 30 : width;
142
    }
143
144
    /**
145
     * @source <a href="https://github.com/MeteorDevelopment/meteor-client/blob/2025789457e5b4c0671f04f0d3c7e0d91a31765c/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListHudMixin.java#L28">code section</a>
146
     * @contributor sqlerrorthing (<a href="https://github.com/CCBlueX/LiquidBounce/pull/5077">pull request</a>)
147
     * @author Paul1365972 (on Meteor Client)
148
     */
149
    @Inject(method = "extractPingIcon", at = @At("HEAD"), cancellable = true)
150
    private void hookOnRenderLatencyIcon(GuiGraphicsExtractor context, int width, int x, int y, PlayerInfo entry, CallbackInfo ci) {
151
        var accurateLatency = ModuleBetterTab.AccurateLatency.INSTANCE;
152
        if (ModuleBetterTab.INSTANCE.getRunning() && accurateLatency.getRunning()) {
153
            var textRenderer = Minecraft.getInstance().font;
154
155
            var latency = Mth.clamp(entry.getLatency(), 0, 9999);
156
            var color = latency < 150 ? 0xFF00E970 : latency < 300 ? 0xFFE7D020 : 0xFFD74238;
157
            var text = latency + (accurateLatency.getSuffix() ? "ms" : "");
158
            context.text(textRenderer, text, x + width - textRenderer.width(text), y, color);
159
            ci.cancel();
160
        }
161
    }
162
163
    // ModifyArg breaks lunar compatibility as of 17.1.2025 (minecraft 1.21.4); that's why WrapOperation is used
164
    @WrapOperation(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;fill(IIIII)V", ordinal = 2))
165
    private void hookRenderPlayerBackground(GuiGraphicsExtractor instance, int x0, int y0, int x1, int y1, int col, Operation<Void> original, @Local(name = "i") int i, @Local(name = "playerInfos") List<PlayerInfo> playerInfos) {
166
        var drawColor = col;
167
168
        var highlight = ModuleBetterTab.Highlight.INSTANCE;
169
        if (ModuleBetterTab.INSTANCE.getRunning() && highlight.getRunning() && i < playerInfos.size()) {
170
            var entry = playerInfos.get(i);
171
            var others = highlight.getOthers();
172
173
            //noinspection DataFlowIssue
174
            if (highlight.getSelf().getRunning() && Objects.equals(entry.getProfile().name(), Minecraft.getInstance().player.getGameProfile().name())) {
175
                drawColor = highlight.getSelf().getColor().argb();
176
            } else if (highlight.getFriends().getRunning() && FriendManager.INSTANCE.isFriend(entry.getProfile().name())) {
177
                drawColor = highlight.getFriends().getColor().argb();
178
            } else if (others.getRunning() && others.getFilter().isInFilter(entry)) {
179
                drawColor = others.getColor().argb();
180
            }
181
        }
182
183
        original.call(instance, x0, y0, x1, y1, drawColor);
184
    }
185
186
    @ModifyReturnValue(method = "getNameForDisplay", at = @At("RETURN"))
187
    private Component modifyPlayerName(Component original, PlayerInfo entry) {
188
        var components = new TextBuilder(original);
189
190
        if (ModuleBetterTab.INSTANCE.getRunning() && ModuleBetterTab.INSTANCE.getShowGameMode()) {
191
            var playerGameMode = entry.getGameMode();
192
            var gameModeText = PlainText.of(" [" + shortName(playerGameMode) + "]");
193
            components.add(gameModeText);
194
        }
195
196
        if (ModuleAntiStaff.INSTANCE.shouldShowAsStaffOnTab(entry.getProfile().name())) {
197
            var staffText = PlainText.of(" - (Staff)", TextColor.fromRgb(CommonColors.SOFT_RED));
198
            components.add(staffText);
199
        }
200
201
        return components.build();
202
    }
203
204
}
205
MixinScoreboardsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinScoreboard.javaJava · 63 lines · 2.5 KB
@Mixin(Scoreboard.class)
ModifiesScoreboard
MixinScoreboard.javaJava · 63 lines · 2.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleAntiExploit;
23
import net.minecraft.world.scores.PlayerTeam;
24
import net.minecraft.world.scores.Scoreboard;
25
import org.jspecify.annotations.Nullable;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.Shadow;
28
import org.spongepowered.asm.mixin.injection.At;
29
import org.spongepowered.asm.mixin.injection.Inject;
30
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31
32
/**
33
 * Fixes a ViaFabricPlus bug where it would not correctly handle the scoreboard data, resulting in a disconnect.
34
 * <p>
35
 * ViaFabricPlus versions: 3.4.8-?
36
 */
37
@Mixin(Scoreboard.class)
38
public abstract class MixinScoreboard {
39
40
    @Shadow
41
    @Nullable
42
    public abstract PlayerTeam getPlayersTeam(String scoreHolderName);
43
44
    @ModifyExpressionValue(method = "addObjective", at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/objects/Object2ObjectMap;containsKey(Ljava/lang/Object;)Z", remap = false))
45
    private boolean noCrash(boolean original) {
46
        var antiExploit = ModuleAntiExploit.INSTANCE;
47
        if (antiExploit.getRunning() && antiExploit.getVfpScoreboardFix()) {
48
            return false;
49
        } else {
50
            return original;
51
        }
52
    }
53
54
    @Inject(method = "removePlayerFromTeam(Ljava/lang/String;Lnet/minecraft/world/scores/PlayerTeam;)V", at = @At("HEAD"), cancellable = true)
55
    private void noCrash2(String scoreHolderName, PlayerTeam team, CallbackInfo ci) {
56
        var antiExploit = ModuleAntiExploit.INSTANCE;
57
        if (antiExploit.getRunning() && antiExploit.getVfpScoreboardFix() && getPlayersTeam(scoreHolderName) != team) {
58
            ci.cancel();
59
        }
60
    }
61
62
}
63
MixinScreensrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinScreen.javaJava · 135 lines · 5.1 KB
@Mixin(Screen.class)
ModifiesScreen
MixinScreen.javaJava · 135 lines · 5.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
20
21
import net.ccbluex.liquidbounce.LiquidBounce;
22
import net.ccbluex.liquidbounce.additions.ScreenAddition;
23
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
24
import net.ccbluex.liquidbounce.features.module.modules.player.cheststealer.features.FeatureSilentScreen;
25
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
26
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
27
import net.ccbluex.liquidbounce.integration.screen.ScreenManager;
28
import net.ccbluex.liquidbounce.integration.theme.ThemeManager;
29
import net.ccbluex.liquidbounce.utils.text.RunnableClickEvent;
30
import net.minecraft.client.Minecraft;
31
import net.minecraft.client.gui.Font;
32
import net.minecraft.client.gui.GuiGraphicsExtractor;
33
import net.minecraft.client.gui.components.Renderable;
34
import net.minecraft.client.gui.components.events.GuiEventListener;
35
import net.minecraft.client.gui.screens.Screen;
36
import net.minecraft.network.chat.ClickEvent;
37
import org.jspecify.annotations.Nullable;
38
import org.spongepowered.asm.mixin.Final;
39
import org.spongepowered.asm.mixin.Mixin;
40
import org.spongepowered.asm.mixin.Shadow;
41
import org.spongepowered.asm.mixin.Unique;
42
import org.spongepowered.asm.mixin.injection.At;
43
import org.spongepowered.asm.mixin.injection.Inject;
44
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
45
46
@Mixin(Screen.class)
47
public abstract class MixinScreen implements ScreenAddition {
48
49
    @Final
50
    @Shadow
51
    protected Font font;
52
    @Shadow
53
    public int height;
54
    @Shadow
55
    public int width;
56
57
    @Shadow
58
    protected abstract <T extends GuiEventListener & Renderable> T addRenderableWidget(T drawableElement);
59
60
    @Final
61
    @Shadow
62
    @Nullable
63
    protected Minecraft minecraft;
64
65
    @Shadow
66
    private boolean initialized;
67
68
    @Inject(method = "init(II)V", at = @At("TAIL"))
69
    private void objInit(CallbackInfo ci) {
70
        if (!LiquidBounce.INSTANCE.isInitialized()) {
71
            return;
72
        }
73
74
        ThemeManager.INSTANCE.loadBackgroundAsync();
75
    }
76
77
    @Inject(method = "init()V", at = @At("TAIL"))
78
    protected void init(CallbackInfo ci) {
79
        if (!LiquidBounce.INSTANCE.isInitialized()) {
80
            return;
81
        }
82
83
        ThemeManager.INSTANCE.loadBackgroundAsync();
84
    }
85
86
    @Inject(method = "extractTransparentBackground", at = @At("HEAD"), cancellable = true)
87
    private void hookRenderInGameBackground(GuiGraphicsExtractor context, CallbackInfo ci) {
88
        if (!ModuleAntiBlind.canRender(DoRender.GUI_BACKGROUND)) {
89
            ci.cancel();
90
        }
91
    }
92
93
    @Inject(method = "extractRenderStateWithTooltipAndSubtitles", at = @At("HEAD"), cancellable = true)
94
    private void cancelRenderByChestStealer(CallbackInfo ci) {
95
        if (LiquidBounce.INSTANCE.isInitialized() && FeatureSilentScreen.INSTANCE.getShouldHide()) {
96
            ci.cancel();
97
        }
98
    }
99
100
    @Inject(method = "extractBackground", at = @At("HEAD"), cancellable = true)
101
    private void renderBackgroundTexture(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
102
        if (this.minecraft != null && this.minecraft.level == null && !SelfDestruct.INSTANCE.isDestructed()) {
103
            if (!LiquidBounce.INSTANCE.isInitialized()) {
104
                return;
105
            }
106
107
            if (ThemeManager.INSTANCE.isBasicMode() && !ScreenManager.isClientScreen((Screen) (Object) this)) {
108
                return;
109
            }
110
111
            if (ThemeManager.INSTANCE.drawBackground(context, width, height, mouseX, mouseY, delta)) {
112
                ci.cancel();
113
            }
114
        }
115
    }
116
117
    /**
118
     * Allows the execution of {@link RunnableClickEvent}.
119
     * (default branch in switch pattern matching)
120
     */
121
    @Inject(method = "defaultHandleClickEvent", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", ordinal = 0, shift = At.Shift.BEFORE, remap = false), cancellable = true)
122
    private static void hookExecuteClickEvents(ClickEvent clickEvent, Minecraft client, Screen screenAfterRun, CallbackInfo ci) {
123
        if (clickEvent instanceof RunnableClickEvent runnableClickEvent) {
124
            runnableClickEvent.run();
125
            ci.cancel();
126
        }
127
    }
128
129
    @Unique
130
    @Override
131
    public boolean liquidbounce$screenInitialized() {
132
        return initialized;
133
    }
134
}
135
MixinScreenRectanglesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinScreenRectangle.javaJava · 79 lines · 2.8 KB
@Mixin(ScreenRectangle.class)
MixinScreenRectangle.javaJava · 79 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import com.llamalad7.mixinextras.sugar.Local;
25
import net.ccbluex.liquidbounce.utils.collection.Pools;
26
import net.minecraft.client.gui.navigation.ScreenRectangle;
27
import org.joml.Matrix3x2fc;
28
import org.joml.Vector2f;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
33
34
@Mixin(ScreenRectangle.class)
35
public abstract class MixinScreenRectangle {
36
37
    @WrapOperation(
38
        method = "transformAxisAligned",
39
        at = @At(value = "NEW", target = "()Lorg/joml/Vector2f;", remap = false)
40
    )
41
    private Vector2f reuseVec_transform(Operation<Vector2f> original) {
42
        return Pools.Vec2f.borrow();
43
    }
44
45
    @WrapOperation(
46
        method = "transformMaxBounds",
47
        at = @At(value = "NEW", target = "()Lorg/joml/Vector2f;", remap = false)
48
    )
49
    private Vector2f reuseVec_transformEachVertex(Operation<Vector2f> original) {
50
        return Pools.Vec2f.borrow();
51
    }
52
53
    @Inject(
54
        method = "transformAxisAligned",
55
        at = @At("RETURN")
56
    )
57
    private void recycleVec_transform(
58
        Matrix3x2fc matrix, CallbackInfoReturnable<ScreenRectangle> cir, @Local(name = "topLeft") Vector2f v0, @Local(name = "bottomRight") Vector2f v1
59
    ) {
60
        Pools.Vec2f.recycle(v0);
61
        Pools.Vec2f.recycle(v1);
62
    }
63
64
    @Inject(
65
        method = "transformMaxBounds",
66
        at = @At("RETURN")
67
    )
68
    private void recycleVec_transformEachVertex(
69
        Matrix3x2fc matrix, CallbackInfoReturnable<ScreenRectangle> cir, @Local(name = "topLeft") Vector2f v0,
70
        @Local(name = "topRight") Vector2f v1, @Local(name = "bottomLeft") Vector2f v2, @Local(name = "bottomRight") Vector2f v3
71
    ) {
72
        Pools.Vec2f.recycle(v0);
73
        Pools.Vec2f.recycle(v1);
74
        Pools.Vec2f.recycle(v2);
75
        Pools.Vec2f.recycle(v3);
76
    }
77
78
}
79
MixinSubtitleOverlaysrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinSubtitleOverlay.javaJava · 118 lines · 3.9 KB
@Mixin(SubtitleOverlay.class)
MixinSubtitleOverlay.javaJava · 118 lines · 3.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui;
20
21
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import net.ccbluex.liquidbounce.integration.theme.component.SubtitleOverlayCapture;
25
import net.minecraft.client.gui.Font;
26
import net.minecraft.client.gui.GuiGraphicsExtractor;
27
import net.minecraft.client.gui.components.SubtitleOverlay;
28
import net.minecraft.network.chat.Component;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
32
/**
33
 * Captures the values passed to the vanilla subtitle renderer without reproducing its state calculations.
34
 *
35
 * @see net.minecraft.client.gui.components.SubtitleOverlay#extractRenderState(GuiGraphicsExtractor)
36
 */
37
@Mixin(SubtitleOverlay.class)
38
public abstract class MixinSubtitleOverlay {
39
40
    @WrapMethod(method = "extractRenderState")
41
    private void captureFrame(GuiGraphicsExtractor graphics, Operation<Void> original) {
42
        SubtitleOverlayCapture.begin();
43
        try {
44
            original.call(graphics);
45
            SubtitleOverlayCapture.publish();
46
        } finally {
47
            SubtitleOverlayCapture.end();
48
        }
49
    }
50
51
    @WrapOperation(
52
        method = "extractRenderState",
53
        at = @At(
54
            value = "INVOKE",
55
            target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;fill(IIIII)V"
56
        )
57
    )
58
    private void captureBackground(
59
        GuiGraphicsExtractor graphics,
60
        int x0,
61
        int y0,
62
        int x1,
63
        int y1,
64
        int color,
65
        Operation<Void> original
66
    ) {
67
        SubtitleOverlayCapture.captureBackground(color);
68
        if (SubtitleOverlayCapture.shouldRenderVanilla()) {
69
            original.call(graphics, x0, y0, x1, y1, color);
70
        }
71
    }
72
73
    @WrapOperation(
74
        method = "extractRenderState",
75
        at = @At(
76
            value = "INVOKE",
77
            target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;text(Lnet/minecraft/client/gui/Font;Ljava/lang/String;III)V"
78
        )
79
    )
80
    private void captureDirection(
81
        GuiGraphicsExtractor graphics,
82
        Font font,
83
        String text,
84
        int x,
85
        int y,
86
        int color,
87
        Operation<Void> original
88
    ) {
89
        SubtitleOverlayCapture.captureDirection(text);
90
        if (SubtitleOverlayCapture.shouldRenderVanilla()) {
91
            original.call(graphics, font, text, x, y, color);
92
        }
93
    }
94
95
    @WrapOperation(
96
        method = "extractRenderState",
97
        at = @At(
98
            value = "INVOKE",
99
            target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;text(Lnet/minecraft/client/gui/Font;Lnet/minecraft/network/chat/Component;III)V"
100
        )
101
    )
102
    private void captureSubtitle(
103
        GuiGraphicsExtractor graphics,
104
        Font font,
105
        Component text,
106
        int x,
107
        int y,
108
        int color,
109
        Operation<Void> original
110
    ) {
111
        SubtitleOverlayCapture.captureSubtitle(text, color);
112
        if (SubtitleOverlayCapture.shouldRenderVanilla()) {
113
            original.call(graphics, font, text, x, y, color);
114
        }
115
    }
116
117
}
118
MixinConnectScreensrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/custom/MixinConnectScreen.javaJava · 174 lines · 7.1 KB
@Mixin(ConnectScreen.class)
MixinConnectScreen.javaJava · 174 lines · 7.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui.custom;
21
22
import net.ccbluex.liquidbounce.api.thirdparty.IpInfoApi;
23
import net.ccbluex.liquidbounce.event.EventManager;
24
import net.ccbluex.liquidbounce.event.events.ServerConnectEvent;
25
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
26
import net.ccbluex.liquidbounce.features.misc.proxy.ProxyManager;
27
import net.ccbluex.liquidbounce.injection.mixins.minecraft.gui.MixinScreen;
28
import net.ccbluex.liquidbounce.utils.text.PlainText;
29
import net.ccbluex.liquidbounce.utils.text.TextList;
30
import net.minecraft.ChatFormatting;
31
import net.minecraft.client.Minecraft;
32
import net.minecraft.client.gui.GuiGraphicsExtractor;
33
import net.minecraft.client.gui.screens.ConnectScreen;
34
import net.minecraft.client.multiplayer.ServerData;
35
import net.minecraft.client.multiplayer.TransferState;
36
import net.minecraft.client.multiplayer.resolver.ServerAddress;
37
import net.minecraft.network.Connection;
38
import net.minecraft.network.chat.Component;
39
import org.jspecify.annotations.Nullable;
40
import org.spongepowered.asm.mixin.Mixin;
41
import org.spongepowered.asm.mixin.Shadow;
42
import org.spongepowered.asm.mixin.Unique;
43
import org.spongepowered.asm.mixin.injection.At;
44
import org.spongepowered.asm.mixin.injection.Constant;
45
import org.spongepowered.asm.mixin.injection.Inject;
46
import org.spongepowered.asm.mixin.injection.ModifyConstant;
47
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
48
49
import java.net.InetSocketAddress;
50
import java.util.ArrayList;
51
52
import static net.ccbluex.liquidbounce.utils.text.TextExtensionsKt.hideSensitiveAddress;
53
54
@Mixin(ConnectScreen.class)
55
public abstract class MixinConnectScreen extends MixinScreen {
56
57
    @Shadow
58
    private volatile @Nullable Connection connection;
59
60
    @Shadow
61
    public abstract void connect(
62
        Minecraft client, ServerAddress address, ServerData info, @Nullable TransferState cookieStorage);
63
64
    @Unique
65
    private ServerAddress serverAddress = null;
66
67
    @Inject(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;centeredText(Lnet/minecraft/client/gui/Font;Lnet/minecraft/network/chat/Component;III)V"))
68
    private void injectRender(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta, final CallbackInfo callback) {
69
        /*
70
         * Make a text demonstration of the connection status
71
         * This is useful for debugging the connection trace
72
         *
73
         * Looks like this: Client <> Proxy <> Server
74
         *
75
         * For Client, it should show the actual client IP
76
         * For Proxy, it should show the proxy IP
77
         * For Server, it should show the server IP
78
         */
79
80
        var clientConnection = this.connection;
81
        var serverAddress = this.serverAddress;
82
83
        if (clientConnection == null || this.serverAddress == null || SelfDestruct.INSTANCE.isDestructed()) {
84
            return;
85
        }
86
87
        var connectionDetails = getConnectionDetails(clientConnection, serverAddress);
88
        context.centeredText(this.font, connectionDetails, this.width / 2,
89
            this.height / 2 - 60, -1);
90
    }
91
92
93
    @Inject(method = "connect(Lnet/minecraft/client/Minecraft;Lnet/minecraft/client/multiplayer/resolver/ServerAddress;Lnet/minecraft/client/multiplayer/ServerData;Lnet/minecraft/client/multiplayer/TransferState;)V", at = @At("HEAD"), cancellable = true)
94
    private void injectConnect(Minecraft client, ServerAddress address, ServerData info, TransferState cookieStorage, CallbackInfo ci) {
95
        this.serverAddress = address;
96
        var event = EventManager.INSTANCE.callEvent(new ServerConnectEvent((ConnectScreen) (Object) this, address, info, cookieStorage));
97
98
        if (event.isCancelled()) {
99
            ci.cancel();
100
        }
101
    }
102
103
    @ModifyConstant(method = "extractRenderState", constant = @Constant(intValue = 50))
104
    private int modifyStatusY(int original) {
105
        return original + 30;
106
    }
107
108
    @Unique
109
    private Component getConnectionDetails(Connection clientConnection, ServerAddress serverAddress) {
110
        // This will either be the socket address or the server address
111
        var socketAddr = getSocketAddress(clientConnection, serverAddress);
112
        var serverAddr = String.format(
113
                "%s:%s",
114
                hideSensitiveAddress(serverAddress.getHost()),
115
                serverAddress.getPort()
116
        );
117
        var ipInfo = IpInfoApi.INSTANCE.getCurrent();
118
119
        var spacer = PlainText.of(" ⟺ ", ChatFormatting.DARK_GRAY);
120
121
        var textParts = new ArrayList<Component>();
122
123
        var client = PlainText.of("Client", ChatFormatting.BLUE);
124
        textParts.add(client);
125
126
        if (ipInfo != null) {
127
            var country = ipInfo.getCountry();
128
129
            if (country != null) {
130
                textParts.add(PlainText.of(" (", ChatFormatting.DARK_GRAY));
131
                textParts.add(PlainText.of(country, ChatFormatting.BLUE));
132
                textParts.add(PlainText.of(")", ChatFormatting.DARK_GRAY));
133
            }
134
        }
135
        textParts.add(spacer);
136
137
        var socket = PlainText.of(
138
            socketAddr,
139
            ProxyManager.INSTANCE.getCurrentProxy() != null
140
                ? ChatFormatting.GOLD // No proxy - shows server address
141
                : ChatFormatting.RED // Proxy good
142
        );
143
        textParts.add(socket);
144
        textParts.add(spacer);
145
146
        var server = PlainText.of(serverAddr, ChatFormatting.GREEN);
147
        textParts.add(server);
148
149
        return TextList.of(textParts);
150
    }
151
152
    @Unique
153
    private static String getSocketAddress(Connection clientConnection, ServerAddress serverAddress) {
154
        String socketAddr;
155
        if (clientConnection.getRemoteAddress() instanceof InetSocketAddress address) {
156
            // In this we do not redact the host string - it is usually not sensitive
157
            var hostString = address.getHostString();
158
            var hostAddress = address.isUnresolved() ?
159
                    "<unresolved>" :
160
                    address.getAddress().getHostAddress();
161
162
            if (hostString.equals(serverAddress.getHost())) {
163
                socketAddr = String.format("%s:%s", hostAddress, address.getPort());
164
            } else {
165
                socketAddr = String.format("%s/%s:%s", hostString, hostAddress, address.getPort());
166
            }
167
        } else {
168
            socketAddr = "<unknown>";
169
        }
170
        return socketAddr;
171
    }
172
173
}
174
MixinDisconnectedScreensrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/custom/MixinDisconnectedScreen.javaJava · 86 lines · 3.1 KB
@Mixin(DisconnectedScreen.class)
MixinDisconnectedScreen.javaJava · 86 lines · 3.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui.custom;
21
22
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
23
import net.ccbluex.liquidbounce.injection.mixins.minecraft.gui.MixinScreen;
24
import net.minecraft.client.gui.components.Button;
25
import net.minecraft.client.gui.screens.DisconnectedScreen;
26
import net.minecraft.client.gui.screens.Screen;
27
import net.minecraft.client.gui.screens.TitleScreen;
28
import net.minecraft.network.chat.Component;
29
import org.spongepowered.asm.mixin.Final;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.Shadow;
32
import org.spongepowered.asm.mixin.Unique;
33
import org.spongepowered.asm.mixin.injection.At;
34
import org.spongepowered.asm.mixin.injection.Inject;
35
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
36
37
@Mixin(DisconnectedScreen.class)
38
public abstract class MixinDisconnectedScreen extends MixinScreen {
39
40
    @Shadow
41
    @Final
42
    private static Component TO_TITLE;
43
44
    @Shadow
45
    @Final
46
    private Component buttonText;
47
48
    @Shadow
49
    @Final
50
    private Screen parent;
51
52
    @Unique
53
    private Button disconnectButton;
54
55
    @Inject(method = "init", at = @At("HEAD"))
56
    private void injectButtons(final CallbackInfo callback) {
57
        if (SelfDestruct.INSTANCE.isDestructed()) {
58
            return;
59
        }
60
61
        /*
62
         * Add second quit button in-case the first one is being covered by the multiplayer message
63
         * This technique is used by many servers or anti-cheats to prevent players from quitting
64
         * out of the game when they are banned
65
         */
66
        int x = this.width - 140;
67
        int y = this.height - 30;
68
        disconnectButton = (this.minecraft.allowsMultiplayer() ?
69
                Button.builder(this.buttonText, button -> this.minecraft.gui.setScreen(this.parent)) :
70
                Button.builder(TO_TITLE, button -> this.minecraft.gui.setScreen(new TitleScreen()))
71
        ).bounds(x, y, 120, 20).build();
72
        addRenderableWidget(disconnectButton);
73
    }
74
75
    @Inject(method = "repositionElements", at = @At("HEAD"))
76
    private void moveButtons(final CallbackInfo callback) {
77
        if (disconnectButton != null) {
78
            // fixes button position
79
            int x = this.width - 140;
80
            int y = this.height - 30;
81
            disconnectButton.setPosition(x, y);
82
        }
83
    }
84
85
}
86
MixinLevelLoadingScreensrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/custom/MixinLevelLoadingScreen.javaJava · 50 lines · 1.8 KB
@Mixin(LevelLoadingScreen.class)
MixinLevelLoadingScreen.javaJava · 50 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui.custom;
21
22
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
23
import net.ccbluex.liquidbounce.injection.mixins.minecraft.gui.MixinScreen;
24
import net.minecraft.client.gui.components.Button;
25
import net.minecraft.client.gui.screens.LevelLoadingScreen;
26
import net.minecraft.network.chat.CommonComponents;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
30
@Mixin(LevelLoadingScreen.class)
31
public abstract class MixinLevelLoadingScreen extends MixinScreen {
32
33
    @Override
34
    protected void init(CallbackInfo ci) {
35
        super.init(ci);
36
37
        if (SelfDestruct.INSTANCE.isDestructed()) {
38
            return;
39
        }
40
41
        Button quitButton = Button.builder(CommonComponents.GUI_PROCEED, _ -> this.minecraft.gui.setScreen(null))
42
            .pos(this.width / 2 - 100, this.height / 2 + 50)
43
            .size(200, 20)
44
            .build();
45
46
        addRenderableWidget(quitButton);
47
    }
48
49
}
50
MixinAbstractSelectionListsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/widget/MixinAbstractSelectionList.javaJava · 49 lines · 2.0 KB
@Mixin(AbstractSelectionList.class)
MixinAbstractSelectionList.javaJava · 49 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui.widget;
21
22
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
23
import net.ccbluex.liquidbounce.LiquidBounce;
24
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
25
import net.ccbluex.liquidbounce.integration.theme.ThemeManager;
26
import net.minecraft.client.Minecraft;
27
import net.minecraft.client.gui.GuiGraphicsExtractor;
28
import net.minecraft.client.gui.components.AbstractSelectionList;
29
import org.spongepowered.asm.mixin.Final;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.Shadow;
32
import org.spongepowered.asm.mixin.injection.At;
33
34
@Mixin(AbstractSelectionList.class)
35
public abstract class MixinAbstractSelectionList {
36
37
    @Shadow
38
    @Final
39
    protected Minecraft minecraft;
40
41
    @WrapWithCondition(method = "extractWidgetRenderState",
42
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/AbstractSelectionList;extractListSeparators(Lnet/minecraft/client/gui/GuiGraphicsExtractor;)V"))
43
    private boolean renderBackground(AbstractSelectionList<?> instance, GuiGraphicsExtractor graphics) {
44
        return this.minecraft.level != null || SelfDestruct.INSTANCE.isDestructed()
45
            || LiquidBounce.INSTANCE.isInitialized() && ThemeManager.INSTANCE.isBasicMode();
46
    }
47
48
}
49
MixinEditBoxsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/widget/MixinEditBox.javaJava · 40 lines · 1.6 KB
@Mixin(EditBox.class)
ModifiesEditBox
MixinEditBox.javaJava · 40 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui.widget;
21
22
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleTextFieldProtect;
23
import net.minecraft.client.gui.components.EditBox;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.Shadow;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.ModifyArg;
28
29
@Mixin(EditBox.class)
30
public abstract class MixinEditBox {
31
    @Shadow
32
    private int displayPos;
33
34
    @ModifyArg(method = "extractWidgetRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/EditBox;applyFormat(Ljava/lang/String;I)Lnet/minecraft/util/FormattedCharSequence;"))
35
    private String censorText(String string) {
36
        return ModuleTextFieldProtect.INSTANCE.protect(string, this.displayPos);
37
    }
38
39
}
40
MixinAttackRangesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinAttackRange.javaJava · 49 lines · 2.0 KB
@Mixin(AttackRange.class)
ModifiesAttackRange
MixinAttackRange.javaJava · 49 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.item;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleHitbox;
25
import net.minecraft.client.Minecraft;
26
import net.minecraft.world.entity.LivingEntity;
27
import net.minecraft.world.item.component.AttackRange;
28
import org.jspecify.annotations.NullMarked;
29
import org.objectweb.asm.Opcodes;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.injection.At;
32
33
@NullMarked
34
@Mixin(AttackRange.class)
35
public abstract class MixinAttackRange {
36
37
    @ModifyExpressionValue(
38
        method = "isInRange(Lnet/minecraft/world/entity/LivingEntity;Ljava/util/function/ToDoubleFunction;D)Z",
39
        at = @At(value = "FIELD", target = "Lnet/minecraft/world/item/component/AttackRange;hitboxMargin:F", opcode = Opcodes.GETFIELD)
40
    )
41
    private static float applyHitboxMargin(float original, @Local(argsOnly = true, name = "attacker") LivingEntity entity) {
42
        if (entity == Minecraft.getInstance().player && ModuleHitbox.INSTANCE.getRunning() && ModuleHitbox.INSTANCE.getApplyToComponent()) {
43
            return ModuleHitbox.INSTANCE.getSize() + original;
44
        }
45
        return original;
46
    }
47
48
}
49
MixinItemsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItem.javaJava · 49 lines · 1.9 KB
@Mixin(Item.class)
ModifiesItem
MixinItem.javaJava · 49 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.item;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
23
import net.minecraft.client.Minecraft;
24
import net.minecraft.world.entity.player.Player;
25
import net.minecraft.world.item.Item;
26
import net.minecraft.world.level.ClipContext;
27
import net.minecraft.world.level.Level;
28
import net.minecraft.world.phys.Vec3;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
32
@Mixin(Item.class)
33
public abstract class MixinItem {
34
35
    @ModifyExpressionValue(method = "getPlayerPOVHitResult", at = @At(value = "INVOKE",
36
            target = "Lnet/minecraft/world/entity/player/Player;calculateViewVector(FF)Lnet/minecraft/world/phys/Vec3;"))
37
    private static Vec3 hookFixRotation(Vec3 original, Level world, Player player, ClipContext.Fluid fluidHandling) {
38
        if (player == Minecraft.getInstance().player) {
39
            var rotation = RotationManager.INSTANCE.getCurrentRotation();
40
            if (rotation != null) {
41
                return rotation.directionVector();
42
            }
43
        }
44
45
        return original;
46
    }
47
48
}
49
MixinItemCooldownssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItemCooldowns.javaJava · 56 lines · 1.8 KB
@Mixin(ItemCooldowns.class)
MixinItemCooldowns.javaJava · 56 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.item;
21
22
import net.ccbluex.liquidbounce.interfaces.ItemCooldownsAddition;
23
import net.minecraft.resources.Identifier;
24
import net.minecraft.world.item.ItemCooldowns;
25
import net.minecraft.world.item.ItemStack;
26
import org.jspecify.annotations.Nullable;
27
import org.spongepowered.asm.mixin.Final;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Shadow;
30
31
import java.util.Map;
32
33
@Mixin(ItemCooldowns.class)
34
public abstract class MixinItemCooldowns implements ItemCooldownsAddition {
35
36
    @Shadow
37
    @Final
38
    private Map<Identifier, ItemCooldowns.CooldownInstance> cooldowns;
39
40
    @Shadow
41
    private int tickCount;
42
43
    @Shadow
44
    public abstract Identifier getCooldownGroup(ItemStack stack);
45
46
    @Override
47
    public @Nullable Entry liquidBounce$getCooldown(ItemStack stack) {
48
        var entry = this.cooldowns.get(this.getCooldownGroup(stack));
49
        if (entry != null) {
50
            return new Entry(this.tickCount, entry.startTime(), entry.endTime());
51
        } else {
52
            return null;
53
        }
54
    }
55
}
56
MixinItemInHandRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItemInHandRenderer.javaJava · 281 lines · 13.9 KB
@Mixin(ItemInHandRenderer.class)
ModifiesItemInHandRenderer not in 26.3
MixinItemInHandRenderer.javaJava · 281 lines · 13.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.item;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import com.llamalad7.mixinextras.sugar.Local;
25
import com.mojang.blaze3d.vertex.PoseStack;
26
import com.mojang.math.Axis;
27
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleSwordBlock;
28
import net.ccbluex.liquidbounce.features.module.modules.render.animations.ModuleAnimations;
29
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleSilentHotbar;
30
import net.ccbluex.liquidbounce.features.module.modules.render.animations.SwingAnimations;
31
import net.ccbluex.liquidbounce.utils.client.SilentHotbar;
32
import net.ccbluex.liquidbounce.utils.item.ItemCategorizationsKt;
33
import net.ccbluex.liquidbounce.utils.render.FirstPersonShieldTint;
34
import net.minecraft.client.Minecraft;
35
import net.minecraft.client.player.AbstractClientPlayer;
36
import net.minecraft.client.renderer.ItemInHandRenderer;
37
import net.minecraft.client.renderer.SubmitNodeCollector;
38
import net.minecraft.client.renderer.item.ItemStackRenderState;
39
import net.minecraft.core.component.DataComponents;
40
import net.minecraft.world.InteractionHand;
41
import net.minecraft.world.entity.HumanoidArm;
42
import net.minecraft.world.entity.LivingEntity;
43
import net.minecraft.world.item.ItemDisplayContext;
44
import net.minecraft.world.item.ItemStack;
45
import net.minecraft.world.item.ItemUseAnimation;
46
import net.minecraft.world.item.ShieldItem;
47
import org.spongepowered.asm.mixin.Final;
48
import org.spongepowered.asm.mixin.Mixin;
49
import org.spongepowered.asm.mixin.Shadow;
50
import org.spongepowered.asm.mixin.Unique;
51
import org.spongepowered.asm.mixin.injection.*;
52
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
53
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
54
55
@Mixin(ItemInHandRenderer.class)
56
public abstract class MixinItemInHandRenderer {
57
58
    @Final
59
    @Shadow
60
    private Minecraft minecraft;
61
62
    @Shadow
63
    private ItemStack offHandItem;
64
65
    @Shadow
66
    @Final
67
    private static float ITEM_POS_Y;
68
69
    @WrapOperation(method = "renderItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/item/ItemStackRenderState;submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;III)V"))
70
    private void hookFirstPersonShieldTint(
71
        ItemStackRenderState instance, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords,
72
        int overlayCoords, int outlineColor, Operation<Void> original, LivingEntity mob, ItemStack itemStack,
73
        ItemDisplayContext type
74
    ) {
75
        if (itemStack.getItem() instanceof ShieldItem && type.firstPerson()) {
76
            FirstPersonShieldTint.render(
77
                () -> original.call(instance, poseStack, submitNodeCollector, lightCoords, overlayCoords, outlineColor));
78
            return;
79
        }
80
81
        original.call(instance, poseStack, submitNodeCollector, lightCoords, overlayCoords, outlineColor);
82
    }
83
84
    @Inject(
85
        method = "swingArm",
86
        at = @At("HEAD"),
87
        cancellable = true
88
    )
89
    private void cancelVanillaSwing(
90
        float attack,
91
        PoseStack poseStack,
92
        int invert,
93
        HumanoidArm arm,
94
        CallbackInfo ci
95
    ) {
96
        AbstractClientPlayer player = Minecraft.getInstance().player;
97
98
        if (player == null || !ModuleAnimations.INSTANCE.getRunning() || !SwingAnimations.INSTANCE.getEnabled() || arm != player.getMainArm() || ModuleSwordBlock.shouldAnimateSwordBlock(player)) {
99
            return;
100
        }
101
102
        SwingAnimations.INSTANCE.onRenderItem(
103
            player,
104
            InteractionHand.MAIN_HAND,
105
            attack,
106
            poseStack
107
        );
108
109
        ci.cancel();
110
    }
111
112
    @Inject(method = "submitArmWithItem", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V", shift = At.Shift.AFTER))
113
    private void hookRenderFirstPersonItem(
114
        AbstractClientPlayer player, float frameInterp, float xRot, InteractionHand hand, float attack, ItemStack itemStack, float inverseArmHeight, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, CallbackInfo ci) {
115
        if (ModuleAnimations.INSTANCE.getRunning()) {
116
            var isInBothHands = InteractionHand.MAIN_HAND == hand && itemStack.has(DataComponents.MAP_ID) && offHandItem.isEmpty();
117
            ModuleAnimations.MainHand mainHand = ModuleAnimations.MainHand.INSTANCE;
118
            ModuleAnimations.OffHand offHand = ModuleAnimations.OffHand.INSTANCE;
119
            if (isInBothHands && mainHand.getRunning() && offHand.getRunning()) {
120
                liquid_bounce$applyTransformations(poseStack,
121
                        (mainHand.getMainHandX() + offHand.getOffHandX()) / 2f,
122
                        (mainHand.getMainHandY() + offHand.getOffHandY()) / 2f,
123
                        (mainHand.getMainHandItemScale() + offHand.getOffHandItemScale()) / 2f,
124
                        (mainHand.getMainHandPositiveX() + offHand.getOffHandPositiveX()) / 2f,
125
                        (mainHand.getMainHandPositiveY() + offHand.getOffHandPositiveY()) / 2f,
126
                        (mainHand.getMainHandPositiveZ() + offHand.getOffHandPositiveZ()) / 2f
127
                );
128
            } else if (isInBothHands && mainHand.getRunning()) {
129
                poseStack.translate(0f, 0f, mainHand.getMainHandItemScale());
130
            } else if (InteractionHand.MAIN_HAND == hand && mainHand.getRunning()) {
131
                liquid_bounce$applyTransformations(poseStack, mainHand.getMainHandX(), mainHand.getMainHandY(), mainHand.getMainHandItemScale(), mainHand.getMainHandPositiveX(), mainHand.getMainHandPositiveY(), mainHand.getMainHandPositiveZ());
132
            } else if (offHand.getRunning()) {
133
                liquid_bounce$applyTransformations(poseStack, offHand.getOffHandX(), offHand.getOffHandY(), offHand.getOffHandItemScale(), offHand.getOffHandPositiveX(), offHand.getOffHandPositiveY(), offHand.getOffHandPositiveZ());
134
            }
135
        }
136
    }
137
138
    @Unique
139
    private static void liquid_bounce$applyTransformations(PoseStack matrices, float translateX, float translateY, float translateZ, float rotateX, float rotateY, float rotateZ) {
140
        matrices.translate(translateX, translateY, translateZ);
141
        matrices.mulPose(Axis.XP.rotationDegrees(rotateX));
142
        matrices.mulPose(Axis.YP.rotationDegrees(rotateY));
143
        matrices.mulPose(Axis.ZP.rotationDegrees(rotateZ));
144
    }
145
146
    @Inject(method = "submitArmWithItem",
147
        slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getUseAnimation()Lnet/minecraft/world/item/ItemUseAnimation;")),
148
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;applyItemArmTransform(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/entity/HumanoidArm;F)V", ordinal = 0, shift = At.Shift.AFTER))
149
    private void transformBlockAnimation(
150
        AbstractClientPlayer player, float frameInterp, float xRot, InteractionHand hand, float attack, ItemStack itemStack, float inverseArmHeight, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, CallbackInfo ci) {
151
        if (ItemCategorizationsKt.isSword(itemStack)) {
152
            var arm = hand == InteractionHand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite();
153
154
            if (ModuleAnimations.INSTANCE.getRunning()) {
155
                var activeChoice = ModuleAnimations.INSTANCE.getBlockAnimationChoice().getActiveMode();
156
                activeChoice.transform(poseStack, arm, inverseArmHeight, attack);
157
            } else {
158
                // Default animation
159
                ModuleAnimations.OneSevenAnimation.INSTANCE.transform(poseStack, arm, inverseArmHeight, attack);
160
            }
161
        }
162
    }
163
164
    @Inject(method = "submitArmWithItem", at = @At("HEAD"), cancellable = true)
165
    private void hideShield(AbstractClientPlayer player, float frameInterp, float xRot, InteractionHand hand, float attack, ItemStack itemStack, float inverseArmHeight, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, CallbackInfo ci) {
166
        if (hand == InteractionHand.OFF_HAND && player == Minecraft.getInstance().player &&
167
            ModuleSwordBlock.INSTANCE.shouldHideOffhand(itemStack)) {
168
            ci.cancel();
169
        }
170
    }
171
172
    @ModifyArg(method = "submitArmWithItem", at = @At(
173
            value = "INVOKE",
174
            target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;applyItemArmTransform(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/entity/HumanoidArm;F)V",
175
            ordinal = 3
176
    ), index = 2)
177
    private float injectIgnoreBlocking(float equipProgress) {
178
        if (ModuleAnimations.EquipOffset.INSTANCE.getRunning() && ModuleAnimations.EquipOffset.INSTANCE.getIgnoreBlocking()) {
179
            return 0.0F;
180
        }
181
182
        return equipProgress;
183
    }
184
185
    @ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getMainHandItem()Lnet/minecraft/world/item/ItemStack;"))
186
    private ItemStack injectSilentHotbar(ItemStack original) {
187
        if (ModuleSilentHotbar.INSTANCE.getRunning()) {
188
            // noinspection DataFlowIssue
189
            return minecraft.player.getInventory().getNonEquipmentItems().get(SilentHotbar.INSTANCE.getClientsideSlot());
190
        }
191
192
        return original;
193
    }
194
195
    @ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getItemSwapScale(F)F"))
196
    private float injectSilentHotbarNoCooldown(float original) {
197
        if (ModuleSilentHotbar.INSTANCE.getRunning() && ModuleSilentHotbar.INSTANCE.getNoCooldownProgress() && SilentHotbar.INSTANCE.isSlotModified()) {
198
            return 1f;
199
        }
200
201
        return original;
202
    }
203
204
    @Inject(method = "itemUsed", at = @At("HEAD"), cancellable = true)
205
    private void injectIgnorePlace(InteractionHand hand, CallbackInfo ci) {
206
        if (ModuleAnimations.INSTANCE.getRunning() && ModuleAnimations.EquipOffset.INSTANCE.getIgnorePlace()) {
207
            ci.cancel();
208
        }
209
    }
210
211
    @Inject(method = "shouldInstantlyReplaceVisibleItem", at = @At("RETURN"), cancellable = true)
212
    private void injectIgnoreAmount(ItemStack currentlyVisibleItem, ItemStack expectedItem, CallbackInfoReturnable<Boolean> cir) {
213
        if (ModuleAnimations.INSTANCE.getRunning() && !cir.getReturnValueZ()) {
214
            cir.setReturnValue(!ModuleAnimations.EquipOffset.INSTANCE.getRunning()
215
                    || (currentlyVisibleItem.getCount() == expectedItem.getCount() || ModuleAnimations.EquipOffset.INSTANCE.getIgnoreAmount())
216
                    && ItemStack.isSameItemSameComponents(currentlyVisibleItem, expectedItem)
217
            );
218
        }
219
    }
220
221
    @ModifyArg(method = "applyItemArmTransform", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(FFF)V"), index = 1)
222
    private float injectDisableEquipOffset(float y) {
223
        if (ModuleAnimations.INSTANCE.getRunning() && !ModuleAnimations.EquipOffset.INSTANCE.getRunning()) {
224
            return ITEM_POS_Y;
225
        }
226
        return y;
227
    }
228
229
    @ModifyExpressionValue(method = "submitArmWithItem", at = @At(
230
        value = "INVOKE",
231
        target = "Lnet/minecraft/world/item/ItemStack;getUseAnimation()Lnet/minecraft/world/item/ItemUseAnimation;",
232
        ordinal = 0
233
    ))
234
    private ItemUseAnimation hookUseAction(ItemUseAnimation original, @Local(argsOnly = true, name = "itemStack") ItemStack itemStack, @Local(argsOnly = true, name = "player") AbstractClientPlayer player) {
235
        if (ModuleSwordBlock.shouldAnimateSwordBlock(player, itemStack)) {
236
            return ItemUseAnimation.BLOCK;
237
        }
238
        return original;
239
    }
240
241
    @ModifyExpressionValue(method = "submitArmWithItem", at = @At(
242
        value = "INVOKE",
243
        target = "Lnet/minecraft/client/player/AbstractClientPlayer;isUsingItem()Z",
244
        ordinal = 1
245
    ))
246
    private boolean hookIsUseItem(boolean original, @Local(argsOnly = true, name = "player") AbstractClientPlayer player) {
247
        if (ModuleSwordBlock.shouldAnimateSwordBlock(player)) {
248
            return true;
249
        }
250
251
        return original;
252
    }
253
254
    @ModifyExpressionValue(method = "submitArmWithItem", at = @At(
255
        value = "INVOKE",
256
        target = "Lnet/minecraft/client/player/AbstractClientPlayer;getUsedItemHand()Lnet/minecraft/world/InteractionHand;",
257
        ordinal = 1
258
    ))
259
    private InteractionHand hookActiveHand(InteractionHand original, @Local(argsOnly = true, name = "player") AbstractClientPlayer player) {
260
        if (ModuleSwordBlock.shouldAnimateSwordBlock(player)) {
261
            return InteractionHand.MAIN_HAND;
262
        }
263
264
        return original;
265
    }
266
267
    @ModifyExpressionValue(method = "submitArmWithItem", at = @At(
268
        value = "INVOKE",
269
        target = "Lnet/minecraft/client/player/AbstractClientPlayer;getUseItemRemainingTicks()I",
270
        ordinal = 2
271
    ))
272
    private int hookItemUseItem(int original, @Local(argsOnly = true, name = "player") AbstractClientPlayer player) {
273
        if (ModuleSwordBlock.shouldAnimateSwordBlock(player)) {
274
            return 7200;
275
        }
276
        return original;
277
    }
278
279
280
}
281
MixinItemStacksrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItemStack.javaJava · 54 lines · 2.1 KB
@Mixin(ItemStack.class)
ModifiesItemStack
MixinItemStack.javaJava · 54 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.item;
20
21
import net.ccbluex.liquidbounce.event.EventManager;
22
import net.ccbluex.liquidbounce.event.events.ItemLoreQueryEvent;
23
import net.minecraft.network.chat.Component;
24
import net.minecraft.world.entity.player.Player;
25
import net.minecraft.world.item.Item.TooltipContext;
26
import net.minecraft.world.item.ItemStack;
27
import net.minecraft.world.item.TooltipFlag;
28
import org.jspecify.annotations.Nullable;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
33
34
import java.util.ArrayList;
35
import java.util.List;
36
37
@Mixin(ItemStack.class)
38
public abstract class MixinItemStack {
39
40
    @Inject(method = "getTooltipLines", at = @At("RETURN"), cancellable = true)
41
    void injectLoreQueryEvent(
42
        TooltipContext context, @Nullable Player player, TooltipFlag type, CallbackInfoReturnable<List<Component>> cir) {
43
        List<Component> lore = cir.getReturnValue();
44
        if (!(lore instanceof ArrayList<Component>)) {
45
            return;
46
        }
47
48
        ItemLoreQueryEvent event = new ItemLoreQueryEvent(ItemStack.class.cast(this), (ArrayList<Component>) lore);
49
        EventManager.INSTANCE.callEvent(event);
50
        cir.setReturnValue(event.getLore());
51
    }
52
53
}
54
MixinTridentItemsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinTridentItem.javaJava · 54 lines · 2.1 KB
@Mixin(TridentItem.class)
ModifiesTridentItem
MixinTridentItem.javaJava · 54 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.item;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleTridentBoost;
24
import net.minecraft.world.item.TridentItem;
25
import org.jspecify.annotations.NullMarked;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
import org.spongepowered.asm.mixin.injection.ModifyArgs;
29
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
30
31
@NullMarked
32
@Mixin(TridentItem.class)
33
public abstract class MixinTridentItem {
34
35
    @ModifyExpressionValue(
36
        method = {"use", "releaseUsing"},
37
        at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;isInWaterOrRain()Z")
38
    )
39
    private boolean hookRiptideWaterRequirement(boolean original) {
40
        return original || ModuleTridentBoost.ignoresWaterRequirement();
41
    }
42
43
    @ModifyArgs(
44
        method = "releaseUsing",
45
        at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;push(DDD)V")
46
    )
47
    private void hookRiptideImpulse(Args args) {
48
        args.set(0, ModuleTridentBoost.scaleHorizontal(args.<Double>get(0)));
49
        args.set(1, ModuleTridentBoost.scaleVertical(args.<Double>get(1)));
50
        args.set(2, ModuleTridentBoost.scaleHorizontal(args.<Double>get(2)));
51
    }
52
53
}
54
MixinAddressChecksrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinAddressCheck.javaJava · 60 lines · 2.3 KB
@Mixin(AddressCheck.class)
ModifiesAddressCheck
MixinAddressCheck.javaJava · 60 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import com.google.common.collect.ImmutableList;
23
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
24
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
25
import net.minecraft.client.multiplayer.resolver.AddressCheck;
26
import org.jspecify.annotations.NullMarked;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
30
import java.util.ServiceConfigurationError;
31
import java.util.stream.Collector;
32
import java.util.stream.Stream;
33
34
@NullMarked
35
@Mixin(AddressCheck.class)
36
public interface MixinAddressCheck {
37
38
    /**
39
     * java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.client.multiplayer.resolver.ServerNameResolver
40
     * 	at ~
41
     * Caused by: java.lang.ExceptionInInitializerError: Exception java.util.ServiceConfigurationError: com.mojang.blocklist.BlockListSupplier: com.mojang.patchy.MojangBlockListSupplier not a subtype
42
     */
43
    @WrapOperation(
44
        method = "createFromService",
45
        at = @At(value = "INVOKE", target = "Ljava/util/stream/Stream;collect(Ljava/util/stream/Collector;)Ljava/lang/Object;", remap = false)
46
    )
47
    private static Object preventCannotConnectToAnyServer(
48
        Stream<?> instance,
49
        Collector<?, ?, ?> collector,
50
        Operation<?> operation
51
    ) {
52
        try {
53
            return operation.call(instance, collector);
54
        } catch (NoClassDefFoundError | ServiceConfigurationError | ExceptionInInitializerError error) {
55
            return ImmutableList.of();
56
        }
57
    }
58
59
}
60
MixinClientHandshakePacketListenerImplMixinsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientHandshakePacketListenerImplMixin.javaJava · 76 lines · 3.3 KB
@Mixin(ClientHandshakePacketListenerImpl.class)
MixinClientHandshakePacketListenerImplMixin.javaJava · 76 lines · 3.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
23
import net.ccbluex.liquidbounce.features.spoofer.SpooferClient;
24
import net.ccbluex.liquidbounce.utils.text.PlainText;
25
import net.minecraft.ChatFormatting;
26
import net.minecraft.client.multiplayer.ClientHandshakePacketListenerImpl;
27
import net.minecraft.network.chat.Component;
28
import net.minecraft.network.chat.MutableComponent;
29
import net.minecraft.network.chat.Style;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.injection.At;
32
33
@Mixin(ClientHandshakePacketListenerImpl.class)
34
public abstract class MixinClientHandshakePacketListenerImplMixin {
35
36
    @ModifyExpressionValue(method = "handleLoginFinished", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/ClientBrandRetriever;getClientModName()Ljava/lang/String;", remap = false))
37
    private String getClientModName(String original) {
38
        return SpooferClient.INSTANCE.clientBrand(original);
39
    }
40
41
    /**
42
     * For some reason a lot of people do not know the Minecraft basics.
43
     * How do people not know that you need a Minecraft premium account to join a premium server?
44
     */
45
    @ModifyExpressionValue(method = "authenticateServer", at = @At(value = "INVOKE",
46
            target = "Lnet/minecraft/network/chat/Component;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/network/chat/MutableComponent;", ordinal = 1))
47
    private MutableComponent modifySessionReason(MutableComponent original) {
48
        if (SelfDestruct.INSTANCE.isDestructed()) {
49
            return original;
50
        }
51
52
        var notOfflineMode = PlainText.of(
53
            "Not offline mode",
54
            Style.EMPTY.withColor(ChatFormatting.RED).withUnderlined(true)
55
        );
56
        var requiresValidText = PlainText.of(
57
            "This server requires a valid session. Possible solutions:",
58
            ChatFormatting.RED
59
        );
60
        var loginText = PlainText.of("Login into a Minecraft premium account and try again.");
61
        var retryText = PlainText.of("If you've already signed into a premium account,\n" +
62
                "reload the game or re-sign into the account.");
63
64
        return Component.empty()
65
                .append(notOfflineMode)
66
                .append(PlainText.NEW_LINE)
67
                .append(PlainText.NEW_LINE)
68
                .append(requiresValidText)
69
                .append(PlainText.NEW_LINE)
70
                .append(loginText)
71
                .append(PlainText.NEW_LINE)
72
                .append(retryText);
73
    }
74
75
}
76
MixinClientIntentionPacketsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientIntentionPacket.javaJava · 42 lines · 1.7 KB
@Mixin(ClientIntentionPacket.class)
MixinClientIntentionPacket.javaJava · 42 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import net.ccbluex.liquidbounce.features.spoofer.SpooferBungeeCord;
24
import net.minecraft.network.protocol.handshake.ClientIntentionPacket;
25
import org.objectweb.asm.Opcodes;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
29
@Mixin(ClientIntentionPacket.class)
30
public abstract class MixinClientIntentionPacket {
31
32
    @ModifyExpressionValue(method = "write", at = @At(value = "FIELD", target = "Lnet/minecraft/network/protocol/handshake/ClientIntentionPacket;hostName:Ljava/lang/String;", opcode = Opcodes.GETFIELD))
33
    private String modifyAddress(String original) {
34
        if (SpooferBungeeCord.INSTANCE.getRunning()) {
35
            return SpooferBungeeCord.INSTANCE.modifyHandshakeAddress(original);
36
        }
37
38
        return original;
39
    }
40
41
}
42
MixinClientPacketListenersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientPacketListener.javaJava · 281 lines · 13.3 KB
@Mixin(ClientPacketListener.class)
MixinClientPacketListener.javaJava · 281 lines · 13.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
23
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
24
import com.llamalad7.mixinextras.sugar.Cancellable;
25
import com.llamalad7.mixinextras.sugar.Local;
26
import net.ccbluex.liquidbounce.common.ChunkUpdateFlag;
27
import net.ccbluex.liquidbounce.event.EventManager;
28
import net.ccbluex.liquidbounce.event.events.*;
29
import net.ccbluex.liquidbounce.features.module.modules.combat.crystalaura.trigger.triggers.*;
30
import net.ccbluex.liquidbounce.features.module.modules.exploit.disabler.disablers.DisablerSpigotSpam;
31
import net.ccbluex.liquidbounce.features.module.modules.misc.betterchat.ModuleBetterChat;
32
import net.ccbluex.liquidbounce.features.module.modules.player.Limit;
33
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleAntiExploit;
34
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleNoRotateSet;
35
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
36
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation;
37
import net.ccbluex.liquidbounce.utils.kotlin.Priority;
38
import net.minecraft.client.Minecraft;
39
import net.minecraft.client.gui.screens.LevelLoadingScreen;
40
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
41
import net.minecraft.client.multiplayer.ClientPacketListener;
42
import net.minecraft.client.multiplayer.CommonListenerCookie;
43
import net.minecraft.client.player.LocalPlayer;
44
import net.minecraft.network.Connection;
45
import net.minecraft.network.chat.Component;
46
import net.minecraft.network.protocol.PacketUtils;
47
import net.minecraft.network.protocol.game.*;
48
import net.minecraft.util.Mth;
49
import net.minecraft.world.entity.player.Player;
50
import net.minecraft.world.phys.Vec3;
51
import org.jspecify.annotations.Nullable;
52
import org.spongepowered.asm.mixin.Mixin;
53
import org.spongepowered.asm.mixin.Unique;
54
import org.spongepowered.asm.mixin.injection.At;
55
import org.spongepowered.asm.mixin.injection.Inject;
56
import org.spongepowered.asm.mixin.injection.ModifyArgs;
57
import org.spongepowered.asm.mixin.injection.ModifyVariable;
58
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
59
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
60
61
import java.util.Optional;
62
63
@Mixin(ClientPacketListener.class)
64
public abstract class MixinClientPacketListener extends ClientCommonPacketListenerImpl {
65
66
    protected MixinClientPacketListener(Minecraft client, Connection connection, CommonListenerCookie connectionState) {
67
        super(client, connection, connectionState);
68
    }
69
70
    @Inject(method = "handleLevelChunkWithLight", at = @At("RETURN"))
71
    private void injectChunkLoadEvent(ClientboundLevelChunkWithLightPacket packet, CallbackInfo ci) {
72
        EventManager.INSTANCE.callEvent(new ChunkLoadEvent(packet.getX(), packet.getZ()));
73
    }
74
75
    @Inject(method = "handleForgetLevelChunk", at = @At("RETURN"))
76
    private void injectUnloadEvent(ClientboundForgetLevelChunkPacket packet, CallbackInfo ci) {
77
        EventManager.INSTANCE.callEvent(new ChunkUnloadEvent(packet.pos()));
78
    }
79
80
    @WrapMethod(method = "handleChunkBlocksUpdate")
81
    private void onChunkDeltaUpdateStart(ClientboundSectionBlocksUpdatePacket packet, Operation<Void> original) {
82
        ChunkUpdateFlag.withChunkDeltaUpdating(() -> {
83
            original.call(packet);
84
            EventManager.INSTANCE.callEvent(new ChunkDeltaUpdateEvent(packet));
85
        });
86
    }
87
88
    @Inject(method = "handleTeleportEntity", at = @At("RETURN"))
89
    private void hookOnEntityPosition(ClientboundTeleportEntityPacket packet, CallbackInfo ci) {
90
        EntityMoveTrigger.INSTANCE.notify(packet);
91
    }
92
93
    @Inject(method = "handleBlockUpdate", at = @At("RETURN"))
94
    private void hookOnBlockUpdate(ClientboundBlockUpdatePacket packet, CallbackInfo ci) {
95
        BlockChangeTrigger.INSTANCE.notify(packet);
96
    }
97
98
    @Inject(method = "handleChunkBlocksUpdate", at = @At("RETURN"))
99
    private void hookOnChunkDeltaUpdate(ClientboundSectionBlocksUpdatePacket packet, CallbackInfo ci) {
100
        BlockChangeTrigger.INSTANCE.postChunkUpdateHandler(packet);
101
    }
102
103
    @Inject(method = "handleAddEntity", at = @At("RETURN"))
104
    private void hookOnEntitySpawn(ClientboundAddEntityPacket packet, CallbackInfo ci) {
105
        CrystalSpawnTrigger.INSTANCE.notify(packet);
106
    }
107
108
    @Inject(method = "handleSoundEntityEvent", at = @At("RETURN"))
109
    private void hookOnPlaySoundFromEntity(ClientboundSoundEntityPacket packet, CallbackInfo ci) {
110
        ExplodeSoundTrigger.INSTANCE.notify(packet);
111
    }
112
113
    @Inject(method = "handleRemoveEntities", at = @At("RETURN"))
114
    private void hookOnEntitiesDestroy(ClientboundRemoveEntitiesPacket packet, CallbackInfo ci) {
115
        CrystalDestroyTrigger.INSTANCE.notify(packet);
116
    }
117
118
    @ModifyExpressionValue(method = "setTitleText", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundSetTitleTextPacket;text()Lnet/minecraft/network/chat/Component;"))
119
    private @Nullable Component hookOnTitle(@Nullable Component original, @Cancellable CallbackInfo ci) {
120
        var event = new TitleEvent.Title(original);
121
        EventManager.INSTANCE.callEvent(event);
122
        if (event.isCancelled()) {
123
            ci.cancel();
124
        }
125
        return event.getText();
126
    }
127
128
    @ModifyExpressionValue(method = "setSubtitleText", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket;text()Lnet/minecraft/network/chat/Component;"))
129
    private @Nullable Component hookOnSubtitle(@Nullable Component original, @Cancellable CallbackInfo ci) {
130
        var event = new TitleEvent.Subtitle(original);
131
        EventManager.INSTANCE.callEvent(event);
132
        if (event.isCancelled()) {
133
            ci.cancel();
134
        }
135
        return event.getText();
136
    }
137
138
    @ModifyArgs(method = "setTitlesAnimation", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Hud;setTimes(III)V"))
139
    private void hookOnTitleFade(Args args, @Cancellable CallbackInfo ci) {
140
        var event = new TitleEvent.Fade(args.get(0), args.get(1), args.get(2));
141
        EventManager.INSTANCE.callEvent(event);
142
        if (event.isCancelled()) {
143
            ci.cancel();
144
        }
145
        args.set(0, event.getFadeInTicks());
146
        args.set(1, event.getStayTicks());
147
        args.set(2, event.getFadeOutTicks());
148
    }
149
150
    /**
151
     * This injection rewrites the method!!!
152
     */
153
    @Inject(method = "handleTitlesClear", at = @At(value = "HEAD"), cancellable = true)
154
    private void hookOnTitleClear(ClientboundClearTitlesPacket packet, CallbackInfo ci) {
155
        PacketUtils.ensureRunningOnSameThread(packet, (ClientGamePacketListener) this, this.minecraft.packetProcessor());
156
        var event = new TitleEvent.Clear(packet.shouldResetTimes());
157
        EventManager.INSTANCE.callEvent(event);
158
        if (event.isCancelled()) {
159
            ci.cancel();
160
            return;
161
        }
162
        this.minecraft.gui.hud.clearTitles();
163
        if (event.getReset()) {
164
            this.minecraft.gui.hud.resetTitleTimes();
165
        }
166
        ci.cancel();
167
    }
168
169
    @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
170
    @ModifyExpressionValue(method = "handleExplosion", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundExplodePacket;playerKnockback()Ljava/util/Optional;"))
171
    private Optional<Vec3> onExplosionVelocity(Optional<Vec3> original) {
172
        var present = original.isPresent();
173
        if (present && ModuleAntiExploit.canLimit(Limit.EXPLOSION_STRENGTH)) {
174
            var vec = original.get();
175
            double fixedX = Mth.clamp(vec.x, -10.0, 10.0);
176
            double fixedY = Mth.clamp(vec.y, -10.0, 10.0);
177
            double fixedZ = Mth.clamp(vec.z, -10.0, 10.0);
178
179
            if (fixedX != vec.x || fixedY != vec.y || fixedZ != vec.z) {
180
                ModuleAntiExploit.INSTANCE.notify(Limit.EXPLOSION_STRENGTH, "Limited too strong explosion", true);
181
                return Optional.of(new Vec3(fixedX, fixedY, fixedZ));
182
            }
183
        }
184
185
        return original;
186
    }
187
188
    @ModifyExpressionValue(method = "handleParticleEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundLevelParticlesPacket;getCount()I", ordinal = 1))
189
    private int onParticleAmount(int original) {
190
        if (ModuleAntiExploit.canLimit(Limit.PARTICLES_AMOUNT) && 500 <= original) {
191
            ModuleAntiExploit.INSTANCE.notify(Limit.PARTICLES_AMOUNT, "Limited too many particles", true);
192
            return 100;
193
        }
194
        return original;
195
    }
196
197
    @ModifyExpressionValue(method = "handleParticleEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundLevelParticlesPacket;getMaxSpeed()F"))
198
    private float onParticleSpeed(float original) {
199
        if (ModuleAntiExploit.canLimit(Limit.PARTICLES_SPEED) && 10.0f <= original) {
200
            ModuleAntiExploit.INSTANCE.notify(Limit.PARTICLES_SPEED, "Limited too fast particles speed", true);
201
            return 10.0f;
202
        }
203
        return original;
204
    }
205
206
    @ModifyExpressionValue(method = "handleGameEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundGameEventPacket;getEvent()Lnet/minecraft/network/protocol/game/ClientboundGameEventPacket$Type;"))
207
    private ClientboundGameEventPacket.Type onGameStateChange(ClientboundGameEventPacket.Type original) {
208
        if (ModuleAntiExploit.INSTANCE.getRunning() && original == ClientboundGameEventPacket.DEMO_EVENT && ModuleAntiExploit.INSTANCE.getCancelDemo()) {
209
            ModuleAntiExploit.INSTANCE.notify(null, "Cancelled demo GUI (just annoying thing)", false);
210
            return null;
211
        }
212
213
        return original;
214
    }
215
216
    @Inject(method = "handleSetHealth", at = @At("HEAD"))
217
    private void injectHealthUpdate(ClientboundSetHealthPacket packet, CallbackInfo ci) {
218
        LocalPlayer player = this.minecraft.player;
219
220
        if (player == null) {
221
            return;
222
        }
223
224
        EventManager.INSTANCE.callEvent(new HealthUpdateEvent(packet.getHealth(), packet.getFood(), packet.getSaturation(), player.getHealth()));
225
226
        if (packet.getHealth() == 0) {
227
            EventManager.INSTANCE.callEvent(DeathEvent.INSTANCE);
228
        }
229
    }
230
231
    @Unique
232
    private final ThreadLocal<Rotation> rotationThreadLocal = ThreadLocal.withInitial(() -> null);
233
234
    @Inject(method = "handleMovePlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientPacketListener;setValuesFromPositionPacket(Lnet/minecraft/world/entity/PositionMoveRotation;Ljava/util/Set;Lnet/minecraft/world/entity/Entity;Z)Z"))
235
    private void injectPlayerPositionLook(
236
        ClientboundPlayerPositionPacket packet, CallbackInfo ci, @Local(name = "player") Player player) {
237
        rotationThreadLocal.set(new Rotation(player.getYRot(), player.getXRot(), true));
238
    }
239
240
    @Inject(method = "handleMovePlayer", at = @At("RETURN"))
241
    private void injectNoRotateSet(ClientboundPlayerPositionPacket packet, CallbackInfo ci, @Local(name = "player") Player player) {
242
        if (!ModuleNoRotateSet.INSTANCE.getRunning() || Minecraft.getInstance().gui.screen() instanceof LevelLoadingScreen) {
243
            return;
244
        }
245
246
        var prevRotation = this.rotationThreadLocal.get();
247
        if (prevRotation == null) {
248
            return;
249
        }
250
        this.rotationThreadLocal.remove();
251
252
        if (ModuleNoRotateSet.INSTANCE.getMode().getActiveMode() == ModuleNoRotateSet.ResetRotation.INSTANCE) {
253
            // Changes your server side rotation and then resets it with provided settings
254
            var rotationTarget = ModuleNoRotateSet.ResetRotation.INSTANCE.getRotations().toRotationTarget(
255
                    new Rotation(player.getYRot(), player.getXRot(), true),
256
                    null,
257
                    true,
258
                    null
259
            );
260
            RotationManager.INSTANCE.setRotationTarget(rotationTarget, Priority.NOT_IMPORTANT, ModuleNoRotateSet.INSTANCE);
261
        }
262
263
        // Increase yaw and pitch by a value so small that the difference cannot be seen,
264
        // just to update the rotation server-side.
265
        player.setYRot(prevRotation.yRot() + 0.000001f);
266
        player.setXRot(prevRotation.xRot() + 0.000001f);
267
    }
268
269
    @ModifyVariable(method = "sendChat", at = @At("HEAD"), argsOnly = true, name = "content")
270
    private String handleSendMessage(String content) {
271
        var result = ModuleBetterChat.INSTANCE.modifyMessage(content);
272
273
        if (DisablerSpigotSpam.INSTANCE.getRunning()) {
274
            return DisablerSpigotSpam.INSTANCE.getMessage() + " " + result;
275
        }
276
277
        return result;
278
    }
279
280
}
281
MixinClientboundRemoveEntitiesPacketsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientboundRemoveEntitiesPacket.javaJava · 45 lines · 1.6 KB
@Mixin(ClientboundRemoveEntitiesPacket.class)
MixinClientboundRemoveEntitiesPacket.javaJava · 45 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
20
21
import net.ccbluex.liquidbounce.interfaces.ClientboundRemoveEntitiesPacketAddition;
22
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.Unique;
25
26
@Mixin(ClientboundRemoveEntitiesPacket.class)
27
public abstract class MixinClientboundRemoveEntitiesPacket implements ClientboundRemoveEntitiesPacketAddition {
28
29
    @Unique
30
    private boolean liquid_bounce$containsCrystal;
31
32
    @Unique
33
    @Override
34
    public void liquid_bounce$setContainsCrystal() {
35
        this.liquid_bounce$containsCrystal = true;
36
    }
37
38
    @Unique
39
    @Override
40
    public boolean liquid_bounce$containsCrystal() {
41
        return this.liquid_bounce$containsCrystal;
42
    }
43
44
}
45
MixinConnectionsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinConnection.javaJava · 105 lines · 4.1 KB
@Mixin(Connection.class)
ModifiesConnection
MixinConnection.javaJava · 105 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
20
21
import io.netty.channel.ChannelPipeline;
22
import net.ccbluex.liquidbounce.event.EventManager;
23
import net.ccbluex.liquidbounce.event.events.PacketEvent;
24
import net.ccbluex.liquidbounce.event.events.PipelineEvent;
25
import net.ccbluex.liquidbounce.event.events.TransferOrigin;
26
import net.minecraft.network.BandwidthDebugMonitor;
27
import net.minecraft.network.Connection;
28
import net.minecraft.network.PacketListener;
29
import net.minecraft.network.protocol.Packet;
30
import net.minecraft.network.protocol.PacketFlow;
31
import net.minecraft.network.protocol.game.ClientboundBundlePacket;
32
import net.minecraft.server.RunningOnDifferentThreadException;
33
import org.spongepowered.asm.mixin.Mixin;
34
import org.spongepowered.asm.mixin.Shadow;
35
import org.spongepowered.asm.mixin.injection.At;
36
import org.spongepowered.asm.mixin.injection.Inject;
37
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
38
39
@Mixin(Connection.class)
40
public abstract class MixinConnection {
41
42
    @Shadow
43
    private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) {
44
    }
45
46
    /**
47
     * Handle sending packets
48
     *
49
     * @param packet       packet to send
50
     * @param callbackInfo callback
51
     */
52
    @Inject(method = "send(Lnet/minecraft/network/protocol/Packet;)V", at = @At("HEAD"), cancellable = true)
53
    private void hookSendingPacket(Packet<?> packet, final CallbackInfo callbackInfo) {
54
        final PacketEvent event = new PacketEvent(TransferOrigin.OUTGOING, packet, true);
55
56
        EventManager.INSTANCE.callEvent(event);
57
58
        if (event.isCancelled()) {
59
            callbackInfo.cancel();
60
        }
61
    }
62
63
    /**
64
     * Handle receiving packets
65
     */
66
    @Inject(method = "genericsFtw", at = @At("HEAD"), cancellable = true, require = 1)
67
    private static void hookReceivingPacket(Packet<?> packet, PacketListener listener, CallbackInfo ci) {
68
        if (packet instanceof ClientboundBundlePacket bundleS2CPacket) {
69
            // Cancel handling bundle packets since we take this in our own hands
70
            ci.cancel();
71
72
            // Handle each packet individually
73
            for (Packet<?> packetInBundle : bundleS2CPacket.subPackets()) {
74
                try {
75
                    // This will call this method again, but with a single packet instead of a bundle
76
                    genericsFtw(packetInBundle, listener);
77
                } catch (RunningOnDifferentThreadException ignored) {
78
                }
79
                // usually we also handle RejectedExecutionException and
80
                // ClassCastException, but both of them will disconnect the player
81
                // and therefore are handled by the upper layer
82
            }
83
            return;
84
        }
85
86
        final PacketEvent event = new PacketEvent(TransferOrigin.INCOMING, packet, true);
87
        EventManager.INSTANCE.callEvent(event);
88
        if (event.isCancelled()) {
89
            ci.cancel();
90
        }
91
    }
92
93
    /**
94
     * Hook proxy
95
     */
96
    @Inject(method = "configureSerialization", at = @At("HEAD"))
97
    private static void hookProxy(ChannelPipeline pipeline, PacketFlow side, boolean local, BandwidthDebugMonitor packetSizeLogger, CallbackInfo ci) {
98
        if (side == PacketFlow.CLIENTBOUND) {
99
            final PipelineEvent event = new PipelineEvent(pipeline, local);
100
            EventManager.INSTANCE.callEvent(event);
101
        }
102
    }
103
104
}
105
MixinFriendlyByteBufsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinFriendlyByteBuf.javaJava · 47 lines · 1.6 KB
@Mixin(FriendlyByteBuf.class)
MixinFriendlyByteBuf.javaJava · 47 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import net.minecraft.network.FriendlyByteBuf;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.Shadow;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.Inject;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
28
29
@Mixin(FriendlyByteBuf.class)
30
public abstract class MixinFriendlyByteBuf {
31
32
    @Shadow
33
    public abstract FriendlyByteBuf writeVarInt(int value);
34
35
    @Inject(
36
            method = "writeEnum",
37
            at = @At("HEAD"),
38
            cancellable = true
39
    )
40
    public void writeEnumConstant(Enum<?> instance, CallbackInfoReturnable<FriendlyByteBuf> cir) {
41
        if (instance == null) {
42
            cir.setReturnValue(this.writeVarInt(-1));
43
        }
44
    }
45
46
}
47
MixinMultiPlayerGameModesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinMultiPlayerGameMode.javaJava · 124 lines · 6.1 KB
@Mixin(MultiPlayerGameMode.class)
MixinMultiPlayerGameMode.javaJava · 124 lines · 6.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import net.ccbluex.liquidbounce.event.EventManager;
23
import net.ccbluex.liquidbounce.event.events.*;
24
import net.ccbluex.liquidbounce.features.module.modules.combat.aimbot.ModuleAutoBow;
25
import net.ccbluex.liquidbounce.features.module.modules.combat.crystalaura.trigger.triggers.ClientBlockBreakTrigger;
26
import net.ccbluex.liquidbounce.utils.client.SilentHotbar;
27
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
28
import net.minecraft.core.BlockPos;
29
import net.minecraft.core.Direction;
30
import net.minecraft.world.InteractionHand;
31
import net.minecraft.world.InteractionResult;
32
import net.minecraft.world.entity.Entity;
33
import net.minecraft.world.entity.player.Player;
34
import net.minecraft.world.inventory.ContainerInput;
35
import net.minecraft.world.level.GameType;
36
import org.spongepowered.asm.mixin.Mixin;
37
import org.spongepowered.asm.mixin.injection.At;
38
import org.spongepowered.asm.mixin.injection.Inject;
39
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
40
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
41
42
@Mixin(MultiPlayerGameMode.class)
43
public abstract class MixinMultiPlayerGameMode {
44
45
    /**
46
     * Hook attacking entity
47
     */
48
    @Inject(method = "attack", at = @At("HEAD"), cancellable = true)
49
    private void hookAttack(Player player, Entity target, CallbackInfo callbackInfo) {
50
        var event = EventManager.INSTANCE.callEvent(new AttackEntityEvent(target));
51
        if (event.isCancelled()) callbackInfo.cancel();
52
    }
53
54
    /**
55
     * Hook into updateBlockBreakingProgress method at HEAD and call BlockBreakingProgress event.
56
     */
57
    @Inject(method = "continueDestroyBlock", at = @At(value = "HEAD"))
58
    private void hookBlockBreakingProgress(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
59
        EventManager.INSTANCE.callEvent(new BlockBreakingProgressEvent(pos));
60
    }
61
62
    /**
63
     * Hook into cancel block breaking at HEAD and call cancel block breaking event, which is able to cancel the execution.
64
     */
65
    @Inject(method = "stopDestroyBlock", at = @At("HEAD"), cancellable = true)
66
    private void hookCancelBlockBreaking(CallbackInfo ci) {
67
        final var event = EventManager.INSTANCE.callEvent(new CancelBlockBreakingEvent());
68
        if (event.isCancelled()) ci.cancel();
69
    }
70
71
    @Inject(method = "startDestroyBlock", at = @At("HEAD"), cancellable = true)
72
    private void hookAttackBlock(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
73
        final var event =  EventManager.INSTANCE.callEvent(new BlockAttackEvent(pos));
74
        if (event.isCancelled()) cir.setReturnValue(false);
75
    }
76
77
    /**
78
     * @author superblaubeere27
79
     */
80
    @ModifyExpressionValue(method = "ensureHasSentCarriedItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;getSelectedSlot()I"))
81
    private int hookCustomSelectedSlot(int original) {
82
        return SilentHotbar.INSTANCE.getServersideSlot();
83
    }
84
85
    @Inject(method = "useItem", at = @At("RETURN"))
86
    private void hookItemInteractAtReturn(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
87
        final PlayerInteractedItemEvent cancelEvent = new PlayerInteractedItemEvent(player, hand, cir.getReturnValue());
88
        EventManager.INSTANCE.callEvent(cancelEvent);
89
    }
90
91
    @Inject(method = "useItem", at = @At("HEAD"), cancellable = true)
92
    private void hookItemInteractAtHead(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
93
        final var event = EventManager.INSTANCE.callEvent(new PlayerInteractItemEvent(player, hand));
94
        if (event.isCancelled()) cir.setReturnValue(InteractionResult.PASS);
95
    }
96
97
    @Inject(method = "releaseUsingItem", at = @At("HEAD"))
98
    private void stopUsingItem(Player player, CallbackInfo callbackInfo) {
99
        ModuleAutoBow.onStopUsingItem();
100
    }
101
102
    @Inject(method = "setLocalMode(Lnet/minecraft/world/level/GameType;)V", at = @At("RETURN"))
103
    private void setGameMode(GameType mode, CallbackInfo callbackInfo) {
104
        EventManager.INSTANCE.callEvent(new GameModeChangeEvent(mode));
105
    }
106
107
    @Inject(method = "setLocalMode(Lnet/minecraft/world/level/GameType;Lnet/minecraft/world/level/GameType;)V", at = @At("RETURN"))
108
    private void setGameModes(GameType mode, GameType previousMode, CallbackInfo callbackInfo) {
109
        EventManager.INSTANCE.callEvent(new GameModeChangeEvent(mode));
110
    }
111
112
    @Inject(method = "destroyBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;destroy(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V", shift = At.Shift.AFTER))
113
    private void hookBreakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
114
        ClientBlockBreakTrigger.INSTANCE.clientBreakHandler();
115
    }
116
117
    @Inject(method = "handleContainerInput", at = @At("HEAD"), cancellable = true)
118
    private void hookContainerInput(int containerId, int slotNum, int buttonNum, ContainerInput containerInput, Player player, CallbackInfo ci) {
119
        final var event = EventManager.INSTANCE.callEvent(new PlayerContainerInputEvent(containerId, slotNum, buttonNum, containerInput));
120
        if (event.isCancelled()) ci.cancel();
121
    }
122
123
}
124
MixinMultiPlayerGameModeAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinMultiPlayerGameModeAccessor.javaJava · 33 lines · 1.2 KB
@Mixin(MultiPlayerGameMode.class)
MixinMultiPlayerGameModeAccessor.javaJava · 33 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
23
import net.minecraft.core.BlockPos;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.gen.Accessor;
26
27
@Mixin(MultiPlayerGameMode.class)
28
public interface MixinMultiPlayerGameModeAccessor {
29
30
    @Accessor("destroyBlockPos")
31
    BlockPos liquid_bounce$getDestroyBlockPos();
32
}
33
MixinMultiplayerServerListPingersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinMultiplayerServerListPinger.javaJava · 42 lines · 1.7 KB
@Mixin(targets = "net.minecraft.client.multiplayer.ServerStatusPinger$1")
MixinMultiplayerServerListPinger.javaJava · 42 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import com.llamalad7.mixinextras.injector.ModifyReceiver;
23
import net.ccbluex.liquidbounce.event.EventManager;
24
import net.ccbluex.liquidbounce.event.events.ServerPingedEvent;
25
import net.minecraft.client.multiplayer.ServerData;
26
import org.objectweb.asm.Opcodes;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
30
@Mixin(targets = "net.minecraft.client.multiplayer.ServerStatusPinger$1")
31
public abstract class MixinMultiplayerServerListPinger {
32
33
    @ModifyReceiver(method = "handlePongResponse",
34
            at = @At(value = "FIELD", target = "Lnet/minecraft/client/multiplayer/ServerData;ping:J", opcode = Opcodes.PUTFIELD))
35
    private ServerData onPingResult$onPingResult(ServerData instance, long value) {
36
        instance.ping = value;
37
        EventManager.INSTANCE.callEvent(new ServerPingedEvent(instance));
38
        return instance;
39
    }
40
41
}
42
MixinPacketTypesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinPacketType.javaJava · 44 lines · 1.8 KB
@Mixin(PacketType.class)
ModifiesPacketType
MixinPacketType.javaJava · 44 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
20
21
import net.ccbluex.liquidbounce.utils.network.PacketRegistryKt;
22
import net.minecraft.network.protocol.PacketFlow;
23
import net.minecraft.network.protocol.PacketType;
24
import net.minecraft.resources.Identifier;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
30
@Mixin(PacketType.class)
31
public abstract class MixinPacketType {
32
33
    /**
34
     * Registers a packet type for the given [networkSide] with the specified [id].
35
     *
36
     * @param networkSide The side of the network.
37
     * @param identifier The identifier of the packet type to register defined in {@link PacketType}
38
     */
39
    @Inject(method = "<init>", at = @At("RETURN"))
40
    private void hookPacketRegistry(PacketFlow networkSide, Identifier identifier, CallbackInfo ci) {
41
        PacketRegistryKt.getPacketRegistry().get(networkSide).add(identifier);
42
    }
43
}
44
MixinPlayerInfosrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinPlayerInfo.javaJava · 96 lines · 3.6 KB
@Mixin(PlayerInfo.class)
ModifiesPlayerInfo
MixinPlayerInfo.javaJava · 96 lines · 3.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
24
import com.mojang.authlib.GameProfile;
25
import net.ccbluex.liquidbounce.features.cosmetic.CapeCosmeticsManager;
26
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
27
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleSkinChanger;
28
import net.minecraft.client.Minecraft;
29
import net.minecraft.client.multiplayer.PlayerInfo;
30
import net.minecraft.core.ClientAsset;
31
import net.minecraft.resources.Identifier;
32
import net.minecraft.world.entity.player.PlayerSkin;
33
import org.spongepowered.asm.mixin.Final;
34
import org.spongepowered.asm.mixin.Mixin;
35
import org.spongepowered.asm.mixin.Shadow;
36
import org.spongepowered.asm.mixin.Unique;
37
import org.spongepowered.asm.mixin.injection.At;
38
39
@Mixin(PlayerInfo.class)
40
public abstract class MixinPlayerInfo {
41
42
    @Shadow
43
    @Final
44
    private GameProfile profile;
45
46
    @Unique
47
    private boolean capeTextureLoading = false;
48
    @Unique
49
    private Identifier capeTexture = null;
50
51
    @ModifyReturnValue(method = "getSkin", at = @At("RETURN"))
52
    @SuppressWarnings({"ConstantConditions", "EqualsBetweenInconvertibleTypes", "RedundantCast"})
53
    private PlayerSkin liquid_bounce$skin(PlayerSkin original) {
54
        if (SelfDestruct.INSTANCE.isDestructed()) {
55
            return original;
56
        }
57
58
        if (ModuleSkinChanger.INSTANCE.getRunning()) {
59
            var player = Minecraft.getInstance().player;
60
            if (player != null) {
61
                var playerListEntry = player.getPlayerInfo();
62
                if (playerListEntry != null && playerListEntry.equals((PlayerInfo) (Object) this)) {
63
                    var customSkinTextures = ModuleSkinChanger.INSTANCE.getSkinTextures();
64
                    if (customSkinTextures != null) {
65
                        original = customSkinTextures.get();
66
                    }
67
                }
68
            }
69
        }
70
71
        if (capeTexture != null) {
72
            return new PlayerSkin(original.body(), new ClientAsset.ResourceTexture(capeTexture, capeTexture),
73
                    original.elytra(), original.model(), original.secure());
74
        }
75
76
        liquid_bounce$fetchCapeTexture();
77
        return original;
78
    }
79
80
    @ModifyExpressionValue(method = "createSkinLookup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isLocalPlayer(Ljava/util/UUID;)Z"))
81
    private static boolean liquid_bounce$allow_custom_skin(boolean b) {
82
        return b || ModuleSkinChanger.INSTANCE.getRunning();
83
    }
84
85
    @Unique
86
    private void liquid_bounce$fetchCapeTexture() {
87
        if (capeTextureLoading) {
88
            return;
89
        }
90
91
        capeTextureLoading = true;
92
        CapeCosmeticsManager.INSTANCE.loadPlayerCape(this.profile, id -> capeTexture = id);
93
    }
94
95
}
96
MixinServerNameResolversrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinServerNameResolver.javaJava · 66 lines · 2.7 KB
@Mixin(ServerNameResolver.class)
MixinServerNameResolver.javaJava · 66 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import net.minecraft.client.multiplayer.resolver.AddressCheck;
25
import net.minecraft.client.multiplayer.resolver.ResolvedServerAddress;
26
import net.minecraft.client.multiplayer.resolver.ServerAddress;
27
import net.minecraft.client.multiplayer.resolver.ServerNameResolver;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.injection.At;
30
31
import java.util.Optional;
32
import java.util.function.Predicate;
33
34
/**
35
 * Patches out Mojang's server blacklist
36
 *
37
 * @see AddressCheck
38
 */
39
@Mixin(ServerNameResolver.class)
40
public abstract class MixinServerNameResolver {
41
42
    @WrapOperation(
43
        method = "resolveAddress",
44
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/resolver/AddressCheck;isAllowed(Lnet/minecraft/client/multiplayer/resolver/ServerAddress;)Z")
45
    )
46
    private boolean isAllowedA(AddressCheck instance, ServerAddress serverAddress, Operation<Boolean> original) {
47
        return true;
48
    }
49
50
    @WrapOperation(
51
        method = "resolveAddress",
52
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/resolver/AddressCheck;isAllowed(Lnet/minecraft/client/multiplayer/resolver/ResolvedServerAddress;)Z")
53
    )
54
    private boolean isAllowedB(AddressCheck instance, ResolvedServerAddress resolvedServerAddress, Operation<Boolean> original) {
55
        return true;
56
    }
57
58
    @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
59
    @WrapOperation(method = "resolveAddress", at = @At(value = "INVOKE",
60
        target = "Ljava/util/Optional;filter(Ljava/util/function/Predicate;)Ljava/util/Optional;", remap = false))
61
    private Optional<?> isAllowedC(Optional<?> instance, Predicate<?> predicate, Operation<Optional<?>> original) {
62
        return instance;
63
    }
64
65
}
66
MixinServerboundPlayerInputPacketsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinServerboundPlayerInputPacket.javaJava · 76 lines · 2.4 KB
@Mixin(ServerboundPlayerInputPacket.class)
MixinServerboundPlayerInputPacket.javaJava · 76 lines · 2.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import net.ccbluex.liquidbounce.additions.ServerboundPlayerInputPacketAddition;
24
import net.minecraft.network.protocol.game.ServerboundPlayerInputPacket;
25
import net.minecraft.world.entity.player.Input;
26
import org.jspecify.annotations.NullMarked;
27
import org.spongepowered.asm.mixin.Final;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Shadow;
30
import org.spongepowered.asm.mixin.Unique;
31
import org.spongepowered.asm.mixin.injection.At;
32
33
@NullMarked
34
@Mixin(ServerboundPlayerInputPacket.class)
35
public abstract class MixinServerboundPlayerInputPacket implements ServerboundPlayerInputPacketAddition {
36
37
    @Shadow
38
    @Final
39
    private Input input;
40
41
    @Unique
42
    private boolean liquidBounce$forceSneak = false;
43
44
    @Override
45
    public void setLiquidBounce$forceSneak(boolean b) {
46
        this.liquidBounce$forceSneak = b;
47
    }
48
49
    @Override
50
    public boolean getLiquidBounce$forceSneak() {
51
        return this.liquidBounce$forceSneak;
52
    }
53
54
    public Input liquidBounce$getRawInput() {
55
        return this.input;
56
    }
57
58
    @ModifyReturnValue(method = "input", at = @At("RETURN"))
59
    private Input applyForceSneak(Input original) {
60
        if (this.liquidBounce$forceSneak && !original.shift()) {
61
            return new Input(
62
                original.forward(),
63
                original.backward(),
64
                original.left(),
65
                original.right(),
66
                original.jump(),
67
                true,
68
                original.sprint()
69
            );
70
        } else {
71
            return original;
72
        }
73
    }
74
75
}
76
MixinServerboundUseItemOnPacketsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinServerboundUseItemOnPacket.javaJava · 47 lines · 2.3 KB
@Mixin(ServerboundUseItemOnPacket.class)
MixinServerboundUseItemOnPacket.javaJava · 47 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import net.ccbluex.liquidbounce.features.module.modules.exploit.disabler.disablers.DisablerVerusScaffoldG;
25
import net.minecraft.network.FriendlyByteBuf;
26
import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket;
27
import net.minecraft.world.phys.BlockHitResult;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.injection.At;
30
31
@Mixin(ServerboundUseItemOnPacket.class)
32
public abstract class MixinServerboundUseItemOnPacket {
33
    @WrapOperation(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/FriendlyByteBuf;writeBlockHitResult(Lnet/minecraft/world/phys/BlockHitResult;)V"))
34
    private void writeBlockHitResult(FriendlyByteBuf buf, BlockHitResult blockHit, Operation<Void> original) {
35
        if (DisablerVerusScaffoldG.INSTANCE.getRunning()) {
36
            buf.writeBlockPos(blockHit.getBlockPos());
37
            buf.writeVarInt(6 + blockHit.getDirection().ordinal() * 7);
38
            buf.writeFloat((float) blockHit.getLocation().x - blockHit.getBlockPos().getX());
39
            buf.writeFloat((float) blockHit.getLocation().y - blockHit.getBlockPos().getY());
40
            buf.writeFloat((float) blockHit.getLocation().z - blockHit.getBlockPos().getZ());
41
            buf.writeBoolean(blockHit.isInside());
42
        } else {
43
            original.call(buf, blockHit);
44
        }
45
    }
46
}
47
MixinServerboundUseItemPacketsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinServerboundUseItemPacket.javaJava · 76 lines · 2.9 KB
@Mixin(ServerboundUseItemPacket.class)
MixinServerboundUseItemPacket.javaJava · 76 lines · 2.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.network;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedInvalidHand;
25
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
26
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation;
27
import net.ccbluex.liquidbounce.utils.network.UseItemPacketRotation;
28
import net.minecraft.network.FriendlyByteBuf;
29
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
30
import net.minecraft.world.InteractionHand;
31
import org.spongepowered.asm.mixin.Final;
32
import org.spongepowered.asm.mixin.Mixin;
33
import org.spongepowered.asm.mixin.Mutable;
34
import org.spongepowered.asm.mixin.Shadow;
35
import org.spongepowered.asm.mixin.injection.At;
36
import org.spongepowered.asm.mixin.injection.Inject;
37
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
38
39
@Mixin(ServerboundUseItemPacket.class)
40
public abstract class MixinServerboundUseItemPacket {
41
42
    @Mutable
43
    @Shadow
44
    @Final
45
    private float yRot;
46
47
    @Mutable
48
    @Shadow
49
    @Final
50
    private float xRot;
51
52
    @Inject(method = "<init>(Lnet/minecraft/world/InteractionHand;IFF)V", at = @At("RETURN"))
53
    private void modifyRotation(InteractionHand hand, int sequence, float yRot, float xRot, CallbackInfo ci) {
54
        if (!UseItemPacketRotation.shouldOverride()) {
55
            return;
56
        }
57
58
        Rotation rotation = RotationManager.INSTANCE.getCurrentRotation();
59
        if (rotation == null) {
60
            return;
61
        }
62
63
        this.yRot = rotation.yRot();
64
        this.xRot = rotation.xRot();
65
    }
66
67
    /**
68
     * @see NoSlowSharedInvalidHand
69
     */
70
    @WrapOperation(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/FriendlyByteBuf;writeEnum(Ljava/lang/Enum;)Lnet/minecraft/network/FriendlyByteBuf;"))
71
    private static FriendlyByteBuf writeEnum(FriendlyByteBuf instance, Enum<?> value, Operation<FriendlyByteBuf> original) {
72
        return value == null ? instance.writeVarInt(-1) : original.call(instance, value);
73
    }
74
75
}
76
MixinBuiltInRegistriessrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/registry/MixinBuiltInRegistries.javaJava · 37 lines · 1.5 KB
@Mixin(BuiltInRegistries.class)
MixinBuiltInRegistries.javaJava · 37 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.registry;
20
21
import net.ccbluex.liquidbounce.features.creativetab.CustomCreativeModeTabs;
22
import net.minecraft.core.registries.BuiltInRegistries;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.injection.At;
25
import org.spongepowered.asm.mixin.injection.Inject;
26
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
27
28
@Mixin(BuiltInRegistries.class)
29
public abstract class MixinBuiltInRegistries {
30
31
    @Inject(method = "bootStrap", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/registries/BuiltInRegistries;freeze()V"))
32
    private static void injectInitializeTabs(CallbackInfo ci) {
33
        CustomCreativeModeTabs.INSTANCE.init();
34
    }
35
36
}
37
MixinBakedQuadMaterialInfosrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinBakedQuadMaterialInfo.javaJava · 44 lines · 2.0 KB
@Mixin(BakedQuad.MaterialInfo.class)
MixinBakedQuadMaterialInfo.javaJava · 44 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import net.ccbluex.liquidbounce.common.XRayBlockRenderContext;
24
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
25
import net.minecraft.client.resources.model.geometry.BakedQuad;
26
import org.objectweb.asm.Opcodes;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
30
@Mixin(BakedQuad.MaterialInfo.class)
31
public abstract class MixinBakedQuadMaterialInfo {
32
33
    @ModifyReturnValue(method = "layer", at = @At("RETURN"))
34
    private ChunkSectionLayer injectXRayTransparentBackgroundLayer1(ChunkSectionLayer original) {
35
        return XRayBlockRenderContext.forceTranslucentLayer(original);
36
    }
37
38
    @ModifyExpressionValue(method = "flags", at = @At(value = "FIELD", target = "Lnet/minecraft/client/resources/model/geometry/BakedQuad$MaterialInfo;layer:Lnet/minecraft/client/renderer/chunk/ChunkSectionLayer;", opcode = Opcodes.GETFIELD))
39
    private ChunkSectionLayer injectXRayTransparentBackgroundLayer2(ChunkSectionLayer original) {
40
        return XRayBlockRenderContext.forceTranslucentLayer(original);
41
    }
42
43
}
44
MixinCamerasrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinCamera.javaJava · 259 lines · 10.1 KB
@Mixin(Camera.class)
ModifiesCamera
MixinCamera.javaJava · 259 lines · 10.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.ccbluex.liquidbounce.event.EventManager;
25
import net.ccbluex.liquidbounce.event.events.PerspectiveEvent;
26
import net.ccbluex.liquidbounce.features.module.modules.combat.aimbot.ModuleDroneControl;
27
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAspect;
28
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFreeCam;
29
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFreeLook;
30
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleNoFov;
31
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleQuickPerspectiveSwap;
32
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleSmoothCamera;
33
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleZoom;
34
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation;
35
import net.minecraft.client.Camera;
36
import net.minecraft.client.CameraType;
37
import net.minecraft.client.Minecraft;
38
import net.minecraft.util.Mth;
39
import net.minecraft.world.entity.Entity;
40
import net.minecraft.world.entity.LivingEntity;
41
import net.minecraft.world.phys.Vec3;
42
import org.jspecify.annotations.Nullable;
43
import org.spongepowered.asm.mixin.Final;
44
import org.spongepowered.asm.mixin.Mixin;
45
import org.spongepowered.asm.mixin.Shadow;
46
import org.spongepowered.asm.mixin.injection.*;
47
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
48
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
49
50
@Mixin(Camera.class)
51
public abstract class MixinCamera {
52
53
    @Shadow
54
    private boolean detached;
55
    @Shadow
56
    private float yRot;
57
    @Shadow
58
    private float xRot;
59
60
    @Shadow
61
    protected abstract void setRotation(float yRot, float xRot);
62
63
    @Shadow
64
    protected abstract float getMaxZoom(float maxZoom);
65
66
    @Shadow
67
    protected abstract void move(float zoom, float dy, float dx);
68
69
    @Shadow
70
    public abstract void setPosition(Vec3 pos);
71
72
    @Shadow
73
    private @Nullable Entity entity;
74
75
    @Shadow
76
    @Final
77
    private Minecraft minecraft;
78
79
    @Inject(method = "alignWithEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setPosition(DDD)V", shift = At.Shift.AFTER))
80
    private void hookFreeCamModifiedPosition(float partialTicks, CallbackInfo ci) {
81
        ModuleFreeCam.INSTANCE.applyCameraPosition(this.entity, partialTicks);
82
    }
83
84
    @ModifyArgs(method = "alignWithEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setRotation(FF)V"))
85
    private void hookFreeCamModifiedRotation(Args args, @Local(argsOnly = true, name = "partialTicks") float partialTicks) {
86
        if (this.entity == this.minecraft.player && ModuleFreeCam.PositionState.INSTANCE.getAvailable()) {
87
            final Rotation rot = ModuleFreeCam.PositionState.INSTANCE.interpolateRot(partialTicks);
88
            args.set(0, rot.yaw());
89
            args.set(1, rot.pitch());
90
        }
91
    }
92
93
    @Inject(method = "alignWithEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setPosition(DDD)V", shift = At.Shift.AFTER), cancellable = true)
94
    private void modifyCameraOrientation(float partialTicks, CallbackInfo ci) {
95
        var freeLook = ModuleFreeLook.INSTANCE.getRunning();
96
        var freeLockInvertedView = ModuleFreeLook.INSTANCE.isInvertedView();
97
        var qps = ModuleQuickPerspectiveSwap.INSTANCE.getRunning();
98
        var rearView = qps && ModuleQuickPerspectiveSwap.INSTANCE.getRearView() && !freeLook
99
            && this.minecraft.options.getCameraType().isFirstPerson();
100
101
        if (freeLook || qps) {
102
            this.detached = true;
103
104
            if (freeLook) {
105
                var cameraYaw = ModuleFreeLook.INSTANCE.getCameraYaw();
106
                var cameraPitch = ModuleFreeLook.INSTANCE.getCameraPitch();
107
108
                if (freeLockInvertedView) {
109
                    setRotation(cameraYaw + 180, -cameraPitch);
110
                } else {
111
                    setRotation(cameraYaw, cameraPitch);
112
                }
113
            }
114
115
            if (qps && !rearView) {
116
                setRotation(yRot + 180.0f, freeLook && !freeLockInvertedView ? xRot : -xRot);
117
            }
118
119
            float scale = this.entity instanceof LivingEntity livingEntity ? livingEntity.getScale() : 1.0F;
120
            float desiredCameraDistance = PerspectiveEvent.INSTANCE.getDistance();
121
122
            move(-getMaxZoom(desiredCameraDistance * scale), 0.0f, 0.0f);
123
124
            ci.cancel();
125
            return;
126
        }
127
        var screen = ModuleDroneControl.INSTANCE.getScreen();
128
129
        if (screen != null) {
130
            this.setPosition(screen.getCameraPos());
131
            this.setRotation(screen.getCameraRotation().yRot(), screen.getCameraRotation().xRot());
132
        }
133
    }
134
135
    @Inject(method = "alignWithEntity", at = @At("TAIL"))
136
    private void applyFreeCamPlayerSelfRendering(float partialTicks, CallbackInfo ci) {
137
        if (ModuleFreeCam.INSTANCE.getRunning()) {
138
            this.detached = true;
139
        }
140
    }
141
142
    @ModifyArg(
143
        method = "alignWithEntity",
144
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setPosition(Lnet/minecraft/world/phys/Vec3;)V")
145
    )
146
    private Vec3 modifyPositionVehicle(Vec3 original) {
147
        if (ModuleFreeLook.INSTANCE.getRunning()) {
148
            return original;
149
        }
150
151
        ModuleSmoothCamera.cameraUpdate(original);
152
        return ModuleSmoothCamera.shouldApplyChanges() ? ModuleSmoothCamera.INSTANCE.getSmoothPos() : original;
153
    }
154
155
    @ModifyArgs(method = "alignWithEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setPosition(DDD)V"))
156
    private void modifyPosition(Args args) {
157
        if (ModuleFreeLook.INSTANCE.getRunning()) {
158
            return;
159
        }
160
161
        Vec3 original = new Vec3(args.get(0), args.get(1), args.get(2));
162
        ModuleSmoothCamera.cameraUpdate(original);
163
        if (ModuleSmoothCamera.shouldApplyChanges()) {
164
            Vec3 smoothPos = ModuleSmoothCamera.INSTANCE.getSmoothPos();
165
            args.set(0, smoothPos.x);
166
            args.set(1, smoothPos.y);
167
            args.set(2, smoothPos.z);
168
        }
169
    }
170
171
172
    /**
173
     * <pre>
174
     *     minecraft.options.fov.get().intValue();
175
     * </pre>
176
     */
177
    @ModifyExpressionValue(method = {
178
        "createProjectionMatrixForCulling",
179
        "getFluidInCamera",
180
        "calculateFov",
181
    }, at = @At(value = "INVOKE", target = "Ljava/lang/Integer;intValue()I", remap = false))
182
    private int hookGetFov(int original) {
183
        int result;
184
185
        if (ModuleZoom.INSTANCE.getRunning()) {
186
            return ModuleZoom.INSTANCE.getFov(true, 0);
187
        } else {
188
            result = ModuleZoom.INSTANCE.getFov(false, original);
189
        }
190
191
        if (ModuleNoFov.INSTANCE.getRunning() && result == original) {
192
            return ModuleNoFov.INSTANCE.getFov(result);
193
        }
194
195
        return result;
196
    }
197
198
    @ModifyReturnValue(method = "getFov", at = @At("RETURN"))
199
    private float injectShit(float original) {
200
        var screen = ModuleDroneControl.INSTANCE.getScreen();
201
202
        if (screen != null) {
203
            return Math.min(120f, original / screen.getZoomFactor());
204
        }
205
206
        return original;
207
    }
208
209
    @ModifyArgs(method = "createProjectionMatrixForCulling", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;perspective(FFFFZ)Lorg/joml/Matrix4f;", remap = false))
210
    private void hookBasicProjectionMatrix(Args args) {
211
        if (ModuleAspect.INSTANCE.getRunning()) {
212
            args.set(1, (float) args.get(1) / ModuleAspect.getRatioMultiplier());
213
        }
214
    }
215
216
    @Inject(method = "tick", at = @At("HEAD"))
217
    private void tick(CallbackInfo ci) {
218
        final PerspectiveEvent event = PerspectiveEvent.INSTANCE;
219
        event.update(minecraft, entity);
220
221
        EventManager.INSTANCE.callEvent(event);
222
    }
223
224
    /**
225
     * Set as spectator to disable smart culling
226
     */
227
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isSpectator()Z"))
228
    private boolean hookFreeCamDisableSmartCullInBlocks(boolean original) {
229
        return original || ModuleFreeCam.INSTANCE.getRunning();
230
    }
231
232
    @ModifyExpressionValue(method = "alignWithEntity",
233
        at = @At(
234
            value = "INVOKE",
235
            target = "Lnet/minecraft/client/Options;getCameraType()Lnet/minecraft/client/CameraType;"
236
        )
237
    )
238
    private CameraType hookPerspectiveEventOnCamera(CameraType original) {
239
        return PerspectiveEvent.INSTANCE.getPerspective();
240
    }
241
242
    @ModifyConstant(method = "getMaxZoom", constant = @Constant(intValue = 8))
243
    private int hookCameraClip(int constant) {
244
        return (PerspectiveEvent.INSTANCE.getNoClip()) ? 0 : constant;
245
    }
246
247
    @ModifyExpressionValue(method = "alignWithEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(F)F"))
248
    private float hookCameraDistance(float original, float partialTicks) {
249
        if (!PerspectiveEvent.INSTANCE.getNoClip()) {
250
            return original;
251
        }
252
253
        final float lastDistance = PerspectiveEvent.INSTANCE.getLastDistance();
254
        final float distance = PerspectiveEvent.INSTANCE.getDistance();
255
        return distance != lastDistance ? Mth.lerp(partialTicks, lastDistance, distance) : distance;
256
    }
257
258
}
259
MixinEnchantTableRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEnchantTableRenderer.javaJava · 46 lines · 2.6 KB
@Mixin(EnchantTableRenderer.class)
MixinEnchantTableRenderer.javaJava · 46 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
23
import com.mojang.blaze3d.vertex.PoseStack;
24
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
25
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
26
import net.minecraft.client.model.Model;
27
import net.minecraft.client.renderer.SubmitNodeCollector;
28
import net.minecraft.client.renderer.blockentity.EnchantTableRenderer;
29
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
30
import net.minecraft.client.resources.model.sprite.SpriteGetter;
31
import net.minecraft.client.resources.model.sprite.SpriteId;
32
import org.spongepowered.asm.mixin.Mixin;
33
import org.spongepowered.asm.mixin.injection.At;
34
35
@Mixin(EnchantTableRenderer.class)
36
public abstract class MixinEnchantTableRenderer {
37
    @SuppressWarnings("rawtypes")
38
    @WrapWithCondition(
39
            method = "submit(Lnet/minecraft/client/renderer/blockentity/state/EnchantTableRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
40
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;IIILnet/minecraft/client/resources/model/sprite/SpriteId;Lnet/minecraft/client/resources/model/sprite/SpriteGetter;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V")
41
    )
42
    private boolean hookRenderBook(SubmitNodeCollector instance, Model model, Object o, PoseStack poseStack, int i1, int i2, int i3, SpriteId spriteId, SpriteGetter spriteGetter, int i, ModelFeatureRenderer.CrumblingOverlay crumblingOverlay) {
43
        return ModuleAntiBlind.canRender(DoRender.ENCHANT_TABLE_BOOK);
44
    }
45
}
46
MixinEndCrystalModelsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEndCrystalModel.javaJava · 52 lines · 2.1 KB
@Mixin(EndCrystalModel.class)
MixinEndCrystalModel.javaJava · 52 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleCrystalView;
23
import net.minecraft.client.model.object.crystal.EndCrystalModel;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.ModifyVariable;
27
28
@Mixin(EndCrystalModel.class)
29
public abstract class MixinEndCrystalModel {
30
31
    @ModifyExpressionValue(method = "setupAnim(Lnet/minecraft/client/renderer/entity/state/EndCrystalRenderState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EndCrystalRenderer;getY(F)F"))
32
    public float injectYOffsetMultiplier(float original) {
33
        var crystalView = ModuleCrystalView.INSTANCE;
34
        if (crystalView.getRunning()) {
35
            return original * crystalView.getBounce();
36
        }
37
38
        return original;
39
    }
40
41
    @ModifyVariable(method = "setupAnim(Lnet/minecraft/client/renderer/entity/state/EndCrystalRenderState;)V", at = @At(value = "STORE", ordinal = 0), name = "animationSpeed")
42
    public float injectSpinSpeedMultiplier(float original) {
43
        var crystalView = ModuleCrystalView.INSTANCE;
44
        if (crystalView.getRunning()) {
45
            return original * crystalView.getSpinSpeed();
46
        }
47
48
        return original;
49
    }
50
51
}
52
MixinEntityHitboxDebugRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEntityHitboxDebugRenderer.javaJava · 59 lines · 2.3 KB
@Mixin(EntityHitboxDebugRenderer.class)
MixinEntityHitboxDebugRenderer.javaJava · 59 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleHitbox;
25
import net.ccbluex.liquidbounce.utils.combat.CombatExtensionsKt;
26
import net.minecraft.client.renderer.debug.EntityHitboxDebugRenderer;
27
import net.minecraft.world.entity.Entity;
28
import net.minecraft.world.phys.AABB;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
32
@Mixin(EntityHitboxDebugRenderer.class)
33
public abstract class MixinEntityHitboxDebugRenderer {
34
35
    @ModifyExpressionValue(
36
        method = "showHitboxes",
37
        at = {
38
            @At(
39
                value = "INVOKE",
40
                target = "Lnet/minecraft/world/entity/Entity;getBoundingBox()Lnet/minecraft/world/phys/AABB;"
41
            ),
42
            @At(
43
                value = "INVOKE",
44
                target = "Lnet/minecraft/world/entity/boss/enderdragon/EnderDragonPart;getBoundingBox()Lnet/minecraft/world/phys/AABB;"
45
            ),
46
        }
47
    )
48
    private AABB getBoundingBox(AABB original, @Local(argsOnly = true, name = "entity") Entity entity) {
49
        var moduleHitBox = ModuleHitbox.INSTANCE;
50
        if (entity != null && moduleHitBox.getRunning()
51
            && moduleHitBox.getApplyToDebugHitbox() && CombatExtensionsKt.shouldBeAttacked(entity)) {
52
            var expansion = moduleHitBox.getSize();
53
            return original.inflate(expansion);
54
        }
55
        return original;
56
    }
57
58
}
59
MixinFontsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinFont.javaJava · 71 lines · 3.1 KB
@Mixin(Font.class)
ModifiesFont
MixinFont.javaJava · 71 lines · 3.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import com.llamalad7.mixinextras.injector.ModifyReceiver;
23
import net.ccbluex.liquidbounce.features.module.modules.misc.nameprotect.ModuleNameProtect;
24
import net.minecraft.client.gui.Font;
25
import net.minecraft.util.FormattedCharSequence;
26
import net.minecraft.util.FormattedCharSink;
27
import org.jspecify.annotations.Nullable;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.injection.At;
30
import org.spongepowered.asm.mixin.injection.ModifyArg;
31
32
@Mixin(Font.class)
33
public abstract class MixinFont {
34
35
    @ModifyArg(
36
        method = "prepareText(Ljava/lang/String;FFIZI)Lnet/minecraft/client/gui/Font$PreparedText;",
37
        at = @At(
38
            value = "INVOKE",
39
            target = "Lnet/minecraft/util/StringDecomposer;iterateFormatted(Ljava/lang/String;Lnet/minecraft/network/chat/Style;Lnet/minecraft/util/FormattedCharSink;)Z"
40
        )
41
    )
42
    private String injectNameProtectA(String text) {
43
        return ModuleNameProtect.INSTANCE.replace(text);
44
    }
45
46
    @ModifyReceiver(
47
        method = "prepareText(Lnet/minecraft/util/FormattedCharSequence;FFIZZI)Lnet/minecraft/client/gui/Font$PreparedText;",
48
        at = @At(value = "INVOKE", target = "Lnet/minecraft/util/FormattedCharSequence;accept(Lnet/minecraft/util/FormattedCharSink;)Z")
49
    )
50
    private FormattedCharSequence injectNameProtectB(FormattedCharSequence instance, FormattedCharSink formattedCharSink) {
51
        return ModuleNameProtect.INSTANCE.wrap(instance);
52
    }
53
54
    @ModifyArg(method = "width(Ljava/lang/String;)I", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/StringSplitter;stringWidth(Ljava/lang/String;)F"), index = 0)
55
    private @Nullable String injectNameProtectWidthA(@Nullable String text) {
56
        if (text != null && ModuleNameProtect.INSTANCE.getRunning()) {
57
            return ModuleNameProtect.INSTANCE.replace(text);
58
        }
59
60
        return text;
61
    }
62
63
    @ModifyArg(method = "width(Lnet/minecraft/util/FormattedCharSequence;)I",
64
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/StringSplitter;stringWidth(Lnet/minecraft/util/FormattedCharSequence;)F"),
65
            index = 0)
66
    private FormattedCharSequence injectNameProtectWidthB(FormattedCharSequence text) {
67
        return ModuleNameProtect.INSTANCE.wrap(text);
68
    }
69
70
}
71
MixinFramerateLimitTrackersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinFramerateLimitTracker.javaJava · 48 lines · 1.9 KB
@Mixin(value = FramerateLimitTracker.class, priority = 100)priority 100
MixinFramerateLimitTracker.javaJava · 48 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
22
import com.mojang.blaze3d.platform.FramerateLimitTracker;
23
import net.ccbluex.liquidbounce.event.EventManager;
24
import net.ccbluex.liquidbounce.event.events.FpsLimitEvent;
25
import net.ccbluex.liquidbounce.utils.render.RefreshRateKt;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
import org.spongepowered.asm.mixin.injection.Constant;
29
import org.spongepowered.asm.mixin.injection.ModifyConstant;
30
31
@Mixin(value = FramerateLimitTracker.class, priority = 100)
32
public abstract class MixinFramerateLimitTracker {
33
34
    /**
35
     * Removes frame rate limit
36
     */
37
    @ModifyConstant(method = "getFramerateLimit", constant = @Constant(intValue = 60), require = 0)
38
    private int getFramerateLimit(int original) {
39
        return RefreshRateKt.getRefreshRate();
40
    }
41
42
    @ModifyReturnValue(method = "getFramerateLimit", at = @At("RETURN"))
43
    private int hookFpsLimit(int original) {
44
        return EventManager.INSTANCE.callEvent(new FpsLimitEvent(original)).getFps();
45
    }
46
47
}
48
MixinGameRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinGameRenderer.javaJava · 238 lines · 9.4 KB
@Mixin(GameRenderer.class)
ModifiesGameRenderer
MixinGameRenderer.javaJava · 238 lines · 9.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import com.llamalad7.mixinextras.sugar.Local;
25
import com.mojang.blaze3d.pipeline.RenderTarget;
26
import com.mojang.blaze3d.vertex.PoseStack;
27
import com.mojang.math.Axis;
28
import net.ccbluex.liquidbounce.event.EventManager;
29
import net.ccbluex.liquidbounce.event.events.GameRenderEvent;
30
import net.ccbluex.liquidbounce.event.events.PerspectiveEvent;
31
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent;
32
import net.ccbluex.liquidbounce.features.module.modules.fun.ModuleDankBobbing;
33
import net.ccbluex.liquidbounce.features.module.modules.render.*;
34
import net.ccbluex.liquidbounce.features.module.modules.render.customambience.ModuleCustomAmbience;
35
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
36
import net.ccbluex.liquidbounce.utils.collection.Pools;
37
import net.ccbluex.liquidbounce.utils.render.WorldToScreen;
38
import net.minecraft.client.Camera;
39
import net.minecraft.client.CameraType;
40
import net.minecraft.client.DeltaTracker;
41
import net.minecraft.client.Minecraft;
42
import net.minecraft.client.renderer.GameRenderer;
43
import net.minecraft.client.renderer.Lightmap;
44
import net.minecraft.client.renderer.fog.FogRenderer;
45
import net.minecraft.client.renderer.state.level.CameraRenderState;
46
import net.minecraft.util.Mth;
47
import net.minecraft.world.item.ItemStack;
48
import org.joml.Matrix4f;
49
import org.joml.Matrix4fc;
50
import org.objectweb.asm.Opcodes;
51
import org.spongepowered.asm.mixin.Final;
52
import org.spongepowered.asm.mixin.Mixin;
53
import org.spongepowered.asm.mixin.Shadow;
54
import org.spongepowered.asm.mixin.injection.At;
55
import org.spongepowered.asm.mixin.injection.Inject;
56
import org.spongepowered.asm.mixin.injection.ModifyArg;
57
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
58
59
@Mixin(GameRenderer.class)
60
public abstract class MixinGameRenderer {
61
62
    @Shadow
63
    @Final
64
    private Minecraft minecraft;
65
66
    @Shadow
67
    @Final
68
    private Camera mainCamera;
69
70
    @Shadow
71
    public abstract void tick();
72
73
    @Shadow
74
    @Final
75
    private Lightmap lightmap;
76
77
    @Shadow
78
    @Final
79
    private RenderTarget mainRenderTarget;
80
81
    /**
82
     * Hook game render event
83
     */
84
    @Inject(method = "render", at = @At("HEAD"))
85
    public void hookGameRender(CallbackInfo callbackInfo) {
86
        EventManager.INSTANCE.callEvent(GameRenderEvent.INSTANCE);
87
    }
88
89
    /**
90
     * Apply change-look rotations before vanilla updates and extracts the camera state.
91
     */
92
    @Inject(method = "update", at = @At("HEAD"))
93
    private void applyChangeLookRotation(DeltaTracker deltaTracker, CallbackInfo ci) {
94
        RotationManager.INSTANCE.applyChangeLookRotation(deltaTracker.getGameTimeDeltaPartialTick(false));
95
    }
96
97
    @Inject(method = "extractCamera", at = @At("TAIL"))
98
    private void hookWorldToScreenMatricesInExtract(
99
        DeltaTracker deltaTracker,
100
        float worldPartialTicks,
101
        float cameraEntityPartialTicks,
102
        CallbackInfo ci,
103
        @Local(name = "cameraState") CameraRenderState cameraState
104
    ) {
105
        WorldToScreen.setMatrices(cameraState.projectionMatrix, cameraState.viewRotationMatrix, cameraState.pos);
106
    }
107
108
    /**
109
     * Hook world render event
110
     */
111
    @Inject(method = "renderLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/state/level/CameraEntityRenderState;isSleeping:Z", opcode = Opcodes.GETFIELD))
112
    public void hookWorldRender(
113
        DeltaTracker deltaTracker,
114
        CallbackInfo ci,
115
        @Local(name = "projectionMatrix") Matrix4f projectionMatrix,
116
        @Local(name = "modelViewMatrix") Matrix4fc modelViewMatrix
117
    ) {
118
        var newMatStack = Pools.MatStack.borrow();
119
        try {
120
            newMatStack.mulPose(modelViewMatrix);
121
            try (var event = new WorldRenderEvent(
122
                newMatStack,
123
                this.mainCamera,
124
                deltaTracker.getGameTimeDeltaPartialTick(false),
125
                this.mainRenderTarget
126
            )) {
127
                EventManager.INSTANCE.callEvent(event);
128
            }
129
        } finally {
130
            Pools.MatStack.recycle(newMatStack);
131
        }
132
    }
133
134
    @ModifyArg(
135
        method = "renderLevel",
136
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/fog/FogRenderer;getBuffer(Lnet/minecraft/client/renderer/fog/FogRenderer$FogMode;)Lcom/mojang/blaze3d/buffers/GpuBufferSlice;")
137
    )
138
    private FogRenderer.FogMode disableFog(FogRenderer.FogMode fogMode) {
139
        var fogValueGroup = ModuleCustomAmbience.FogValueGroup.INSTANCE;
140
        if (fogValueGroup.getRunning() && ModuleCustomAmbience.FogValueGroup.INSTANCE.getDisableWorldFog()) {
141
            return FogRenderer.FogMode.NONE;
142
        }
143
        return fogMode;
144
    }
145
146
    @WrapOperation(
147
        method = "renderItemInHand",
148
        at = @At(
149
            value = "INVOKE",
150
            target = "Lnet/minecraft/client/renderer/feature/FeatureRenderDispatcher;renderAllFeatures(Lnet/minecraft/client/renderer/SubmitNodeStorage;)V"
151
        )
152
    )
153
    private void drawItemCharmsOnHandFeatureExecution(
154
        net.minecraft.client.renderer.feature.FeatureRenderDispatcher instance,
155
        net.minecraft.client.renderer.SubmitNodeStorage submitNodeStorage,
156
        Operation<Void> original
157
    ) {
158
        ModuleItemChams.Lightmap.INSTANCE.applyToTexture(this.lightmap.getTextureView());
159
        try {
160
            original.call(instance, submitNodeStorage);
161
        } finally {
162
            ModuleItemChams.Lightmap.INSTANCE.resetTexture(this.lightmap.getTextureView());
163
        }
164
    }
165
166
    @Inject(method = "bobHurt", at = @At("HEAD"), cancellable = true)
167
    private void injectHurtCam(CameraRenderState cameraState, PoseStack poseStack, CallbackInfo ci) {
168
        if (ModuleNoHurtCam.INSTANCE.getRunning()) {
169
            ci.cancel();
170
        }
171
    }
172
173
    /**
174
     * Keeps the vanilla 26.1 walk interpolation inputs while applying the custom bobbing strength.
175
     *
176
     * @see net.minecraft.client.renderer.GameRenderer#bobView(net.minecraft.client.renderer.state.level.CameraRenderState, com.mojang.blaze3d.vertex.PoseStack)
177
     * @see net.minecraft.client.Camera#extractRenderState(net.minecraft.client.renderer.state.level.CameraRenderState, float)
178
     * @see net.minecraft.client.renderer.state.level.CameraEntityRenderState#backwardsInterpolatedWalkDistance
179
     * @see net.minecraft.client.renderer.state.level.CameraEntityRenderState#bob
180
     */
181
    @Inject(method = "bobView", at = @At("HEAD"), cancellable = true)
182
    private void injectBobView(CameraRenderState cameraState, PoseStack poseStack, CallbackInfo ci) {
183
        if (ModuleNoBob.INSTANCE.getRunning() ||
184
            ModuleTracers.INSTANCE.getRunning() ||
185
            (ModuleItemESP.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.getShowTracers()) ||
186
            ModuleStorageESP.INSTANCE.showTracers()) {
187
188
            ci.cancel();
189
            return;
190
        }
191
192
        if (!ModuleDankBobbing.INSTANCE.getRunning()) {
193
            return;
194
        }
195
196
        final var entityRenderState = cameraState.entityRenderState;
197
        if (!entityRenderState.isPlayer) {
198
            return;
199
        }
200
201
        float additionalBobbing = ModuleDankBobbing.INSTANCE.getMotion();
202
        float g = entityRenderState.backwardsInterpolatedWalkDistance;
203
        float h = entityRenderState.bob;
204
        poseStack.translate(Mth.sin(g * Mth.PI) * h * 0.5f, -Math.abs(Mth.cos(g * Mth.PI) * h), 0.0f);
205
        poseStack.mulPose(Axis.ZP.rotationDegrees(Mth.sin(h * Mth.PI) * h * (3.0F + additionalBobbing)));
206
        poseStack.mulPose(Axis.XP.rotationDegrees(Math.abs(Mth.cos(h * Mth.PI - (0.2F + additionalBobbing)) * h) * 5.0F));
207
208
        ci.cancel();
209
    }
210
211
    @Inject(method = "displayItemActivation", at = @At("HEAD"), cancellable = true)
212
    private void hookShowFloatingItem(ItemStack floatingItem, CallbackInfo ci) {
213
        if (!ModuleAntiBlind.canRender(DoRender.FLOATING_ITEMS)) {
214
            ci.cancel();
215
        }
216
    }
217
218
    @ModifyExpressionValue(method = "renderLevel", at = @At(value = "INVOKE", target = "Ljava/lang/Math;max(FF)F", ordinal = 0, remap = false))
219
    private float hookAntiNausea(float original) {
220
        if (!ModuleAntiBlind.canRender(DoRender.NAUSEA)) {
221
            return 0f;
222
        }
223
224
        return original;
225
    }
226
227
    @ModifyExpressionValue(method = "extractOptions",
228
            at = @At(
229
                    value = "INVOKE",
230
                    target = "Lnet/minecraft/client/Options;getCameraType()Lnet/minecraft/client/CameraType;"
231
            )
232
    )
233
    private CameraType hookPerspectiveEventOnCamera(CameraType original) {
234
        return PerspectiveEvent.INSTANCE.getPerspective();
235
    }
236
237
}
238
MixinItemFeatureRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinItemFeatureRenderer.javaJava · 96 lines · 4.0 KB
@Mixin(ItemFeatureRenderer.class)
MixinItemFeatureRenderer.javaJava · 96 lines · 4.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import com.llamalad7.mixinextras.sugar.Local;
25
import com.mojang.blaze3d.vertex.PoseStack;
26
import com.mojang.blaze3d.vertex.SheetedDecalTextureGenerator;
27
import com.mojang.blaze3d.vertex.VertexConsumer;
28
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleChams;
29
import net.minecraft.client.Minecraft;
30
import net.minecraft.client.renderer.feature.ItemFeatureRenderer;
31
import net.minecraft.client.renderer.rendertype.OutputTarget;
32
import net.minecraft.client.renderer.rendertype.RenderType;
33
import net.minecraft.client.renderer.rendertype.RenderTypes;
34
import org.jspecify.annotations.Nullable;
35
import org.spongepowered.asm.mixin.Mixin;
36
import org.spongepowered.asm.mixin.Unique;
37
import org.spongepowered.asm.mixin.injection.At;
38
39
@Mixin(ItemFeatureRenderer.class)
40
public abstract class MixinItemFeatureRenderer extends MixinRenderTypeFeatureRenderer {
41
42
    @ModifyExpressionValue(
43
        method = "prepareMainSubmit",
44
        at = @At(
45
            value = "INVOKE",
46
            target = "Lnet/minecraft/client/resources/model/geometry/BakedQuad$MaterialInfo;itemRenderType()Lnet/minecraft/client/renderer/rendertype/RenderType;"
47
        )
48
    )
49
    private RenderType remapHeldItemMainRenderType(
50
        RenderType renderType,
51
        @Local(argsOnly = true, name = "submit") ItemFeatureRenderer.Submit submit
52
    ) {
53
        return ModuleChams.INSTANCE.remapHeldItemRenderTypeIfNeeded(submit, renderType);
54
    }
55
56
    @WrapOperation(
57
        method = "prepareFoilSubmit",
58
        at = @At(
59
            value = "INVOKE",
60
            target = "Lnet/minecraft/client/renderer/feature/ItemFeatureRenderer;getFoilBuffer(Lnet/minecraft/client/renderer/rendertype/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack$Pose;)Lcom/mojang/blaze3d/vertex/VertexConsumer;"
61
        )
62
    )
63
    private VertexConsumer remapHeldItemFoilRenderType(
64
        ItemFeatureRenderer instance,
65
        RenderType renderType,
66
        PoseStack.@Nullable Pose foilDecalPose,
67
        Operation<VertexConsumer> original,
68
        @Local(argsOnly = true, name = "submit") ItemFeatureRenderer.Submit submit
69
    ) {
70
        if (!ModuleChams.INSTANCE.isHeldItemSubmit(submit)) {
71
            return original.call(instance, renderType, foilDecalPose);
72
        }
73
74
        RenderType foilRenderType = useTransparentGlint(renderType)
75
            ? RenderTypes.glintTranslucent()
76
            : RenderTypes.glint();
77
78
        VertexConsumer vertexConsumer = getVertexBuilder(
79
            ModuleChams.INSTANCE.remapHeldItemRenderTypeIfNeeded(submit, foilRenderType)
80
        );
81
82
        if (foilDecalPose != null) {
83
            vertexConsumer = new SheetedDecalTextureGenerator(vertexConsumer, foilDecalPose, 0.0078125F);
84
        }
85
86
        return vertexConsumer;
87
    }
88
89
    @Unique
90
    private static boolean useTransparentGlint(RenderType renderType) {
91
        return Minecraft.getInstance().gameRenderer.gameRenderState().useShaderTransparency()
92
            && renderType.outputTarget() == OutputTarget.ITEM_ENTITY_TARGET;
93
    }
94
95
}
96
MixinLevelRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLevelRenderer.javaJava · 197 lines · 8.9 KB
@Mixin(LevelRenderer.class)
MixinLevelRenderer.javaJava · 197 lines · 8.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import com.mojang.blaze3d.buffers.GpuBufferSlice;
25
import com.mojang.blaze3d.framegraph.FrameGraphBuilder;
26
import com.mojang.blaze3d.framegraph.FramePass;
27
import com.mojang.blaze3d.pipeline.RenderTarget;
28
import com.mojang.blaze3d.vertex.PoseStack;
29
import net.ccbluex.liquidbounce.LiquidBounce;
30
import net.ccbluex.liquidbounce.event.EventManager;
31
import net.ccbluex.liquidbounce.event.events.DrawOutlinesEvent;
32
import net.ccbluex.liquidbounce.event.events.WorldFeatureSubmitEvent;
33
import net.ccbluex.liquidbounce.features.module.modules.render.*;
34
import net.ccbluex.liquidbounce.features.module.modules.render.customambience.ModuleCustomAmbience;
35
import net.ccbluex.liquidbounce.utils.collection.Pools;
36
import net.minecraft.client.Minecraft;
37
import net.minecraft.client.renderer.LevelRenderer;
38
import net.minecraft.client.renderer.SubmitNodeCollector;
39
import net.minecraft.client.renderer.SubmitNodeStorage;
40
import net.minecraft.client.renderer.feature.FeatureRenderDispatcher;
41
import net.minecraft.client.renderer.state.level.LevelRenderState;
42
import org.joml.Matrix4fc;
43
import org.jspecify.annotations.Nullable;
44
import org.joml.Vector4fc;
45
import org.objectweb.asm.Opcodes;
46
import org.spongepowered.asm.mixin.Final;
47
import org.spongepowered.asm.mixin.Mixin;
48
import org.spongepowered.asm.mixin.Shadow;
49
import org.spongepowered.asm.mixin.Unique;
50
import org.spongepowered.asm.mixin.injection.At;
51
import org.spongepowered.asm.mixin.injection.Inject;
52
import org.spongepowered.asm.mixin.injection.ModifyArg;
53
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
54
55
import java.util.List;
56
import java.util.Locale;
57
58
@Mixin(LevelRenderer.class)
59
public abstract class MixinLevelRenderer {
60
61
    @Final
62
    @Shadow
63
    private SubmitNodeStorage submitNodeStorage;
64
65
    @Shadow
66
    @Nullable
67
    public abstract RenderTarget entityOutlineTarget();
68
69
    @Unique
70
    private boolean liquid_bounce$hasCustomOutlineMesh = false;
71
72
    @Inject(
73
        method = "render",
74
        at = @At(
75
            value = "INVOKE",
76
            target = "Lnet/minecraft/client/renderer/LevelRenderer;submitFeatures(Lnet/minecraft/client/renderer/state/level/LevelRenderState;Lnet/minecraft/client/renderer/SubmitNodeCollector;Z)V"
77
        )
78
    )
79
    private void hookWorldFeatureSubmit(CallbackInfo ci, @Local(argsOnly = true, name = "modelViewMatrix") Matrix4fc modelViewMatrix) {
80
        var poseStack = Pools.MatStack.borrow();
81
82
        EventManager.INSTANCE.callEvent(new WorldFeatureSubmitEvent(
83
            poseStack,
84
            Minecraft.getInstance().gameRenderer.mainCamera(),
85
            this.submitNodeStorage,
86
            modelViewMatrix
87
        ));
88
89
        Pools.MatStack.recycle(poseStack);
90
    }
91
92
    // TODO: removed because of vanilla changes
93
//    // After ModelViewMatrix setup
94
//    @Inject(method = "render", at = @At(value = "NEW", target = "Lcom/mojang/blaze3d/framegraph/FrameGraphBuilder;"))
95
//    private void onRender(GraphicsResourceAllocator resourceAllocator, DeltaTracker deltaTracker, boolean renderOutline, CameraRenderState cameraState, Matrix4fc modelViewMatrix, GpuBufferSlice terrainFog, Vector4f fogColor, boolean shouldRenderSky, CallbackInfo ci) {
96
//        OutlineShaderRenderer renderer = OutlineShaderRenderer.INSTANCE;
97
//        if (!renderer.shouldRender()) {
98
//            return;
99
//        }
100
//
101
//        var matrixStack = Pools.MatStack.borrow();
102
//        var event = new DrawOutlinesEvent(
103
//            renderer.prepareRenderTarget(),
104
//            matrixStack,
105
//            cameraState,
106
//            deltaTracker.getGameTimeDeltaPartialTick(false),
107
//            DrawOutlinesEvent.OutlineType.INBUILT_OUTLINE
108
//        );
109
//        EventManager.INSTANCE.callEvent(event);
110
//        Pools.MatStack.recycle(matrixStack);
111
//
112
//        if (event.getDirtyFlag()) {
113
//            renderer.setDirty(true);
114
//        }
115
//    }
116
117
    @ModifyArg(
118
        method = "lambda$render$0",
119
        at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoder;clearColorAndDepthTextures(Lcom/mojang/blaze3d/textures/GpuTexture;Lorg/joml/Vector4fc;Lcom/mojang/blaze3d/textures/GpuTexture;D)V"),
120
        index = 1
121
    )
122
    private Vector4fc customFogClearColor(Vector4fc original) {
123
        return ModuleCustomAmbience.FogValueGroup.INSTANCE.modifyClearColor(original);
124
    }
125
126
//    @Inject(method = "lambda$addMainPass$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/feature/FeatureRenderDispatcher$PreparedFrame;executeOutline()V", shift = At.Shift.AFTER))
127
//    private void onDrawOutlines(CallbackInfo ci) {
128
//        OutlineShaderRenderer.INSTANCE.drawBlitIfDirty(Minecraft.getInstance().gameRenderer.mainRenderTarget());
129
//    }
130
131
    @Inject(method = "lambda$addMainPass$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/feature/FeatureRenderDispatcher$PreparedFrame;executeOutline()V", shift = At.Shift.BEFORE))
132
    private void onRenderGlow(CallbackInfo ci) {
133
        var minecraft = Minecraft.getInstance();
134
        var entityOutlineFb = entityOutlineTarget();
135
        if (entityOutlineFb == null
136
            || !minecraft.gameRenderer.gameRenderState().levelRenderState.shouldShowEntityOutlines) {
137
            return;
138
        }
139
140
        liquid_bounce$hasCustomOutlineMesh = false;
141
        var matrixStack = Pools.MatStack.borrow();
142
        var event = new DrawOutlinesEvent(
143
            entityOutlineFb, matrixStack,
144
            minecraft.getDeltaTracker().getGameTimeDeltaPartialTick(false)
145
        );
146
        EventManager.INSTANCE.callEvent(event);
147
        liquid_bounce$hasCustomOutlineMesh = event.getDirtyFlag();
148
        Pools.MatStack.recycle(matrixStack);
149
    }
150
151
    @Inject(method = "lambda$addMainPass$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/feature/FeatureRenderDispatcher$PreparedFrame;executeSolid()V", shift = At.Shift.BEFORE))
152
    private void prepareChamsRenderTarget(CallbackInfo ci) {
153
        ModuleChams.INSTANCE.beginFrameIfNeeded();
154
    }
155
156
    @Inject(method = "addAlwaysOnTopPass", at = @At("HEAD"))
157
    private void scheduleChamsComposite(
158
        FrameGraphBuilder frame,
159
        FeatureRenderDispatcher.PreparedFrame featureFrame,
160
        GpuBufferSlice fog,
161
        CallbackInfo ci
162
    ) {
163
        FramePass pass = frame.addPass((LiquidBounce.CLIENT_NAME + ' ' + ModuleChams.INSTANCE.getName()).toLowerCase(Locale.ROOT));
164
        pass.disableCulling();
165
        pass.executes(() -> ModuleChams.INSTANCE.compositeIfNeeded(Minecraft.getInstance().gameRenderer.mainRenderTarget()));
166
    }
167
168
    @ModifyExpressionValue(
169
        method = {"submitFeatures", "lambda$addMainPass$0"},
170
        at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/state/level/LevelRenderState;shouldShowEntityOutlines:Z", opcode = Opcodes.GETFIELD)
171
    )
172
    private boolean includeCustomOutlines(boolean original) {
173
        return original || liquid_bounce$hasCustomOutlineMesh;
174
    }
175
176
    @ModifyExpressionValue(
177
        method = {"render", "addMainPass"},
178
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/feature/FeatureRenderDispatcher$PreparedFrame;hasAnyOutline()Z")
179
    )
180
    private boolean includeCustomOutlineTargetInMainPass(boolean original) {
181
        return original || liquid_bounce$hasCustomOutlineMesh;
182
    }
183
184
    @Inject(method = "submitBlockOutline", at = @At("HEAD"), cancellable = true)
185
    private void cancelBlockOutline(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, LevelRenderState levelRenderState, CallbackInfo ci) {
186
        if (ModuleBlockOutline.INSTANCE.getRunning()) {
187
            ci.cancel();
188
        }
189
    }
190
191
    @WrapWithCondition(method = "submitBlockDestroyAnimation", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitBreakingBlockModel(Lcom/mojang/blaze3d/vertex/PoseStack;Ljava/util/List;I)V"))
192
    private boolean cancelRenderBreakingTexture(SubmitNodeCollector instance, PoseStack poseStack, List<?> list, int i) {
193
        return ModuleAntiBlind.canRender(DoRender.BLOCK_BREAK_OVERLAY);
194
    }
195
196
}
197
MixinLightmapsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLightmap.javaJava · 73 lines · 2.8 KB
@Mixin(Lightmap.class)
ModifiesLightmap
MixinLightmap.javaJava · 73 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.mojang.blaze3d.textures.GpuTexture;
22
import net.ccbluex.liquidbounce.features.module.modules.render.customambience.ModuleCustomAmbience;
23
import net.minecraft.client.renderer.Lightmap;
24
import net.minecraft.client.renderer.state.LightmapRenderState;
25
import org.jspecify.annotations.NullMarked;
26
import org.objectweb.asm.Opcodes;
27
import org.spongepowered.asm.mixin.Final;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Shadow;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.ModifyArg;
33
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
34
35
@NullMarked
36
@Mixin(Lightmap.class)
37
public abstract class MixinLightmap {
38
39
    @Shadow
40
    @Final
41
    private GpuTexture texture;
42
43
    /**
44
     * @see net.ccbluex.liquidbounce.features.module.modules.render.ModuleItemChams.Lightmap
45
     */
46
    @ModifyArg(
47
        method = "<init>",
48
        at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuDevice;createTexture(Ljava/lang/String;ILcom/mojang/blaze3d/GpuFormat;IIII)Lcom/mojang/blaze3d/textures/GpuTexture;"),
49
        index = 1
50
    )
51
    private int makeTextureCopiable(int usage) {
52
        return usage | GpuTexture.USAGE_COPY_SRC | GpuTexture.USAGE_COPY_DST;
53
    }
54
55
    /**
56
     * <pre>
57
     * this.dirty = false;
58
     * </pre>
59
     */
60
    @Inject(
61
        method = "render(Lnet/minecraft/client/renderer/state/LightmapRenderState;)V",
62
        at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/state/LightmapRenderState;needsUpdate:Z", ordinal = 0, opcode = Opcodes.GETFIELD),
63
        cancellable = true
64
    )
65
    private void injectCustomClearColor(LightmapRenderState renderState, CallbackInfo ci) {
66
        ModuleCustomAmbience.CustomLightmap customLightmap = ModuleCustomAmbience.CustomLightmap.INSTANCE;
67
        if (customLightmap.getRunning() && customLightmap.getMode().getActiveMode().edit(this.texture, renderState)) {
68
            ci.cancel();
69
        }
70
    }
71
72
}
73
MixinLightmapRenderStateExtractorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLightmapRenderStateExtractor.javaJava · 67 lines · 2.7 KB
@Mixin(LightmapRenderStateExtractor.class)
MixinLightmapRenderStateExtractor.javaJava · 67 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFullBright;
25
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay;
26
import net.minecraft.client.renderer.LightmapRenderStateExtractor;
27
import org.jspecify.annotations.NullMarked;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.injection.At;
30
import org.spongepowered.asm.mixin.injection.ModifyVariable;
31
32
@NullMarked
33
@Mixin(LightmapRenderStateExtractor.class)
34
public abstract class MixinLightmapRenderStateExtractor {
35
36
    /**
37
     * Target:
38
     * <pre>
39
     *     float brightnessOption = ((Double)this.minecraft.options.gamma().get()).floatValue();
40
     * </pre>
41
     */
42
    @ModifyVariable(method = "extract", at = @At(value = "STORE"), name = "brightnessOption")
43
    private float injectXRayFullBright(float brightnessOption) {
44
        // If fullBright is enabled, we need to return our own gamma value
45
        if (ModuleFullBright.FullBrightGamma.INSTANCE.getRunning()) {
46
            return ModuleFullBright.FullBrightGamma.INSTANCE.getGamma();
47
        }
48
49
        // Xray fullBright
50
        final ModuleXRay module = ModuleXRay.INSTANCE;
51
        if (!module.getRunning() || !module.getFullBright()) {
52
            return brightnessOption;
53
        }
54
55
        // They use .floatValue() afterward on the return value,
56
        // so we need to return a value which is not bigger than Float.MAX_VALUE
57
        return Float.MAX_VALUE;
58
    }
59
60
    // Turns off blinking when the darkness effect is active.
61
    @ModifyVariable(method = "extract", at = @At(value = "STORE"), name = "darknessEffectScaleOption")
62
    private float injectAntiDarkness(float darknessEffectScaleOption) {
63
        return ModuleAntiBlind.canRender(DoRender.DARKNESS) ? darknessEffectScaleOption : 0f;
64
    }
65
66
}
67
MixinMapRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinMapRenderer.javaJava · 54 lines · 2.3 KB
@Mixin(MapRenderer.class)
ModifiesMapRenderer
MixinMapRenderer.javaJava · 54 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.mojang.blaze3d.vertex.PoseStack;
24
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
25
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
26
import net.minecraft.client.renderer.MapRenderer;
27
import net.minecraft.client.renderer.SubmitNodeCollector;
28
import net.minecraft.client.renderer.state.MapRenderState;
29
import net.minecraft.world.level.saveddata.maps.MapDecoration;
30
import org.objectweb.asm.Opcodes;
31
import org.spongepowered.asm.mixin.Mixin;
32
import org.spongepowered.asm.mixin.injection.At;
33
import org.spongepowered.asm.mixin.injection.Inject;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
35
36
import java.util.List;
37
38
@Mixin(MapRenderer.class)
39
public abstract class MixinMapRenderer {
40
    @ModifyExpressionValue(
41
            method = "render",
42
            at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/state/MapRenderState;decorations:Ljava/util/List;", opcode = Opcodes.GETFIELD)
43
    ) private List<MapDecoration> hookMapMarkers(List<MapDecoration> original) {
44
        return ModuleAntiBlind.canRender(DoRender.MAP_MARKERS) ? original : List.of();
45
    }
46
47
    @Inject(method = "render", at = @At("HEAD"), cancellable = true)
48
    private void hookMapContents(MapRenderState state, PoseStack matrices, SubmitNodeCollector queue, boolean bl, int light, CallbackInfo ci) {
49
        if (!ModuleAntiBlind.canRender(DoRender.MAP_CONTENTS)) {
50
            ci.cancel();
51
        }
52
    }
53
}
54
MixinModelBlockRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinModelBlockRenderer.javaJava · 125 lines · 5.3 KB
@Mixin(ModelBlockRenderer.class)
MixinModelBlockRenderer.javaJava · 125 lines · 5.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
24
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
25
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
26
import com.mojang.blaze3d.vertex.QuadInstance;
27
import net.ccbluex.liquidbounce.common.XRayBlockRenderContext;
28
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay;
29
import net.minecraft.client.renderer.block.BlockAndTintGetter;
30
import net.minecraft.client.renderer.block.BlockQuadOutput;
31
import net.minecraft.client.renderer.block.ModelBlockRenderer;
32
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
33
import net.minecraft.client.renderer.block.dispatch.BlockStateModelPart;
34
import net.minecraft.core.BlockPos;
35
import net.minecraft.core.Direction;
36
import net.minecraft.world.level.block.state.BlockState;
37
import org.jspecify.annotations.NullMarked;
38
import org.objectweb.asm.Opcodes;
39
import org.spongepowered.asm.mixin.Mixin;
40
import org.spongepowered.asm.mixin.Shadow;
41
import org.spongepowered.asm.mixin.injection.At;
42
import org.spongepowered.asm.mixin.injection.Inject;
43
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
44
45
import java.util.List;
46
47
@NullMarked
48
@Mixin(ModelBlockRenderer.class)
49
public abstract class MixinModelBlockRenderer {
50
51
    @Shadow
52
    private QuadInstance quadInstance;
53
54
    @WrapMethod(method = "tesselateBlock")
55
    private void wrapXRayTransparentBackground(BlockQuadOutput output, float x, float y, float z,
56
            BlockAndTintGetter level, BlockPos pos, BlockState state, BlockStateModel model, long seed,
57
            Operation<Void> original) {
58
        ModuleXRay module = ModuleXRay.INSTANCE;
59
        if (!module.getRunning()) {
60
            original.call(output, x, y, z, level, pos, state, model, seed);
61
            return;
62
        }
63
64
        XRayBlockRenderContext.renderTransparentBackground(module.transparentBackgroundAlpha(state),
65
            () -> original.call(output, x, y, z, level, pos, state, model, seed));
66
    }
67
68
    @Inject(method = {"tesselateFlat", "tesselateAmbientOcclusion"}, at = @At("HEAD"), cancellable = true)
69
    private void injectXRaySkipHiddenBlocks(BlockQuadOutput output, float x, float y, float z,
70
            List<BlockStateModelPart> parts, BlockAndTintGetter level, BlockState state, BlockPos pos,
71
            CallbackInfo ci) {
72
        ModuleXRay module = ModuleXRay.INSTANCE;
73
        if (!module.getRunning()) {
74
            return;
75
        }
76
77
        if (module.shouldSkipRender(state, pos)) {
78
            ci.cancel();
79
        }
80
    }
81
82
    @ModifyExpressionValue(method = "tesselateBlock", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/block/ModelBlockRenderer;ambientOcclusion:Z", opcode = Opcodes.GETFIELD))
83
    private static boolean injectXRayFullBright(boolean original) {
84
        ModuleXRay module = ModuleXRay.INSTANCE;
85
        if (!module.getRunning() || !module.getFullBright()) {
86
            return original;
87
        }
88
89
        return false;
90
    }
91
92
    @ModifyReturnValue(method = "forceOpaque", at = @At("RETURN"))
93
    private static boolean injectXRayTransparentBackgroundForceTranslucent(boolean original, boolean cutoutLeaves,
94
            BlockState state) {
95
        ModuleXRay module = ModuleXRay.INSTANCE;
96
        if (!module.getRunning() || !module.shouldRenderTransparentBackground(state)) {
97
            return original;
98
        }
99
100
        return false;
101
    }
102
103
    @ModifyReturnValue(method = "shouldRenderFace", at = @At("RETURN"))
104
    private boolean injectXRayDrawSide(boolean original, BlockAndTintGetter level, BlockState state, Direction direction,
105
            BlockPos neighborPos) {
106
        ModuleXRay module = ModuleXRay.INSTANCE;
107
        if (!module.getRunning()) {
108
            return original;
109
        }
110
111
        return module.modifyDrawSide(state, level, neighborPos.relative(direction.getOpposite()), direction, original);
112
    }
113
114
    @Inject(
115
        method = "putQuadWithTint",
116
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockQuadOutput;put(FFFLnet/minecraft/client/resources/model/geometry/BakedQuad;Lcom/mojang/blaze3d/vertex/QuadInstance;)V")
117
    )
118
    private void injectXRayTransparentBackgroundAlpha(BlockQuadOutput output, float x, float y, float z,
119
            BlockAndTintGetter level, BlockState state, BlockPos pos,
120
            net.minecraft.client.resources.model.geometry.BakedQuad quad, CallbackInfo ci) {
121
        XRayBlockRenderContext.applyAlpha(this.quadInstance);
122
    }
123
124
}
125
MixinRenderSetupAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinRenderSetupAccessor.javaJava · 82 lines · 2.4 KB
@Mixin(RenderSetup.class)
ModifiesRenderSetup
MixinRenderSetupAccessor.javaJava · 82 lines · 2.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import com.mojang.blaze3d.pipeline.RenderPipeline;
23
import net.minecraft.client.renderer.rendertype.LayeringTransform;
24
import net.minecraft.client.renderer.rendertype.OutputTarget;
25
import net.minecraft.client.renderer.rendertype.RenderSetup;
26
import net.minecraft.client.renderer.rendertype.TextureTransform;
27
import org.jspecify.annotations.NullMarked;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.gen.Accessor;
30
import org.spongepowered.asm.mixin.gen.Invoker;
31
32
import java.util.Map;
33
34
@NullMarked
35
@Mixin(RenderSetup.class)
36
public interface MixinRenderSetupAccessor {
37
38
    @Accessor
39
    RenderPipeline getPipeline();
40
41
    @Accessor
42
    Map<String, Object> getTextures();
43
44
    @Accessor
45
    TextureTransform getTextureTransform();
46
47
    @Accessor
48
    RenderSetup.OutlineProperty getOutlineProperty();
49
50
    @Accessor
51
    boolean getUseLightmap();
52
53
    @Accessor
54
    boolean getUseOverlay();
55
56
    @Accessor
57
    boolean getAffectsCrumbling();
58
59
    @Accessor
60
    boolean getSortOnUpload();
61
62
    @Accessor
63
    LayeringTransform getLayeringTransform();
64
65
    @Invoker("<init>")
66
    static RenderSetup liquid_bounce$invokeInit(
67
        RenderPipeline pipeline,
68
        Map<String, Object> textures,
69
        boolean useLightmap,
70
        boolean useOverlay,
71
        LayeringTransform layeringTransform,
72
        OutputTarget outputTarget,
73
        TextureTransform textureTransform,
74
        RenderSetup.OutlineProperty outlineProperty,
75
        boolean affectsCrumbling,
76
        boolean sortOnUpload
77
    ) {
78
        throw new AssertionError();
79
    }
80
81
}
82
MixinRenderTickCountersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinRenderTickCounter.javaJava · 48 lines · 1.8 KB
@Mixin(DeltaTracker.Timer.class)
MixinRenderTickCounter.javaJava · 48 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import net.ccbluex.liquidbounce.utils.client.Timer;
22
import net.minecraft.client.DeltaTracker;
23
import org.objectweb.asm.Opcodes;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.Shadow;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
29
30
@Mixin(DeltaTracker.Timer.class)
31
public abstract class MixinRenderTickCounter {
32
33
    @Shadow
34
    private float deltaTicks;
35
36
    /**
37
     * Hook timer speed to modify frame duration
38
     */
39
    @Inject(method = "advanceGameTime(J)I", at = @At(value = "FIELD", target = "Lnet/minecraft/client/DeltaTracker$Timer;deltaTicks:F", shift = At.Shift.AFTER, opcode = Opcodes.PUTFIELD))
40
    private void hookTimer(CallbackInfoReturnable<Integer> callback) {
41
        float customTimer = Timer.INSTANCE.getTimerSpeed();
42
        if (customTimer > 0) {
43
            deltaTicks *= customTimer;
44
        }
45
    }
46
47
}
48
MixinRenderTypeAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinRenderTypeAccessor.javaJava · 39 lines · 1.2 KB
@Mixin(RenderType.class)
ModifiesRenderType
MixinRenderTypeAccessor.javaJava · 39 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import net.minecraft.client.renderer.rendertype.RenderSetup;
23
import net.minecraft.client.renderer.rendertype.RenderType;
24
import org.jspecify.annotations.NullMarked;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.gen.Accessor;
27
28
@NullMarked
29
@Mixin(RenderType.class)
30
public interface MixinRenderTypeAccessor {
31
32
    @Accessor
33
    String getName();
34
35
    @Accessor
36
    RenderSetup getState();
37
38
}
39
MixinRenderTypeFeatureRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinRenderTypeFeatureRenderer.javaJava · 35 lines · 1.3 KB
@Mixin(RenderTypeFeatureRenderer.class)
MixinRenderTypeFeatureRenderer.javaJava · 35 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import com.mojang.blaze3d.vertex.VertexConsumer;
23
import net.minecraft.client.renderer.feature.RenderTypeFeatureRenderer;
24
import net.minecraft.client.renderer.rendertype.RenderType;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.Shadow;
27
28
@Mixin(RenderTypeFeatureRenderer.class)
29
public abstract class MixinRenderTypeFeatureRenderer {
30
31
    @Shadow
32
    protected abstract VertexConsumer getVertexBuilder(RenderType renderType);
33
34
}
35
MixinScreenEffectRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinScreenEffectRenderer.javaJava · 70 lines · 2.9 KB
@Mixin(ScreenEffectRenderer.class)
MixinScreenEffectRenderer.javaJava · 70 lines · 2.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
23
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
24
import com.mojang.blaze3d.vertex.PoseStack;
25
import com.mojang.blaze3d.vertex.VertexConsumer;
26
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
27
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
28
import net.minecraft.client.renderer.ScreenEffectRenderer;
29
import net.minecraft.client.renderer.SubmitNodeCollector;
30
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
31
import net.minecraft.util.ARGB;
32
import org.spongepowered.asm.mixin.Mixin;
33
import org.spongepowered.asm.mixin.Unique;
34
import org.spongepowered.asm.mixin.injection.At;
35
import org.spongepowered.asm.mixin.injection.Inject;
36
import org.spongepowered.asm.mixin.injection.ModifyArg;
37
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
38
39
@Mixin(ScreenEffectRenderer.class)
40
public abstract class MixinScreenEffectRenderer {
41
42
    @Unique
43
    private static final ScopedValue<Float> FIRE_ALPHA = ScopedValue.newInstance();
44
45
    @WrapMethod(method = "lambda$submitFire$0")
46
    private static void wrapFireRenderer(TextureAtlasSprite sprite, PoseStack.Pose basePose, VertexConsumer builder, Operation<Void> original) {
47
        ScopedValue.where(FIRE_ALPHA, ModuleAntiBlind.INSTANCE.getFireOpacityPercentage())
48
            .run(() -> original.call(sprite, basePose, builder));
49
    }
50
51
    @ModifyArg(
52
        method = "buildQuad",
53
        at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/VertexConsumer;setColor(I)Lcom/mojang/blaze3d/vertex/VertexConsumer;")
54
    )
55
    private static int injectFireOpacity(int color) {
56
        return FIRE_ALPHA.isBound()
57
            ? ARGB.multiplyAlpha(color, FIRE_ALPHA.get())
58
            : color;
59
    }
60
61
    @Inject(method = "submitBlockSprite", at = @At("HEAD"), cancellable = true)
62
    private static void hookWallOverlay(TextureAtlasSprite sprite, PoseStack poseStack,
63
        SubmitNodeCollector submitNodeCollector, int color, CallbackInfo ci) {
64
        if (!ModuleAntiBlind.canRender(DoRender.WALL_OVERLAY)) {
65
            ci.cancel();
66
        }
67
    }
68
69
}
70
MixinSignTextsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinSignText.javaJava · 54 lines · 2.1 KB
@Mixin(SignText.class)
ModifiesSignText
MixinSignText.javaJava · 54 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.minecraft.network.chat.Component;
25
import net.minecraft.util.FormattedCharSequence;
26
import net.minecraft.world.level.block.entity.SignText;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.Unique;
29
import org.spongepowered.asm.mixin.injection.At;
30
import org.spongepowered.asm.mixin.injection.Inject;
31
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
32
33
import java.util.Arrays;
34
import java.util.function.Function;
35
36
@Mixin(SignText.class)
37
public abstract class MixinSignText {
38
39
    @Unique
40
    private static final FormattedCharSequence[] LIQUIDBOUNCE$EMPTY = new FormattedCharSequence[SignText.LINES];
41
42
    static {
43
        Arrays.fill(LIQUIDBOUNCE$EMPTY, FormattedCharSequence.EMPTY);
44
    }
45
46
    @Inject(method = "getRenderMessages", at = @At("HEAD"), cancellable = true)
47
    private void injectNoSignRender(boolean filtered, Function<Component, FormattedCharSequence> messageOrderer, CallbackInfoReturnable<FormattedCharSequence[]> cir) {
48
        if (!ModuleAntiBlind.canRender(DoRender.SIGN_TEXT)) {
49
            cir.setReturnValue(LIQUIDBOUNCE$EMPTY);
50
        }
51
    }
52
53
}
54
MixinSkyRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinSkyRenderer.javaJava · 49 lines · 1.9 KB
@Mixin(SkyRenderer.class)
ModifiesSkyRenderer
MixinSkyRenderer.javaJava · 49 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import net.ccbluex.liquidbounce.features.module.modules.render.customambience.ModuleCustomAmbience;
25
import net.minecraft.client.renderer.SkyRenderer;
26
import net.minecraft.client.renderer.state.level.SkyRenderState;
27
import org.jspecify.annotations.NullMarked;
28
import org.objectweb.asm.Opcodes;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
32
@NullMarked
33
@Mixin(SkyRenderer.class)
34
public abstract class MixinSkyRenderer {
35
36
    @WrapOperation(
37
        method = "extractRenderState",
38
        at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/state/level/SkyRenderState;skyColor:I", opcode = Opcodes.PUTFIELD)
39
    )
40
    private void applyCustomSkyColor(SkyRenderState instance, int value, Operation<Void> original) {
41
        var customSkyColor = ModuleCustomAmbience.SkyColor.INSTANCE;
42
        if (customSkyColor.getRunning()) {
43
            value = customSkyColor.getColor().argb();
44
        }
45
        original.call(instance, value);
46
    }
47
48
}
49
MixinSubmitNodeCollectionsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinSubmitNodeCollection.javaJava · 67 lines · 2.9 KB
@Mixin(SubmitNodeCollection.class)
MixinSubmitNodeCollection.javaJava · 67 lines · 2.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.llamalad7.mixinextras.sugar.Local;
22
import net.ccbluex.liquidbounce.common.StorageEspOutlineContext;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleChams;
24
import net.minecraft.client.renderer.SubmitNodeCollection;
25
import net.minecraft.client.renderer.feature.ItemFeatureRenderer;
26
import net.minecraft.client.renderer.rendertype.RenderType;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
import org.spongepowered.asm.mixin.injection.Inject;
30
import org.spongepowered.asm.mixin.injection.ModifyVariable;
31
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
32
33
@Mixin(SubmitNodeCollection.class)
34
public abstract class MixinSubmitNodeCollection {
35
36
    @ModifyVariable(method = "submitModel", at = @At("HEAD"), argsOnly = true, name = "outlineColor")
37
    private int injectStorageEspGlowOutlineColor(int outlineColor) {
38
        int storageEspOutlineColor = StorageEspOutlineContext.getOutlineColor();
39
        return outlineColor == 0 && storageEspOutlineColor != 0 ? storageEspOutlineColor : outlineColor;
40
    }
41
42
    @ModifyVariable(
43
        method = "submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IIILnet/minecraft/client/renderer/texture/TextureAtlasSprite;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V",
44
        at = @At("HEAD"),
45
        argsOnly = true,
46
        name = "renderType"
47
    )
48
    private RenderType remapHeldItemModelRenderType(RenderType renderType) {
49
        return ModuleChams.INSTANCE.remapCurrentHeldItemRenderTypeIfNeeded(renderType);
50
    }
51
52
    @Inject(
53
        method = "submitItem",
54
        at = @At(
55
            value = "INVOKE",
56
            target = "Lnet/minecraft/client/renderer/feature/ItemFeatureRenderer$Submit;hasTranslucency()Z"
57
        )
58
    )
59
    private void markHeldItemSubmit(
60
        CallbackInfo callbackInfo,
61
        @Local(name = "submit") ItemFeatureRenderer.Submit submit
62
    ) {
63
        ModuleChams.INSTANCE.markHeldItemSubmitIfActive(submit);
64
    }
65
66
}
67
MixinVisGraphsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinVisGraph.javaJava · 38 lines · 1.5 KB
@Mixin(VisGraph.class)
ModifiesVisGraph
MixinVisGraph.javaJava · 38 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay;
22
import net.minecraft.client.renderer.chunk.VisGraph;
23
import net.minecraft.core.BlockPos;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.Inject;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28
29
@Mixin(VisGraph.class)
30
public abstract class MixinVisGraph {
31
    @Inject(method = "setOpaque", at = @At("HEAD"), cancellable = true)
32
    private void onMarkClosed(BlockPos pos, CallbackInfo cir) {
33
        if (ModuleXRay.INSTANCE.getRunning()) {
34
            cir.cancel();
35
        }
36
    }
37
}
38
MixinWeatherEffectRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWeatherEffectRenderer.javaJava · 63 lines · 2.8 KB
@Mixin(WeatherEffectRenderer.class)
MixinWeatherEffectRenderer.javaJava · 63 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import net.ccbluex.liquidbounce.features.module.modules.render.customambience.ModuleCustomAmbience;
23
import net.minecraft.client.renderer.WeatherEffectRenderer;
24
import net.minecraft.world.level.biome.Biome;
25
import org.objectweb.asm.Opcodes;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
29
@Mixin(WeatherEffectRenderer.class)
30
public abstract class MixinWeatherEffectRenderer {
31
32
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getRainLevel(F)F"))
33
    private float ambientPrecipitation2(float original) {
34
        var moduleCustomAmbience = ModuleCustomAmbience.INSTANCE;
35
        if (moduleCustomAmbience.getRunning() && moduleCustomAmbience.getWeather().get() == ModuleCustomAmbience.WeatherType.SNOWY) {
36
            return 0f;
37
        }
38
39
        return original;
40
    }
41
42
    @ModifyExpressionValue(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/state/level/WeatherRenderState;intensity:F", opcode = Opcodes.GETFIELD))
43
    private float modifyPrecipitationGradient(float original) {
44
        var precipitation = ModuleCustomAmbience.Precipitation.INSTANCE;
45
        if (precipitation.getRunning() && original != 0f) {
46
            return precipitation.getGradient();
47
        }
48
49
        return original;
50
    }
51
52
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getPrecipitationAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/biome/Biome$Precipitation;"))
53
    private Biome.Precipitation modifyBiomePrecipitation(Biome.Precipitation original) {
54
        var moduleOverrideWeather = ModuleCustomAmbience.INSTANCE;
55
        if (moduleOverrideWeather.getRunning() && moduleOverrideWeather.getWeather().get() == ModuleCustomAmbience.WeatherType.SNOWY) {
56
            return Biome.Precipitation.SNOW;
57
        }
58
59
        return original;
60
    }
61
62
}
63
MixinWorldBorderRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWorldBorderRenderer.javaJava · 42 lines · 1.7 KB
@Mixin(WorldBorderRenderer.class)
MixinWorldBorderRenderer.javaJava · 42 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.minecraft.client.renderer.WorldBorderRenderer;
25
import net.minecraft.client.renderer.state.level.WorldBorderRenderState;
26
import net.minecraft.world.phys.Vec3;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
import org.spongepowered.asm.mixin.injection.Inject;
30
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31
32
@Mixin(WorldBorderRenderer.class)
33
public abstract class MixinWorldBorderRenderer {
34
35
    @Inject(method = "render", at = @At("HEAD"), cancellable = true)
36
    private void render(WorldBorderRenderState state, Vec3 cameraPos, double viewDistanceBlocks, double farPlaneDistance, CallbackInfo ci) {
37
        if (!ModuleAntiBlind.canRender(DoRender.WORLD_BORDER)) {
38
            ci.cancel();
39
        }
40
    }
41
}
42
MixinBannerRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/blockentity/MixinBannerRenderer.javaJava · 39 lines · 1.9 KB
@Mixin(BannerRenderer.class)
MixinBannerRenderer.javaJava · 39 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.blockentity;
20
21
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleItemChams;
22
import net.ccbluex.liquidbounce.utils.render.FirstPersonShieldTint;
23
import net.minecraft.client.renderer.blockentity.BannerRenderer;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.ModifyArg;
27
28
@Mixin(BannerRenderer.class)
29
public abstract class MixinBannerRenderer {
30
31
    @ModifyArg(method = "submitPatternLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/OrderedSubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IIILnet/minecraft/client/renderer/texture/TextureAtlasSprite;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"), index = 6)
32
    private static int hookFirstPersonShieldPatternTint(int tintedColor) {
33
        return FirstPersonShieldTint.isRendering()
34
            ? ModuleItemChams.Shield.INSTANCE.applyTint(tintedColor)
35
            : tintedColor;
36
    }
37
38
}
39
MixinBeaconRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/blockentity/MixinBeaconRenderer.javaJava · 45 lines · 1.8 KB
@Mixin(BeaconRenderer.class)
MixinBeaconRenderer.javaJava · 45 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.blockentity;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.minecraft.client.renderer.blockentity.BeaconRenderer;
25
import net.minecraft.world.level.block.entity.BeaconBeamOwner;
26
import net.minecraft.world.level.block.entity.BlockEntity;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
import org.spongepowered.asm.mixin.injection.Inject;
30
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31
32
@Mixin(BeaconRenderer.class)
33
public abstract class MixinBeaconRenderer<T extends BlockEntity & BeaconBeamOwner> {
34
    @Inject(
35
            method = "submit*",
36
            at = @At("HEAD"),
37
            cancellable = true
38
    )
39
    private void hookRenderBeaconBlock(CallbackInfo ci) {
40
        if (!ModuleAntiBlind.canRender(DoRender.BEACON_BEAMS)) {
41
            ci.cancel();
42
        }
43
    }
44
}
45
MixinBlockEntityRenderDispatchersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/blockentity/MixinBlockEntityRenderDispatcher.javaJava · 74 lines · 3.3 KB
@Mixin(BlockEntityRenderDispatcher.class)
MixinBlockEntityRenderDispatcher.javaJava · 74 lines · 3.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.blockentity;
20
21
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
22
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
23
import com.mojang.blaze3d.vertex.PoseStack;
24
import net.ccbluex.liquidbounce.common.StorageEspOutlineContext;
25
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleStorageESP;
26
import net.ccbluex.liquidbounce.render.engine.type.Color4b;
27
import net.minecraft.client.Minecraft;
28
import net.minecraft.client.renderer.SubmitNodeCollector;
29
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
30
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
31
import net.minecraft.client.renderer.blockentity.state.BlockEntityRenderState;
32
import net.minecraft.client.renderer.state.level.CameraRenderState;
33
import org.spongepowered.asm.mixin.Mixin;
34
import org.spongepowered.asm.mixin.injection.At;
35
36
@Mixin(BlockEntityRenderDispatcher.class)
37
public abstract class MixinBlockEntityRenderDispatcher {
38
39
    /**
40
     * Inject StorageESP glow effect
41
     *
42
     * @author 1zuna
43
     */
44
    @WrapOperation(
45
            method = "submit",
46
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderer;submit(Lnet/minecraft/client/renderer/blockentity/state/BlockEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V")
47
    )
48
    private <S extends BlockEntityRenderState> void injectStorageEspGlow(
49
        BlockEntityRenderer<?, S> renderer, S state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector,
50
        CameraRenderState camera, Operation<Void> original
51
    ) {
52
        Color4b outlineColor = Color4b.TRANSPARENT;
53
        var client = Minecraft.getInstance();
54
        if (ModuleStorageESP.GlowMode.INSTANCE.getRunning() && client.level != null) {
55
            var type = ModuleStorageESP.categorize(client.level.getBlockEntity(state.blockPos));
56
57
            if (type != null && type.shouldRender(state.blockPos)) {
58
                var color = type.getColor();
59
60
                if (!color.isTransparent()) {
61
                    outlineColor = color;
62
                }
63
            }
64
        }
65
66
        if (outlineColor.isTransparent()) {
67
            original.call(renderer, state, poseStack, submitNodeCollector, camera);
68
        } else {
69
            StorageEspOutlineContext.render(outlineColor.argb(), () -> original.call(renderer, state, poseStack, submitNodeCollector, camera));
70
        }
71
    }
72
73
}
74
MixinSpawnerRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/blockentity/MixinSpawnerRenderer.javaJava · 42 lines · 1.8 KB
@Mixin(SpawnerRenderer.class)
MixinSpawnerRenderer.javaJava · 42 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.blockentity;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.minecraft.client.renderer.blockentity.SpawnerRenderer;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
30
@Mixin(SpawnerRenderer.class)
31
public abstract class MixinSpawnerRenderer {
32
    @Inject(
33
        method = "submit(Lnet/minecraft/client/renderer/blockentity/state/SpawnerRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
34
            at = @At("HEAD"),
35
            cancellable = true
36
    ) private void onRender(CallbackInfo ci) {
37
        if (!ModuleAntiBlind.canRender(DoRender.MOB_IN_SPAWNER)) {
38
            ci.cancel();
39
        }
40
    }
41
}
42
MixinArmedEntityRenderStatesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/MixinArmedEntityRenderState.javaJava · 56 lines · 2.3 KB
@Mixin(ArmedEntityRenderState.class)
MixinArmedEntityRenderState.javaJava · 56 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import com.llamalad7.mixinextras.sugar.Local;
25
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleSwordBlock;
26
import net.minecraft.client.Minecraft;
27
import net.minecraft.client.renderer.entity.state.ArmedEntityRenderState;
28
import net.minecraft.world.entity.HumanoidArm;
29
import net.minecraft.world.entity.LivingEntity;
30
import net.minecraft.world.item.ItemStack;
31
import org.jspecify.annotations.NullMarked;
32
import org.spongepowered.asm.mixin.Mixin;
33
import org.spongepowered.asm.mixin.injection.At;
34
35
@NullMarked
36
@Mixin(ArmedEntityRenderState.class)
37
public abstract class MixinArmedEntityRenderState {
38
39
    @WrapOperation(
40
        method = "extractArmedEntityRenderState",
41
        at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getItemHeldByArm(Lnet/minecraft/world/entity/HumanoidArm;)Lnet/minecraft/world/item/ItemStack;")
42
    )
43
    private static ItemStack hideOffhandShield(LivingEntity entity, HumanoidArm arm, Operation<ItemStack> original, @Local(argsOnly = true, name = "state") ArmedEntityRenderState reusedState) {
44
        if (entity == Minecraft.getInstance().player
45
            && ModuleSwordBlock.INSTANCE.getApplyToThirdPersonView()
46
            && ModuleSwordBlock.INSTANCE.shouldHideOffhand()
47
            && arm != reusedState.mainArm
48
        ) {
49
            return ItemStack.EMPTY;
50
        }
51
52
        return original.call(entity, arm);
53
    }
54
55
}
56
MixinAvatarRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/MixinAvatarRenderer.javaJava · 62 lines · 2.6 KB
@Mixin(AvatarRenderer.class)
MixinAvatarRenderer.javaJava · 62 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity;
20
21
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleSwordBlock;
22
import net.minecraft.client.Minecraft;
23
import net.minecraft.client.model.HumanoidModel;
24
import net.minecraft.client.player.LocalPlayer;
25
import net.minecraft.client.renderer.entity.player.AvatarRenderer;
26
import net.minecraft.world.InteractionHand;
27
import net.minecraft.world.entity.Avatar;
28
import net.minecraft.world.item.ItemStack;
29
import org.jspecify.annotations.NullMarked;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.injection.At;
32
import org.spongepowered.asm.mixin.injection.Inject;
33
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
34
35
@NullMarked
36
@Mixin(AvatarRenderer.class)
37
public abstract class MixinAvatarRenderer {
38
39
    @Inject(method = "getArmPose(Lnet/minecraft/world/entity/Avatar;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/client/model/HumanoidModel$ArmPose;", at = @At("HEAD"), cancellable = true)
40
    private static void injectArmPose(
41
        Avatar player, ItemStack stack, InteractionHand hand, CallbackInfoReturnable<HumanoidModel.ArmPose> cir) {
42
        LocalPlayer localPlayer = Minecraft.getInstance().player;
43
        if (player == localPlayer
44
            && ModuleSwordBlock.INSTANCE.getApplyToThirdPersonView()
45
        ) {
46
            switch (hand) {
47
                case MAIN_HAND -> {
48
                    if (ModuleSwordBlock.shouldAnimateSwordBlock(localPlayer, stack)) {
49
                        cir.setReturnValue(HumanoidModel.ArmPose.BLOCK);
50
                    }
51
                }
52
                case OFF_HAND -> {
53
                    if (ModuleSwordBlock.INSTANCE.shouldHideOffhand()) {
54
                        cir.setReturnValue(HumanoidModel.ArmPose.EMPTY);
55
                    }
56
                }
57
            }
58
        }
59
    }
60
61
}
62
MixinEndCrystalRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/MixinEndCrystalRenderer.javaJava · 46 lines · 2.1 KB
@Mixin(EndCrystalRenderer.class)
MixinEndCrystalRenderer.javaJava · 46 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity;
20
21
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
22
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
23
import com.mojang.blaze3d.vertex.PoseStack;
24
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleCrystalView;
25
import net.minecraft.client.renderer.entity.EndCrystalRenderer;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
29
@Mixin(EndCrystalRenderer.class)
30
public abstract class MixinEndCrystalRenderer {
31
32
    @WrapOperation(method = "submit(Lnet/minecraft/client/renderer/entity/state/EndCrystalRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;scale(FFF)V"))
33
    public void injectScale(PoseStack instance, float x, float y, float z, Operation<Void> original) {
34
        var crystalView = ModuleCrystalView.INSTANCE;
35
        if (crystalView.getRunning()) {
36
            x *= crystalView.getSize();
37
            y *= crystalView.getSize();
38
            z *= crystalView.getSize();
39
            instance.translate(0f, crystalView.getYTranslate(), 0f);
40
        }
41
42
        original.call(instance, x, y, z);
43
    }
44
45
}
46
MixinEntityRenderStatesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/MixinEntityRenderState.javaJava · 58 lines · 1.8 KB
@Mixin(EntityRenderState.class)
MixinEntityRenderState.javaJava · 58 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity;
20
21
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition;
22
import net.minecraft.client.renderer.entity.state.EntityRenderState;
23
import net.minecraft.world.entity.Entity;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.Unique;
26
27
@Mixin(EntityRenderState.class)
28
public abstract class MixinEntityRenderState implements EntityRenderStateAddition {
29
30
    @Unique
31
    private Entity liquid_bounce$entity;
32
33
    @Unique
34
    private boolean liquid_bounce$isCustom = false;
35
36
    @Unique
37
    @Override
38
    public void liquid_bounce$setEntity(Entity entity) {
39
        this.liquid_bounce$entity = entity;
40
    }
41
42
    @Unique
43
    @Override
44
    public Entity liquid_bounce$getEntity() {
45
        return liquid_bounce$entity;
46
    }
47
48
    @Override
49
    public boolean liquid_bounce$isCustom() {
50
        return liquid_bounce$isCustom;
51
    }
52
53
    @Override
54
    public void liquid_bounce$setCustom(boolean custom) {
55
        liquid_bounce$isCustom = custom;
56
    }
57
}
58
MixinEntityRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/MixinEntityRenderer.javaJava · 187 lines · 9.5 KB
@Mixin(EntityRenderer.class)
MixinEntityRenderer.javaJava · 187 lines · 9.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
23
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
24
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
25
import com.llamalad7.mixinextras.sugar.Local;
26
import com.mojang.blaze3d.vertex.PoseStack;
27
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleAntiExploit;
28
import net.ccbluex.liquidbounce.features.module.modules.render.*;
29
import net.ccbluex.liquidbounce.features.module.modules.render.esp.ModuleESP;
30
import net.ccbluex.liquidbounce.features.module.modules.render.esp.modes.EspGlowMode;
31
import net.ccbluex.liquidbounce.features.module.modules.render.nametags.ModuleNametags;
32
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition;
33
import net.ccbluex.liquidbounce.render.engine.type.Color4b;
34
import net.ccbluex.liquidbounce.utils.combat.CombatExtensionsKt;
35
import net.minecraft.client.Minecraft;
36
import net.minecraft.client.gui.Font;
37
import net.minecraft.client.renderer.SubmitNodeCollector;
38
import net.minecraft.client.renderer.culling.Frustum;
39
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
40
import net.minecraft.client.renderer.entity.EntityRenderer;
41
import net.minecraft.client.renderer.entity.state.EntityRenderState;
42
import net.minecraft.client.renderer.state.level.CameraRenderState;
43
import net.minecraft.network.chat.Component;
44
import net.minecraft.util.FormattedCharSequence;
45
import net.minecraft.world.entity.Entity;
46
import net.minecraft.world.entity.LivingEntity;
47
import net.minecraft.world.entity.item.FallingBlockEntity;
48
import net.minecraft.world.entity.item.PrimedTnt;
49
import net.minecraft.world.phys.Vec3;
50
import org.spongepowered.asm.mixin.Final;
51
import org.spongepowered.asm.mixin.Mixin;
52
import org.spongepowered.asm.mixin.Shadow;
53
import org.spongepowered.asm.mixin.Unique;
54
import org.spongepowered.asm.mixin.injection.At;
55
import org.spongepowered.asm.mixin.injection.Inject;
56
import org.spongepowered.asm.mixin.injection.ModifyArg;
57
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
58
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
59
60
@Mixin(EntityRenderer.class)
61
public abstract class MixinEntityRenderer<T extends Entity, S extends EntityRenderState> {
62
63
    @Shadow
64
    @Final
65
    protected EntityRenderDispatcher entityRenderDispatcher;
66
67
    @Shadow
68
    public abstract Font getFont();
69
70
    @Inject(method = "shouldRender", at = @At("HEAD"), cancellable = true)
71
    private void shouldRender(T entity, Frustum frustum, double x, double y, double z, CallbackInfoReturnable<Boolean> cir) {
72
        if (ModuleCombineMobs.INSTANCE.getRunning() && ModuleCombineMobs.INSTANCE.trackEntity(entity)) {
73
            cir.setReturnValue(false);
74
        }
75
76
        if (entity instanceof FallingBlockEntity && !ModuleAntiBlind.canRender(DoRender.FALLING_BLOCKS)) {
77
            cir.setReturnValue(false);
78
        }
79
    }
80
81
    @Inject(method = "submit", at = @At("HEAD"))
82
    private void renderMobOwners(S state, PoseStack matrices, SubmitNodeCollector queue, CameraRenderState cameraState, CallbackInfo ci) {
83
        var entity = ((EntityRenderStateAddition) state).liquid_bounce$getEntity();
84
        var ownerName = ModuleMobOwners.INSTANCE.getOwnerInfoText(entity);
85
86
        if (ownerName != null) {
87
            renderLabel(entity, ownerName, matrices, queue, state.lightCoords);
88
        }
89
    }
90
91
    @SuppressWarnings("unused")
92
    @Unique
93
    private void renderLabel(
94
        Entity entity, FormattedCharSequence text,
95
        PoseStack matrices, SubmitNodeCollector queue, int light
96
    ) {
97
        var d = this.entityRenderDispatcher.distanceToSqr(entity);
98
99
        if (d > 4096.0) {
100
            return;
101
        }
102
103
        var f = entity.getBbHeight() / 2.0F;
104
105
        matrices.pushPose();
106
        matrices.translate(0.0D, f, 0.0D);
107
        matrices.mulPose(this.entityRenderDispatcher.camera.rotation());
108
        matrices.scale(-0.025F, -0.025F, 0.025F);
109
110
        var matrix4f = matrices.last().pose();
111
112
        var g = Minecraft.getInstance().options.getBackgroundOpacity(0.25F);
113
        var j = (int) (g * 255.0F) << 24;
114
        var textRenderer = this.getFont();
115
        var h = (float) (-textRenderer.width(text) / 2);
116
        queue.submitText(
117
            matrices, h,
118
            0, text,
119
            true, Font.DisplayMode.NORMAL,
120
            light, -1,
121
            Color4b.BLACK.argb(), -1
122
        );
123
        matrices.popPose();
124
    }
125
126
    @WrapWithCondition(method = "submitNameDisplay(Lnet/minecraft/client/renderer/entity/state/EntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitNameTag(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/phys/Vec3;ILnet/minecraft/network/chat/Component;ZILnet/minecraft/client/renderer/state/level/CameraRenderState;)V"))
127
    private boolean disableVanillaNametag(SubmitNodeCollector instance, PoseStack poseStack, Vec3 vec3, int i, Component component, boolean b, int j, CameraRenderState cameraRenderState, @Local(argsOnly = true, name = "state") S state) {
128
        return ModuleNametags.INSTANCE.shouldRenderVanillaNametag(state);
129
    }
130
131
    @ModifyArg(method = "submitNameDisplay(Lnet/minecraft/client/renderer/entity/state/EntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitNameTag(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/phys/Vec3;ILnet/minecraft/network/chat/Component;ZILnet/minecraft/client/renderer/state/level/CameraRenderState;)V"), index = 3)
132
    private Component sanitizeNametagText(Component component) {
133
        var sanitized = ModuleAntiExploit.INSTANCE.unobfuscateIfNeeded(component);
134
        return sanitized != null ? sanitized : component;
135
    }
136
137
    @Inject(method = "extractRenderState", at = @At("HEAD"))
138
    private void hookInjectEntityIntoState(T entity, S state, float tickDelta, CallbackInfo ci) {
139
        ((EntityRenderStateAddition) state).liquid_bounce$setEntity(entity);
140
    }
141
142
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;shouldEntityAppearGlowing(Lnet/minecraft/world/entity/Entity;)Z"))
143
    private boolean modifyShouldRenderOutline(boolean original, @Local(argsOnly = true, name = "entity") Entity entity) {
144
        return original || liquid_bounce$shouldRenderOutline(entity);
145
    }
146
147
    @Unique
148
    private static boolean liquid_bounce$shouldRenderOutline(Entity entity) {
149
        if (ModuleItemESP.GlowMode.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.shouldRender(entity)) {
150
            return true;
151
        } else if (EspGlowMode.INSTANCE.getRunning() && CombatExtensionsKt.shouldBeShown(entity) && EspGlowMode.INSTANCE.shouldRender(entity)) {
152
            return true;
153
        } else if (ModuleTNTTimer.INSTANCE.getRunning() && ModuleTNTTimer.INSTANCE.getEsp() && entity instanceof PrimedTnt) {
154
            return true;
155
        } else if (ModuleStorageESP.GlowMode.INSTANCE.getRunning()) {
156
            var category = ModuleStorageESP.categorize(entity);
157
            return category != null && category.shouldRender(entity);
158
        } else {
159
            return false;
160
        }
161
    }
162
163
    /**
164
     * Inject ESP color as glow color
165
     *
166
     * @author 1zuna
167
     */
168
    @WrapOperation(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getTeamColor()I"))
169
    private int injectTeamColor(Entity entity, Operation<Integer> operation) {
170
        if (entity instanceof LivingEntity livingEntity && EspGlowMode.INSTANCE.getRunning() && EspGlowMode.INSTANCE.shouldRender(livingEntity)) {
171
            return ModuleESP.INSTANCE.getColor(livingEntity).argb();
172
        } else if (ModuleItemESP.GlowMode.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.shouldRender(entity)) {
173
            return ModuleItemESP.INSTANCE.getColor().argb();
174
        } else if (entity instanceof PrimedTnt tntEntity && ModuleTNTTimer.INSTANCE.getRunning() && ModuleTNTTimer.INSTANCE.getEsp()) {
175
            return ModuleTNTTimer.INSTANCE.getTntColor(tntEntity.getFuse()).argb();
176
        } else if (ModuleStorageESP.GlowMode.INSTANCE.getRunning()) {
177
            var category = ModuleStorageESP.categorize(entity);
178
            if (category != null && category.shouldRender(entity)) {
179
                return category.getColor().argb();
180
            }
181
        }
182
183
        return operation.call(entity);
184
    }
185
186
}
187
MixinLivingEntityRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/MixinLivingEntityRenderer.javaJava · 207 lines · 10.1 KB
@Mixin(LivingEntityRenderer.class)
MixinLivingEntityRenderer.javaJava · 207 lines · 10.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
24
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
25
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
26
import com.llamalad7.mixinextras.sugar.Local;
27
import com.mojang.blaze3d.vertex.PoseStack;
28
import kotlin.Pair;
29
import net.ccbluex.liquidbounce.api.models.cosmetics.CosmeticCategory;
30
import net.ccbluex.liquidbounce.features.cosmetic.CosmeticService;
31
import net.ccbluex.liquidbounce.features.module.modules.render.*;
32
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition;
33
import net.ccbluex.liquidbounce.render.engine.type.Color4b;
34
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation;
35
import net.minecraft.client.Minecraft;
36
import net.minecraft.client.model.EntityModel;
37
import net.minecraft.client.model.Model;
38
import net.minecraft.client.player.AbstractClientPlayer;
39
import net.minecraft.client.renderer.SubmitNodeCollector;
40
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
41
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
42
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
43
import net.minecraft.client.renderer.rendertype.RenderType;
44
import net.minecraft.client.renderer.rendertype.RenderTypes;
45
import net.minecraft.client.renderer.state.level.CameraRenderState;
46
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
47
import net.minecraft.resources.Identifier;
48
import net.minecraft.util.Mth;
49
import net.minecraft.world.entity.Entity;
50
import net.minecraft.world.entity.LivingEntity;
51
import org.jspecify.annotations.Nullable;
52
import org.jspecify.annotations.NullMarked;
53
import org.spongepowered.asm.mixin.Mixin;
54
import org.spongepowered.asm.mixin.Shadow;
55
import org.spongepowered.asm.mixin.Unique;
56
import org.spongepowered.asm.mixin.injection.At;
57
import org.spongepowered.asm.mixin.injection.Inject;
58
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
59
60
@NullMarked
61
@Mixin(LivingEntityRenderer.class)
62
public abstract class MixinLivingEntityRenderer<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> {
63
64
    @Unique
65
    private static final int ESP_TRUE_SIGHT_REQUIREMENT_COLOR = new Color4b(255, 255, 255, 100).argb();
66
67
    @Shadow
68
    public abstract Identifier getTextureLocation(S state);
69
70
    @Unique
71
    private @Nullable Pair<Rotation, Rotation> getOverwriteRotation(ModuleRotations.BodyPart bodyPart) {
72
        if (ModuleRotations.INSTANCE.getRunning() && ModuleRotations.INSTANCE.isPartAllowed(bodyPart)) {
73
            var rotation = ModuleRotations.INSTANCE.getModelRotation();
74
            var prevRotation = ModuleRotations.INSTANCE.getPrevModelRotation();
75
76
            if (rotation != null && prevRotation != null) {
77
                return new Pair<>(prevRotation, rotation);
78
            }
79
        }
80
81
        return null;
82
    }
83
84
    @ModifyExpressionValue(method = "extractRenderState(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/LivingEntityRenderer;solveBodyRot(Lnet/minecraft/world/entity/LivingEntity;FF)F"))
85
    private float hookBodyYaw(float original, LivingEntity entity, S state, float tickDelta) {
86
        if (entity != Minecraft.getInstance().player) {
87
            return original;
88
        }
89
90
        var overwriteRotation = getOverwriteRotation(ModuleRotations.BodyPart.BODY);
91
        if (overwriteRotation != null) {
92
            return Mth.rotLerp(tickDelta, overwriteRotation.getFirst().yRot(), overwriteRotation.getSecond().yRot());
93
        }
94
95
        return original;
96
    }
97
98
    @ModifyExpressionValue(method = "extractRenderState(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;rotLerp(FFF)F"))
99
    private float hookHeadYaw(float original, LivingEntity entity, S state, float tickDelta) {
100
        if (entity != Minecraft.getInstance().player) {
101
            return original;
102
        }
103
104
        var overwriteRotation = getOverwriteRotation(ModuleRotations.BodyPart.HEAD);
105
        if (overwriteRotation != null) {
106
            return Mth.rotLerp(tickDelta, overwriteRotation.getFirst().yRot(), overwriteRotation.getSecond().yRot());
107
        }
108
109
        return original;
110
    }
111
112
    @ModifyExpressionValue(method = "extractRenderState(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getXRot(F)F"))
113
    private float hookPitch(float original, LivingEntity entity, S state, float tickDelta) {
114
        if (entity != Minecraft.getInstance().player) {
115
            return original;
116
        }
117
118
        var overwriteRotation = getOverwriteRotation(ModuleRotations.BodyPart.HEAD);
119
        if (overwriteRotation != null) {
120
            return Mth.rotLerp(tickDelta, overwriteRotation.getFirst().xRot(), overwriteRotation.getSecond().xRot());
121
        }
122
123
        return original;
124
    }
125
126
    @WrapOperation(method = "submit(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IIILnet/minecraft/client/renderer/texture/TextureAtlasSprite;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"))
127
    private void injectTrueSight(
128
        SubmitNodeCollector instance, Model<M> model,
129
        Object o, PoseStack matrixStack,
130
        RenderType renderLayer, int light,
131
        int overlay, int tintedColor,
132
        TextureAtlasSprite sprite, int outlineColor,
133
        ModelFeatureRenderer.CrumblingOverlay crumblingOverlayCommand, Operation<Void> original,
134
        @Local(argsOnly = true, name = "state") S state
135
    ) {
136
        if (ModuleLogoffSpot.INSTANCE.isLogoffEntity(state)) {
137
            tintedColor = ESP_TRUE_SIGHT_REQUIREMENT_COLOR;
138
        }
139
140
        var trueSightModule = ModuleTrueSight.INSTANCE;
141
        var trueSight = trueSightModule.getRunning() && trueSightModule.getEntities();
142
        if (ModuleTrueSight.canRenderEntities(state)) {
143
            tintedColor = trueSight ? trueSightModule.getEntityColor().argb() : ESP_TRUE_SIGHT_REQUIREMENT_COLOR;
144
        }
145
        original.call(
146
            instance, model,
147
            o, matrixStack,
148
            renderLayer, light,
149
            overlay, tintedColor,
150
            sprite, outlineColor,
151
            crumblingOverlayCommand
152
        );
153
    }
154
155
    @ModifyReturnValue(method = "getRenderType", at = @At("RETURN"))
156
    private RenderType injectTrueSight(RenderType original, S state, boolean showBody, boolean translucent, boolean showOutline) {
157
        if (ModuleLogoffSpot.INSTANCE.isLogoffEntity(state)) {
158
            return RenderTypes.entityTranslucentCullItemTarget(this.getTextureLocation(state));
159
        }
160
161
        if (ModuleTrueSight.canRenderEntities(state) && !showBody && !translucent && !showOutline) {
162
            state.isInvisible = false;
163
            return RenderTypes.entityTranslucentCullItemTarget(this.getTextureLocation(state));
164
        }
165
        return original;
166
    }
167
168
    @ModifyReturnValue(method = "isEntityUpsideDown(Lnet/minecraft/world/entity/LivingEntity;)Z", at = @At("RETURN"))
169
    private static boolean injectShouldFlipUpsideDown(boolean original, LivingEntity entity) {
170
        if (!(entity instanceof AbstractClientPlayer)) {
171
            return original;
172
        }
173
174
        return original || CosmeticService.INSTANCE.hasCosmetic(entity.getUUID(), CosmeticCategory.DINNERBONE);
175
    }
176
177
    // Chams
178
179
    @ModifyExpressionValue(
180
        method = "getRenderType",
181
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/EntityModel;renderType(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;")
182
    )
183
    private @Nullable RenderType render_Chams(
184
        @Nullable RenderType original,
185
        @Local(argsOnly = true, name = "state") S state
186
    ) {
187
        if (original == null) return null;
188
189
        var entity = ((EntityRenderStateAddition) state).liquid_bounce$getEntity();
190
        return ModuleChams.INSTANCE.remapIfNeeded(original, entity);
191
    }
192
193
    // FreeCam
194
    @ModifyExpressionValue(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getCameraEntity()Lnet/minecraft/world/entity/Entity;"))
195
    private @Nullable Entity hasLabelGetCameraEntityProxy(@Nullable Entity cameraEntity) {
196
        return ModuleFreeCam.INSTANCE.getRunning() ? null : cameraEntity;
197
    }
198
199
    // AntiBlind
200
    @Inject(method = "submit", at = @At("HEAD"), cancellable = true)
201
    private void hideInvisibleEntities(S state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera, CallbackInfo ci) {
202
        if (state.isInvisible && !ModuleAntiBlind.canRender(DoRender.INVISIBLE_ENTITIES)) {
203
            ci.cancel();
204
        }
205
    }
206
}
207
MixinCapeLayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/feature/MixinCapeLayer.javaJava · 52 lines · 2.3 KB
@Mixin(CapeLayer.class)
ModifiesCapeLayer
MixinCapeLayer.javaJava · 52 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity.feature;
21
22
import com.llamalad7.mixinextras.sugar.Local;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleChams;
24
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition;
25
import net.minecraft.client.renderer.entity.layers.CapeLayer;
26
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
27
import net.minecraft.client.renderer.rendertype.RenderType;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.injection.At;
30
import org.spongepowered.asm.mixin.injection.ModifyArg;
31
32
@Mixin(CapeLayer.class)
33
public abstract class MixinCapeLayer {
34
35
    @ModifyArg(
36
        method = "submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V",
37
        at = @At(
38
            value = "INVOKE",
39
            target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IIILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"
40
        ),
41
        index = 3
42
    )
43
    private RenderType renderCapeWithChams(
44
        RenderType renderType,
45
        @Local(argsOnly = true, name = "state") AvatarRenderState state
46
    ) {
47
        var entity = ((EntityRenderStateAddition) state).liquid_bounce$getEntity();
48
        return ModuleChams.INSTANCE.remapIfNeeded(renderType, entity);
49
    }
50
51
}
52
MixinDeadmau5EarsLayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/feature/MixinDeadmau5EarsLayer.javaJava · 45 lines · 2.3 KB
@Mixin(Deadmau5EarsLayer.class)
MixinDeadmau5EarsLayer.javaJava · 45 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity.feature;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.sugar.Local;
23
import net.ccbluex.liquidbounce.api.models.cosmetics.CosmeticCategory;
24
import net.ccbluex.liquidbounce.features.cosmetic.CosmeticService;
25
import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
26
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition;
27
import net.minecraft.client.renderer.entity.layers.Deadmau5EarsLayer;
28
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
29
import org.objectweb.asm.Opcodes;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.injection.At;
32
33
@Mixin(Deadmau5EarsLayer.class)
34
public abstract class MixinDeadmau5EarsLayer {
35
36
    @ModifyExpressionValue(method = "submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/entity/state/AvatarRenderState;showExtraEars:Z", remap = false, opcode = Opcodes.GETFIELD))
37
    private boolean onRender(boolean original, @Local(argsOnly = true, name = "state") AvatarRenderState playerEntityRenderState) {
38
        if (original || SelfDestruct.INSTANCE.isDestructed()) return original;
39
40
        var entity = ((EntityRenderStateAddition) playerEntityRenderState).liquid_bounce$getEntity();
41
        return entity != null && CosmeticService.INSTANCE.hasCosmetic(entity.getUUID(), CosmeticCategory.DEADMAU5_EARS);
42
    }
43
44
}
45
MixinEquipmentLayerRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/feature/MixinEquipmentLayerRenderer.javaJava · 56 lines · 2.7 KB
@Mixin(EquipmentLayerRenderer.class)
MixinEquipmentLayerRenderer.javaJava · 56 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity.feature;
21
22
import com.llamalad7.mixinextras.sugar.Local;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleChams;
24
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition;
25
import net.minecraft.client.renderer.entity.layers.EquipmentLayerRenderer;
26
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
27
import net.minecraft.client.renderer.rendertype.RenderType;
28
import net.minecraft.world.entity.Entity;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.ModifyArg;
32
33
@Mixin(EquipmentLayerRenderer.class)
34
public abstract class MixinEquipmentLayerRenderer {
35
36
    @ModifyArg(
37
        method = "renderLayers(Lnet/minecraft/client/resources/model/EquipmentClientInfo$LayerType;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/world/item/ItemStack;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/resources/Identifier;II)V",
38
        at = @At(
39
            value = "INVOKE",
40
            target = "Lnet/minecraft/client/renderer/OrderedSubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IIILnet/minecraft/client/renderer/texture/TextureAtlasSprite;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"
41
        ),
42
        index = 3
43
    )
44
    private <S> RenderType renderArmorWithChams(
45
        RenderType renderType,
46
        @Local(argsOnly = true, name = "state") S state
47
    ) {
48
        if (state instanceof LivingEntityRenderState livingState) {
49
            Entity entity = ((EntityRenderStateAddition) livingState).liquid_bounce$getEntity();
50
            return ModuleChams.INSTANCE.remapIfNeeded(renderType, entity);
51
        }
52
53
        return renderType;
54
    }
55
}
56
MixinItemInHandLayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/feature/MixinItemInHandLayer.javaJava · 59 lines · 2.5 KB
@Mixin(ItemInHandLayer.class)
MixinItemInHandLayer.javaJava · 59 lines · 2.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity.feature;
20
21
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
22
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import com.mojang.blaze3d.vertex.PoseStack;
25
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleChams;
26
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition;
27
import net.minecraft.client.renderer.SubmitNodeCollector;
28
import net.minecraft.client.renderer.entity.layers.ItemInHandLayer;
29
import net.minecraft.client.renderer.entity.state.ArmedEntityRenderState;
30
import net.minecraft.client.renderer.item.ItemStackRenderState;
31
import org.spongepowered.asm.mixin.Mixin;
32
import org.spongepowered.asm.mixin.injection.At;
33
34
@Mixin(ItemInHandLayer.class)
35
public abstract class MixinItemInHandLayer {
36
37
    @WrapOperation(
38
        method = "submitArmWithItem",
39
        at = @At(
40
            value = "INVOKE",
41
            target = "Lnet/minecraft/client/renderer/item/ItemStackRenderState;submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;III)V"
42
        )
43
    )
44
    private void trackHeldItemEntityContext(
45
        ItemStackRenderState instance,
46
        PoseStack poseStack,
47
        SubmitNodeCollector submitNodeCollector,
48
        int lightCoords,
49
        int overlayCoords,
50
        int outlineColor,
51
        Operation<Void> original,
52
        @Local(argsOnly = true, name = "state") ArmedEntityRenderState state
53
    ) {
54
        ModuleChams.INSTANCE.withHeldItemContext(((EntityRenderStateAddition) state).liquid_bounce$getEntity(),
55
            () -> original.call(instance, poseStack, submitNodeCollector, lightCoords, overlayCoords, outlineColor));
56
    }
57
58
}
59
MixinRenderLayersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/feature/MixinRenderLayer.javaJava · 93 lines · 4.4 KB
@Mixin(RenderLayer.class)
ModifiesRenderLayer
MixinRenderLayer.javaJava · 93 lines · 4.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity.feature;
21
22
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
24
import com.llamalad7.mixinextras.sugar.Local;
25
import com.mojang.blaze3d.vertex.PoseStack;
26
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleLogoffSpot;
27
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleTrueSight;
28
import net.ccbluex.liquidbounce.render.engine.type.Color4b;
29
import net.minecraft.client.model.Model;
30
import net.minecraft.client.renderer.OrderedSubmitNodeCollector;
31
import net.minecraft.client.renderer.entity.layers.RenderLayer;
32
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
33
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
34
import net.minecraft.client.renderer.rendertype.RenderType;
35
import net.minecraft.client.renderer.rendertype.RenderTypes;
36
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
37
import net.minecraft.resources.Identifier;
38
import org.spongepowered.asm.mixin.Mixin;
39
import org.spongepowered.asm.mixin.Unique;
40
import org.spongepowered.asm.mixin.injection.At;
41
42
@Mixin(RenderLayer.class)
43
public abstract class MixinRenderLayer {
44
45
    @Unique
46
    private static final int ESP_TRUE_SIGHT_REQUIREMENT_COLOR = new Color4b(255, 255, 255, 120).argb();
47
48
    @WrapOperation(method = "renderColoredCutoutModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/OrderedSubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IIILnet/minecraft/client/renderer/texture/TextureAtlasSprite;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"))
49
    private static <S> void injectTrueSight(
50
        OrderedSubmitNodeCollector instance,
51
        Model<? super S> model,
52
        S state,
53
        PoseStack matrices,
54
        RenderType renderLayer,
55
        int light,
56
        int overlay,
57
        int tintedColor,
58
        TextureAtlasSprite sprite,
59
        int outlineColor,
60
        ModelFeatureRenderer.CrumblingOverlay crumblingOverlay,
61
        Operation<Void> original
62
    ) {
63
        if (state instanceof LivingEntityRenderState rs) {
64
            var trueSightModule = ModuleTrueSight.INSTANCE;
65
            var trueSight = trueSightModule.getRunning() && trueSightModule.getEntities();
66
            if (ModuleTrueSight.canRenderEntities(rs)) {
67
                tintedColor = trueSight ? trueSightModule.getEntityFeatureLayerColor().argb() : ESP_TRUE_SIGHT_REQUIREMENT_COLOR;
68
            }
69
            if (ModuleLogoffSpot.INSTANCE.isLogoffEntity(rs)) {
70
                tintedColor = ESP_TRUE_SIGHT_REQUIREMENT_COLOR;
71
            }
72
        }
73
        original.call(
74
            instance, model,
75
            state, matrices,
76
            renderLayer, light,
77
            overlay, tintedColor,
78
            sprite, outlineColor,
79
            crumblingOverlay
80
        );
81
    }
82
83
    @WrapOperation(method = "renderColoredCutoutModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/rendertype/RenderTypes;entityCutout(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;"))
84
    private static RenderType injectTrueSight(
85
        Identifier texture, Operation<RenderType> original, @Local(argsOnly = true, name = "state") LivingEntityRenderState state) {
86
        if (ModuleTrueSight.canRenderEntities(state) || ModuleLogoffSpot.INSTANCE.isLogoffEntity(state)) {
87
            return RenderTypes.entityTranslucentCullItemTarget(texture);
88
        }
89
        return original.call(texture);
90
    }
91
92
}
93
MixinFogRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/fog/MixinFogRenderer.javaJava · 54 lines · 2.3 KB
@Mixin(FogRenderer.class)
ModifiesFogRenderer
MixinFogRenderer.javaJava · 54 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.fog;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.customambience.ModuleCustomAmbience;
23
import net.minecraft.client.Camera;
24
import net.minecraft.client.multiplayer.ClientLevel;
25
import net.minecraft.client.renderer.fog.FogData;
26
import net.minecraft.client.renderer.fog.FogRenderer;
27
import org.joml.Vector4f;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.injection.At;
30
import org.spongepowered.asm.mixin.injection.Inject;
31
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
32
33
@Mixin(FogRenderer.class)
34
public abstract class MixinFogRenderer {
35
36
    @Inject(method = "computeFogColor", at = @At("HEAD"), cancellable = true)
37
    private void editFogColor(Camera camera, float partialTicks, ClientLevel level, int renderDistance, float darkenWorldAmount, Vector4f dest, CallbackInfo ci) {
38
        var fogColorOverride = ModuleCustomAmbience.FogValueGroup.FogColorOverride.INSTANCE;
39
        if (fogColorOverride.getRunning()) {
40
            fogColorOverride.getColor().toVector4f(dest);
41
            ci.cancel();
42
        }
43
    }
44
45
    @Inject(
46
        method = "updateBuffer(Lnet/minecraft/client/renderer/fog/FogData;)V",
47
        at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/buffers/GpuBuffer;map(ZZ)Lcom/mojang/blaze3d/buffers/GpuBufferSlice$MappedView;")
48
    )
49
    private void editFogData(FogData fog, CallbackInfo ci) {
50
        ModuleCustomAmbience.FogValueGroup.INSTANCE.modifyFogData(fog);
51
    }
52
53
}
54
MixinLavaFogEnvironmentsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/fog/environment/MixinLavaFogEnvironment.javaJava · 53 lines · 2.1 KB
@Mixin(LavaFogEnvironment.class)
MixinLavaFogEnvironment.javaJava · 53 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.fog.environment;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.minecraft.client.Camera;
25
import net.minecraft.client.DeltaTracker;
26
import net.minecraft.client.multiplayer.ClientLevel;
27
import net.minecraft.client.renderer.fog.FogData;
28
import net.minecraft.client.renderer.fog.environment.LavaFogEnvironment;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33
34
/**
35
 * Removes the fog when the camera is inside lava.
36
 *
37
 * @see LavaFogEnvironment#setupFog
38
 */
39
@Mixin(LavaFogEnvironment.class)
40
public abstract class MixinLavaFogEnvironment {
41
42
    @Inject(method = "setupFog", at = @At("RETURN"))
43
    private void disableLavaFog(FogData fog, Camera camera, ClientLevel level, float renderDistance, DeltaTracker deltaTracker, CallbackInfo ci) {
44
        if (!ModuleAntiBlind.canRender(DoRender.LIQUIDS_FOG)) {
45
            fog.environmentalStart = Float.MAX_VALUE;
46
            fog.environmentalEnd = Float.MAX_VALUE;
47
            fog.skyEnd = Float.MAX_VALUE;
48
            fog.cloudEnd = Float.MAX_VALUE;
49
        }
50
    }
51
52
}
53
MixinMobEffectFogEnvironmentsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/fog/environment/MixinMobEffectFogEnvironment.javaJava · 57 lines · 2.0 KB
@Mixin(MobEffectFogEnvironment.class)
MixinMobEffectFogEnvironment.javaJava · 57 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.fog.environment;
21
22
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
23
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
24
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
25
import net.minecraft.client.renderer.fog.environment.MobEffectFogEnvironment;
26
import net.minecraft.core.Holder;
27
import net.minecraft.world.effect.MobEffect;
28
import net.minecraft.world.effect.MobEffects;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.Shadow;
31
import org.spongepowered.asm.mixin.injection.At;
32
33
@Mixin(MobEffectFogEnvironment.class)
34
public abstract class MixinMobEffectFogEnvironment {
35
36
    @Shadow
37
    public abstract Holder<MobEffect> getMobEffect();
38
39
    @ModifyReturnValue(method = "isApplicable", at = @At("RETURN"))
40
    private boolean onIsApplicable(boolean original) {
41
        if (!original) {
42
            return false;
43
        }
44
45
        var effect = getMobEffect();
46
47
        if (effect == MobEffects.BLINDNESS) {
48
            return ModuleAntiBlind.canRender(DoRender.BLINDING);
49
        }
50
        if (effect == MobEffects.DARKNESS) {
51
            return ModuleAntiBlind.canRender(DoRender.DARKNESS);
52
        }
53
54
        return true;
55
    }
56
}
57
MixinPowderedSnowFogEnvironmentsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/fog/environment/MixinPowderedSnowFogEnvironment.javaJava · 53 lines · 2.1 KB
@Mixin(PowderedSnowFogEnvironment.class)
MixinPowderedSnowFogEnvironment.javaJava · 53 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.fog.environment;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.minecraft.client.Camera;
25
import net.minecraft.client.DeltaTracker;
26
import net.minecraft.client.multiplayer.ClientLevel;
27
import net.minecraft.client.renderer.fog.FogData;
28
import net.minecraft.client.renderer.fog.environment.PowderedSnowFogEnvironment;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33
34
/**
35
 * Removes the fog when the camera is inside powdered snow.
36
 *
37
 * @see PowderedSnowFogEnvironment#setupFog
38
 */
39
@Mixin(PowderedSnowFogEnvironment.class)
40
public abstract class MixinPowderedSnowFogEnvironment {
41
42
    @Inject(method = "setupFog", at = @At("RETURN"))
43
    private void disablePowderedSnowFog(FogData fog, Camera camera, ClientLevel level, float renderDistance, DeltaTracker deltaTracker, CallbackInfo ci) {
44
        if (!ModuleAntiBlind.canRender(DoRender.POWDER_SNOW_FOG)) {
45
            fog.environmentalStart = Float.MAX_VALUE;
46
            fog.environmentalEnd = Float.MAX_VALUE;
47
            fog.skyEnd = Float.MAX_VALUE;
48
            fog.cloudEnd = Float.MAX_VALUE;
49
        }
50
    }
51
52
}
53
MixinWaterFogEnvironmentsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/fog/environment/MixinWaterFogEnvironment.javaJava · 53 lines · 2.1 KB
@Mixin(WaterFogEnvironment.class)
MixinWaterFogEnvironment.javaJava · 53 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.fog.environment;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.minecraft.client.Camera;
25
import net.minecraft.client.DeltaTracker;
26
import net.minecraft.client.multiplayer.ClientLevel;
27
import net.minecraft.client.renderer.fog.FogData;
28
import net.minecraft.client.renderer.fog.environment.WaterFogEnvironment;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.injection.At;
31
import org.spongepowered.asm.mixin.injection.Inject;
32
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33
34
/**
35
 * Removes the fog when the camera is inside water.
36
 *
37
 * @see WaterFogEnvironment#setupFog
38
 */
39
@Mixin(WaterFogEnvironment.class)
40
public abstract class MixinWaterFogEnvironment {
41
42
    @Inject(method = "setupFog", at = @At("RETURN"))
43
    private void disableWaterFog(FogData fog, Camera camera, ClientLevel level, float renderDistance, DeltaTracker deltaTracker, CallbackInfo ci) {
44
        if (!ModuleAntiBlind.canRender(DoRender.LIQUIDS_FOG)) {
45
            fog.environmentalStart = Float.MAX_VALUE;
46
            fog.environmentalEnd = Float.MAX_VALUE;
47
            fog.skyEnd = Float.MAX_VALUE;
48
            fog.cloudEnd = Float.MAX_VALUE;
49
        }
50
    }
51
52
}
53
MixinShieldSpecialRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/special/MixinShieldSpecialRenderer.javaJava · 78 lines · 4.4 KB
@Mixin(ShieldSpecialRenderer.class)
MixinShieldSpecialRenderer.javaJava · 78 lines · 4.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.special;
20
21
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
22
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
23
import com.mojang.blaze3d.vertex.PoseStack;
24
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleItemChams;
25
import net.ccbluex.liquidbounce.utils.render.FirstPersonShieldTint;
26
import net.minecraft.client.model.Model;
27
import net.minecraft.client.renderer.SubmitNodeCollector;
28
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
29
import net.minecraft.client.renderer.rendertype.RenderTypes;
30
import net.minecraft.client.renderer.special.ShieldSpecialRenderer;
31
import net.minecraft.client.resources.model.sprite.SpriteGetter;
32
import net.minecraft.client.resources.model.sprite.SpriteId;
33
import org.spongepowered.asm.mixin.Mixin;
34
import org.spongepowered.asm.mixin.injection.At;
35
import org.spongepowered.asm.mixin.injection.ModifyArg;
36
37
@Mixin(ShieldSpecialRenderer.class)
38
public abstract class MixinShieldSpecialRenderer {
39
40
    @WrapOperation(method = "submit(Lnet/minecraft/core/component/DataComponentMap;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;IIZI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;IIILnet/minecraft/client/resources/model/sprite/SpriteId;Lnet/minecraft/client/resources/model/sprite/SpriteGetter;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"))
41
    private <S> void hookFirstPersonShieldBaseTint(
42
        SubmitNodeCollector instance, Model<S> model, S state, PoseStack poseStack, int lightCoords, int overlayCoords,
43
        int tintedColor, SpriteId sprite, SpriteGetter sprites, int outlineColor,
44
        ModelFeatureRenderer.CrumblingOverlay crumblingOverlay, Operation<Void> original
45
    ) {
46
        if (!FirstPersonShieldTint.isRendering()) {
47
            original.call(
48
                instance, model, state, poseStack, lightCoords, overlayCoords, tintedColor, sprite, sprites, outlineColor,
49
                crumblingOverlay
50
            );
51
            return;
52
        }
53
54
        int shieldTint = ModuleItemChams.Shield.INSTANCE.applyTint(tintedColor);
55
        if (ModuleItemChams.Shield.INSTANCE.usesTranslucentTint(tintedColor)) {
56
            instance.submitModel(
57
                model, state, poseStack, RenderTypes.entityTranslucentCullItemTarget(sprite.atlasLocation()),
58
                lightCoords, overlayCoords, shieldTint,
59
                sprites.get(sprite), outlineColor, crumblingOverlay
60
            );
61
            return;
62
        }
63
64
        original.call(
65
            instance, model, state, poseStack, lightCoords, overlayCoords, shieldTint, sprite, sprites, outlineColor,
66
            crumblingOverlay
67
        );
68
    }
69
70
    @ModifyArg(method = "submit(Lnet/minecraft/core/component/DataComponentMap;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;IIZI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/OrderedSubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IIILnet/minecraft/client/renderer/texture/TextureAtlasSprite;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"), index = 6)
71
    private int hookFirstPersonShieldGlintTint(int tintedColor) {
72
        return FirstPersonShieldTint.isRendering()
73
            ? ModuleItemChams.Shield.INSTANCE.applyTint(tintedColor)
74
            : tintedColor;
75
    }
76
77
}
78
MixinGuiMessagesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinGuiMessage.javaJava · 62 lines · 1.8 KB
@Mixin(GuiMessage.class)
ModifiesGuiMessage
MixinGuiMessage.javaJava · 62 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.text;
20
21
import net.ccbluex.liquidbounce.interfaces.GuiMessageAddition;
22
import net.ccbluex.liquidbounce.interfaces.GuiMessageLineAddition;
23
import net.minecraft.client.multiplayer.chat.GuiMessage;
24
import org.jspecify.annotations.Nullable;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.Unique;
27
28
@Mixin(GuiMessage.class)
29
public abstract class MixinGuiMessage implements GuiMessageLineAddition, GuiMessageAddition {
30
31
    @Unique
32
    private @Nullable String liquid_bounce$id = null;
33
34
    @Unique
35
    private int liquid_bounce$count = 1;
36
37
    @Unique
38
    @Override
39
    public void liquid_bounce$setId(@Nullable String id) {
40
        this.liquid_bounce$id = id;
41
    }
42
43
    @Unique
44
    @Override
45
    public @Nullable String liquid_bounce$getId() {
46
        return liquid_bounce$id;
47
    }
48
49
    @Unique
50
    @Override
51
    public void liquid_bounce$setCount(int count) {
52
        this.liquid_bounce$count = count;
53
    }
54
55
    @Unique
56
    @Override
57
    public int liquid_bounce$getCount() {
58
        return liquid_bounce$count;
59
    }
60
61
}
62
MixinGuiMessageLineVisiblesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinGuiMessageLineVisible.javaJava · 46 lines · 1.5 KB
@Mixin(GuiMessage.Line.class)
MixinGuiMessageLineVisible.javaJava · 46 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.text;
20
21
import net.ccbluex.liquidbounce.interfaces.GuiMessageLineAddition;
22
import net.minecraft.client.multiplayer.chat.GuiMessage;
23
import org.jspecify.annotations.Nullable;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.Unique;
26
27
@Mixin(GuiMessage.Line.class)
28
public abstract class MixinGuiMessageLineVisible implements GuiMessageLineAddition {
29
30
    @Unique
31
    private @Nullable String liquid_bounce$id = null;
32
33
    @Unique
34
    @Override
35
    public void liquid_bounce$setId(@Nullable String id) {
36
        this.liquid_bounce$id = id;
37
    }
38
39
    @Unique
40
    @Override
41
    public @Nullable String liquid_bounce$getId() {
42
        return liquid_bounce$id;
43
    }
44
45
}
46
MixinMutableComponentsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinMutableComponent.javaJava · 51 lines · 1.8 KB
@Mixin(MutableComponent.class)
MixinMutableComponent.javaJava · 51 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.text;
21
22
import net.ccbluex.liquidbounce.utils.text.PlainText;
23
import net.minecraft.network.chat.Component;
24
import net.minecraft.network.chat.MutableComponent;
25
import net.minecraft.network.chat.contents.PlainTextContents;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.Overwrite;
28
import org.spongepowered.asm.mixin.Shadow;
29
30
@Mixin(MutableComponent.class)
31
public abstract class MixinMutableComponent {
32
33
    @Shadow
34
    public abstract MutableComponent append(Component text);
35
36
    /**
37
     * @author MukjepScarlet
38
     * @reason avoid {@link Component#literal(String)} because it creates {@link MutableComponent}
39
     */
40
    @Overwrite
41
    public MutableComponent append(String text) {
42
        return switch (text) {
43
            case "" -> (MutableComponent) (Object) this;
44
            case " " -> this.append(PlainText.SPACE);
45
            case "\n" -> this.append(PlainText.NEW_LINE);
46
            default -> this.append(new PlainText(PlainTextContents.create(text)));
47
        };
48
    }
49
50
}
51
MixinStyleAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinStyleAccessor.javaJava · 50 lines · 1.6 KB
@Mixin(Style.class)
ModifiesStyle
MixinStyleAccessor.javaJava · 50 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.text;
21
22
import kotlin.NotImplementedError;
23
import net.minecraft.network.chat.*;
24
import org.jspecify.annotations.NullMarked;
25
import org.jspecify.annotations.Nullable;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.gen.Invoker;
28
29
@NullMarked
30
@Mixin(Style.class)
31
public interface MixinStyleAccessor {
32
33
    @Invoker("<init>")
34
    static Style create(
35
        @Nullable TextColor color,
36
        @Nullable Integer shadowColor,
37
        @Nullable Boolean bold,
38
        @Nullable Boolean italic,
39
        @Nullable Boolean underlined,
40
        @Nullable Boolean strikethrough,
41
        @Nullable Boolean obfuscated,
42
        @Nullable ClickEvent clickEvent,
43
        @Nullable HoverEvent hoverEvent,
44
        @Nullable String insertion,
45
        @Nullable FontDescription font
46
    ) {
47
        throw new NotImplementedError();
48
    }
49
}
50
MixinTextColorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTextColor.javaJava · 83 lines · 2.7 KB
@Mixin(TextColor.class)
ModifiesTextColor
MixinTextColor.javaJava · 83 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.text;
21
22
import com.google.common.base.Objects;
23
import net.ccbluex.liquidbounce.interfaces.TextColorAddition;
24
import net.minecraft.network.chat.TextColor;
25
import org.jspecify.annotations.Nullable;
26
import org.spongepowered.asm.mixin.*;
27
import org.spongepowered.asm.mixin.injection.At;
28
import org.spongepowered.asm.mixin.injection.Inject;
29
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
30
31
/**
32
 * Why not Style? Because it is immutable so we would have to create a new instance every edit.
33
 */
34
@Mixin(TextColor.class)
35
public abstract class MixinTextColor implements TextColorAddition {
36
37
    @Shadow
38
    @Final
39
    private @Nullable String name;
40
    @Shadow
41
    @Final
42
    private int value;
43
    @Unique
44
    private boolean bypassesNameProtect = false;
45
46
    @Override
47
    public boolean liquid_bounce$doesBypassingNameProtect() {
48
        return bypassesNameProtect;
49
    }
50
51
    @Override
52
    public TextColor liquid_bounce$withNameProtectionBypass() {
53
        var textColor = new TextColor(this.value, this.name);
54
55
        ((TextColorAddition) ((Object) textColor)).liquid_bounce$setBypassingNameProtection(true);
56
57
        return textColor;
58
    }
59
60
    @Override
61
    public void liquid_bounce$setBypassingNameProtection(boolean bypassesNameProtect) {
62
        this.bypassesNameProtect = bypassesNameProtect;
63
    }
64
65
    @Inject(method = "equals", at = @At("RETURN"), cancellable = true)
66
    private void equals(Object o, CallbackInfoReturnable<Boolean> cir) {
67
        if (o instanceof TextColor) {
68
            if (this.bypassesNameProtect != ((TextColorAddition) o).liquid_bounce$doesBypassingNameProtect()) {
69
                cir.setReturnValue(false);
70
            }
71
        }
72
    }
73
    /**
74
     * @author superblaubeere27
75
     * @reason Nobody will ever overwrite this method too fr.
76
     */
77
    @Overwrite
78
    public int hashCode() {
79
        return Objects.hashCode(this.name, this.value, this.bypassesNameProtect);
80
    }
81
82
}
83
MixinTranslatableContentssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTranslatableContents.javaJava · 43 lines · 1.7 KB
@Mixin(TranslatableContents.class)
MixinTranslatableContents.javaJava · 43 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.text;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import net.ccbluex.liquidbounce.lang.LanguageManager;
24
import net.ccbluex.liquidbounce.lang.LanguageText;
25
import net.minecraft.locale.Language;
26
import net.minecraft.network.chat.contents.TranslatableContents;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.injection.At;
29
30
@Mixin(TranslatableContents.class)
31
public abstract class MixinTranslatableContents {
32
33
    @ModifyExpressionValue(method = "decompose", at = @At(value = "INVOKE", target = "Lnet/minecraft/locale/Language;getInstance()Lnet/minecraft/locale/Language;"))
34
    private Language hookClientTranslations(Language original) {
35
        if ((Object) this instanceof LanguageText) {
36
            return LanguageManager.INSTANCE.getLanguage();
37
        } else {
38
            return original;
39
        }
40
    }
41
42
}
43
MixinDownloadQueuesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/util/MixinDownloadQueue.javaJava · 56 lines · 2.1 KB
@Mixin(DownloadQueue.class)
MixinDownloadQueue.javaJava · 56 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.util;
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.sugar.Local;
24
import net.ccbluex.liquidbounce.features.spoofer.SpooferFingerprint;
25
import net.minecraft.client.Minecraft;
26
import net.minecraft.server.packs.DownloadQueue;
27
import org.spongepowered.asm.mixin.Final;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Shadow;
30
import org.spongepowered.asm.mixin.injection.At;
31
32
import java.nio.file.Path;
33
import java.util.UUID;
34
35
@Mixin(DownloadQueue.class)
36
public abstract class MixinDownloadQueue {
37
38
    @Shadow
39
    @Final
40
    private Path cacheDir;
41
42
    @ModifyExpressionValue(method = "lambda$runDownload$0", at = @At(value = "INVOKE", target = "Ljava/nio/file/Path;resolve(Ljava/lang/String;)Ljava/nio/file/Path;"))
43
    private Path hookResolve(Path original, @Local(argsOnly = true, name = "id") UUID id) {
44
        // Check if our fingerprint spoofer is enabled or,
45
        // the folder has been altered with by another mod.
46
        if (!SpooferFingerprint.INSTANCE.getRunning() || !original.getParent().equals(cacheDir)) {
47
            return original;
48
        }
49
50
        var accountId = Minecraft.getInstance().getUser().getProfileId();
51
        var accountFolder = cacheDir.resolve(accountId.toString());
52
        return accountFolder.resolve(id.toString());
53
    }
54
55
}
56
MixinStringUtilsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/util/MixinStringUtil.javaJava · 38 lines · 1.2 KB
@Mixin(StringUtil.class)
ModifiesStringUtil
MixinStringUtil.javaJava · 38 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.minecraft.util;
20
21
import net.minecraft.util.StringUtil;
22
import org.spongepowered.asm.mixin.Mixin;
23
import org.spongepowered.asm.mixin.Overwrite;
24
25
@Mixin(StringUtil.class)
26
public abstract class MixinStringUtil {
27
28
    /**
29
     * @author superblaubeere27
30
     * @reason .
31
     */
32
    @Overwrite
33
    public static boolean isAllowedChatCharacter(int chr) {
34
        return chr >= ' ' && chr != 127;
35
    }
36
37
}
38
MixinVec3isrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/util/MixinVec3i.javaJava · 52 lines · 1.5 KB
@Mixin(Vec3i.class)
ModifiesVec3i
MixinVec3i.javaJava · 52 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.util;
21
22
import net.minecraft.core.Vec3i;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.Overwrite;
25
import org.spongepowered.asm.mixin.Shadow;
26
27
@Mixin(Vec3i.class)
28
public abstract class MixinVec3i {
29
30
    @Shadow
31
    public abstract int getX();
32
33
    @Shadow
34
    public abstract int getY();
35
36
    @Shadow
37
    public abstract int getZ();
38
39
    /**
40
     * @author MukjepScarlet
41
     * @reason avoid useless int -> float -> int
42
     */
43
    @Overwrite
44
    public int distManhattan(Vec3i vec) {
45
        int f = Math.abs(vec.getX() - this.getX());
46
        int g = Math.abs(vec.getY() - this.getY());
47
        int h = Math.abs(vec.getZ() - this.getZ());
48
        return f + g + h;
49
    }
50
51
}
52
MixinSkyLightEnginesrc/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/world/chuck/MixinSkyLightEngine.javaJava · 39 lines · 1.6 KB
@Mixin(SkyLightEngine.class)
MixinSkyLightEngine.javaJava · 39 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.minecraft.world.chuck;
21
22
import net.ccbluex.liquidbounce.features.module.modules.render.DoRender;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
24
import net.minecraft.world.level.lighting.SkyLightEngine;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
30
@Mixin(SkyLightEngine.class)
31
public abstract class MixinSkyLightEngine {
32
    @Inject(at = @At("HEAD"), method = "propagateIncrease", cancellable = true)
33
    private void hookNoBlindSkyLightUpdates(long blockPos, long l, int lightLevel, CallbackInfo ci) {
34
        if (!ModuleAntiBlind.canRender(DoRender.SKYLIGHT_UPDATES)) {
35
            ci.cancel();
36
        }
37
    }
38
}
39
MixinRealmsAvailabilityAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/realms/MixinRealmsAvailabilityAccessor.javaJava · 41 lines · 1.5 KB
@Mixin(RealmsAvailability.class)
MixinRealmsAvailabilityAccessor.javaJava · 41 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.realms;
21
22
import com.mojang.realmsclient.RealmsAvailability;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.gen.Accessor;
25
26
import java.util.concurrent.CompletableFuture;
27
28
/**
29
 * {@link RealmsAvailability#get()} only re-runs its check when the cached result carries an exception, and
30
 * an {@code AUTHENTICATION_ERROR} carries none - so a failure from an earlier session is never retried.
31
 */
32
@Mixin(RealmsAvailability.class)
33
public interface MixinRealmsAvailabilityAccessor {
34
35
    @Accessor(value = "future", remap = false)
36
    static void setFuture(CompletableFuture<RealmsAvailability.Result> future) {
37
        throw new AssertionError();
38
    }
39
40
}
41
MixinRealmsClientAccessorsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/realms/MixinRealmsClientAccessor.javaJava · 42 lines · 1.6 KB
@Mixin(RealmsClient.class)
ModifiesRealmsClient
MixinRealmsClientAccessor.javaJava · 42 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.injection.mixins.realms;
21
22
import com.mojang.realmsclient.client.RealmsClient;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.gen.Accessor;
25
26
/**
27
 * {@link RealmsClient#getOrCreate(net.minecraft.client.Minecraft)} caches the instance it built from the
28
 * session that happened to be active at the time, in final fields, and hands it out from then on. Nulling
29
 * the instance is the only way to make it pick up the account we switched to.
30
 * <p>
31
 * Realms is not covered by Fabric intermediary, so its names are the same in development and production.
32
 */
33
@Mixin(RealmsClient.class)
34
public interface MixinRealmsClientAccessor {
35
36
    @Accessor(value = "realmsClientInstance", remap = false)
37
    static void setRealmsClientInstance(RealmsClient instance) {
38
        throw new AssertionError();
39
    }
40
41
}
42
MixinSodiumAbstractBlockRenderContextsrc/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumAbstractBlockRenderContext.javaJava · 104 lines · 3.9 KB
@Mixin(AbstractBlockRenderContext.class)
ModifiesAbstractBlockRenderContext external mod
MixinSodiumAbstractBlockRenderContext.javaJava · 104 lines · 3.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.sodium;
20
21
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
22
import net.caffeinemc.mods.sodium.client.model.light.LightMode;
23
import net.caffeinemc.mods.sodium.client.model.light.data.QuadLightData;
24
import net.caffeinemc.mods.sodium.client.render.model.AbstractBlockRenderContext;
25
import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl;
26
import net.caffeinemc.mods.sodium.client.render.model.SodiumShadeMode;
27
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay;
28
import net.minecraft.client.renderer.block.BlockAndTintGetter;
29
import net.minecraft.core.BlockPos;
30
import net.minecraft.core.Direction;
31
import net.minecraft.world.level.block.state.BlockState;
32
import org.spongepowered.asm.mixin.Final;
33
import org.spongepowered.asm.mixin.Mixin;
34
import org.spongepowered.asm.mixin.Pseudo;
35
import org.spongepowered.asm.mixin.Shadow;
36
import org.spongepowered.asm.mixin.Unique;
37
import org.spongepowered.asm.mixin.injection.At;
38
import org.spongepowered.asm.mixin.injection.Inject;
39
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
40
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
41
42
@Pseudo
43
@Mixin(AbstractBlockRenderContext.class)
44
public abstract class MixinSodiumAbstractBlockRenderContext {
45
46
    @Shadow
47
    protected BlockState state;
48
49
    @Shadow
50
    protected BlockPos pos;
51
52
    @Shadow
53
    protected BlockAndTintGetter level;
54
55
    @Shadow
56
    @Final
57
    protected QuadLightData quadLightData;
58
59
    @Unique
60
    private static final int FULL_BRIGHT_LIGHTMAP = 0x00F000F0;
61
62
    @Inject(method = "shouldDrawSide", at = @At("HEAD"), cancellable = true)
63
    private void injectXRayForceWhitelistedFace(Direction facing, CallbackInfoReturnable<Boolean> cir) {
64
        ModuleXRay module = ModuleXRay.INSTANCE;
65
        if (!module.getRunning() || this.state == null || this.pos == null) {
66
            return;
67
        }
68
69
        if (module.shouldRender(this.state, this.pos)) {
70
            cir.setReturnValue(true);
71
        }
72
    }
73
74
    @ModifyReturnValue(method = "shouldDrawSide", at = @At("RETURN"))
75
    private boolean injectXRayDrawSide(boolean original, Direction facing) {
76
        ModuleXRay module = ModuleXRay.INSTANCE;
77
        if (!module.getRunning() || this.state == null || this.pos == null || this.level == null) {
78
            return original;
79
        }
80
81
        return module.modifyDrawSide(this.state, this.level, this.pos, facing, original);
82
    }
83
84
    @Inject(method = "shadeQuad", at = @At("RETURN"))
85
    private void injectXRayFullBright(MutableQuadViewImpl quad, LightMode lightMode, boolean emissive,
86
            SodiumShadeMode shadeMode, CallbackInfo ci) {
87
        ModuleXRay module = ModuleXRay.INSTANCE;
88
        if (!module.getRunning() || !module.getFullBright() || this.state == null || this.pos == null) {
89
            return;
90
        }
91
92
        if (!module.shouldRender(this.state, this.pos)) {
93
            return;
94
        }
95
96
        float[] brightnesses = this.quadLightData.br;
97
        for (int i = 0; i < 4; i++) {
98
            quad.setLight(i, FULL_BRIGHT_LIGHTMAP);
99
            brightnesses[i] = 1.0F;
100
        }
101
    }
102
103
}
104
MixinSodiumBlockRenderersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumBlockRenderer.javaJava · 94 lines · 4.3 KB
@Mixin(BlockRenderer.class)
ModifiesBlockRenderer external mod
MixinSodiumBlockRenderer.javaJava · 94 lines · 4.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.sodium;
20
21
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
23
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
24
import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer;
25
import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl;
26
import net.ccbluex.liquidbounce.common.XRayBlockRenderContext;
27
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay;
28
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
29
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
30
import net.minecraft.core.BlockPos;
31
import net.minecraft.world.level.block.state.BlockState;
32
import org.objectweb.asm.Opcodes;
33
import org.spongepowered.asm.mixin.Mixin;
34
import org.spongepowered.asm.mixin.Pseudo;
35
import org.spongepowered.asm.mixin.injection.At;
36
import org.spongepowered.asm.mixin.injection.Inject;
37
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
38
39
@Pseudo
40
@Mixin(BlockRenderer.class)
41
public abstract class MixinSodiumBlockRenderer {
42
43
    @WrapMethod(method = "renderModel")
44
    private void wrapXRayTransparentBackground(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin,
45
            Operation<Void> original) {
46
        ModuleXRay module = ModuleXRay.INSTANCE;
47
        if (!module.getRunning()) {
48
            original.call(model, state, pos, origin);
49
            return;
50
        }
51
52
        XRayBlockRenderContext.renderTransparentBackground(module.transparentBackgroundAlpha(state),
53
            () -> original.call(model, state, pos, origin));
54
    }
55
56
    @Inject(method = "renderModel", at = @At("HEAD"), cancellable = true)
57
    private void injectXRaySkipHiddenBlocks(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin,
58
            CallbackInfo ci) {
59
        ModuleXRay module = ModuleXRay.INSTANCE;
60
        if (!module.getRunning()) {
61
            return;
62
        }
63
64
        if (module.shouldSkipRender(state, pos)) {
65
            ci.cancel();
66
        }
67
    }
68
69
    @ModifyExpressionValue(method = "processQuad", at = @At(value = "FIELD", target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer;forceOpaque:Z", opcode = Opcodes.GETFIELD))
70
    private boolean injectXRayTransparentBackgroundDisableForceOpaque(boolean original) {
71
        return XRayBlockRenderContext.isRenderingTransparentBackground() ? false : original;
72
    }
73
74
    @ModifyExpressionValue(method = "processQuad", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl;getRenderType()Lnet/minecraft/client/renderer/chunk/ChunkSectionLayer;"))
75
    private ChunkSectionLayer injectXRayTransparentBackgroundLayer(ChunkSectionLayer original) {
76
        return XRayBlockRenderContext.forceTranslucentLayer(original);
77
    }
78
79
    @Inject(
80
        method = "processQuad",
81
        at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer;shadeQuad(Lnet/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl;Lnet/caffeinemc/mods/sodium/client/model/light/LightMode;ZLnet/caffeinemc/mods/sodium/client/render/model/SodiumShadeMode;)V")
82
    )
83
    private void injectXRayTransparentBackgroundAlpha(MutableQuadViewImpl quad, CallbackInfo ci) {
84
        if (!XRayBlockRenderContext.isRenderingTransparentBackground()) {
85
            return;
86
        }
87
88
        for (int i = 0; i < 4; i++) {
89
            quad.setColor(i, XRayBlockRenderContext.applyAlpha(quad.baseColor(i)));
90
        }
91
    }
92
93
}
94
MixinSodiumLightDataAccesssrc/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumLightDataAccess.javaJava · 65 lines · 2.2 KB
@Mixin(LightDataAccess.class)
ModifiesLightDataAccess external mod
MixinSodiumLightDataAccess.javaJava · 65 lines · 2.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.sodium;
20
21
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
22
import net.caffeinemc.mods.sodium.client.model.light.data.LightDataAccess;
23
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay;
24
import net.minecraft.client.renderer.block.BlockAndTintGetter;
25
import net.minecraft.core.BlockPos;
26
import org.spongepowered.asm.mixin.*;
27
import org.spongepowered.asm.mixin.injection.At;
28
29
@Pseudo
30
@Mixin(LightDataAccess.class)
31
public abstract class MixinSodiumLightDataAccess {
32
33
    @Shadow
34
    @Final
35
    private BlockPos.MutableBlockPos pos;
36
37
    @Shadow
38
    protected BlockAndTintGetter level;
39
40
    /**
41
     * Maximum light level for all color channels.
42
     * <p>
43
     * Minecraft's lighting system represents light in a range of 0-15,
44
     * where 15 corresponds to maximum brightness.
45
     */
46
    @Unique
47
    private static final int MAX_LIGHT_LEVEL = 15 | 15 << 4 | 15 << 8;
48
49
    @ModifyReturnValue(method = "compute", at = @At("RETURN"))
50
    private int modifyLightLevel(int original) {
51
        var xray = ModuleXRay.INSTANCE;
52
        if (xray.getRunning() && xray.getFullBright()) {
53
            var blockState = this.level.getBlockState(pos);
54
55
            if (xray.shouldRender(blockState, pos)) {
56
                // Ensures that the brightness is on max for all color channels
57
                return original | MAX_LIGHT_LEVEL;
58
            }
59
        }
60
61
        return original;
62
    }
63
64
}
65
MixinPacketWrappersrc/main/java/net/ccbluex/liquidbounce/injection/mixins/viaversion/MixinPacketWrapper.javaJava · 78 lines · 3.6 KB
@Mixin(targets = "com.viaversion.viaversion.protocol.packet.PacketWrapperImpl", remap = false)remap=false
Modifiescom.viaversion.viaversion.protocol.packet.PacketWrapperImpl external mod
MixinPacketWrapper.javaJava · 78 lines · 3.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.injection.mixins.viaversion;
20
21
import com.viaversion.viaversion.api.protocol.Protocol;
22
import com.viaversion.viaversion.api.protocol.packet.PacketType;
23
import com.viaversion.viaversion.api.type.Type;
24
import com.viaversion.viaversion.api.type.Types;
25
import com.viaversion.viaversion.exception.InformativeException;
26
import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPackets1_16_2;
27
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPackets1_21_4;
28
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
29
import net.ccbluex.liquidbounce.utils.inventory.InventoryManager;
30
import org.jspecify.annotations.Nullable;
31
import org.spongepowered.asm.mixin.Mixin;
32
import org.spongepowered.asm.mixin.Pseudo;
33
import org.spongepowered.asm.mixin.Shadow;
34
import org.spongepowered.asm.mixin.injection.At;
35
import org.spongepowered.asm.mixin.injection.Inject;
36
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
37
38
@Pseudo
39
@Mixin(targets = "com.viaversion.viaversion.protocol.packet.PacketWrapperImpl", remap = false)
40
public abstract class MixinPacketWrapper {
41
42
    @Shadow
43
    public abstract @Nullable PacketType getPacketType();
44
45
    @Shadow
46
    public abstract <T> T get(Type<T> type, int index) throws InformativeException;
47
48
    @SuppressWarnings("rawtypes")
49
    @Inject(method = "scheduleSendToServer", at = @At("HEAD"), cancellable = true)
50
    private void vfpSendPacketHandler(Class<? extends Protocol> protocol, boolean skipCurrentPipeline, CallbackInfo ci) {
51
        PacketType packetType = this.getPacketType();
52
53
        /*
54
          An injection that prevents ViaFabricPlus from sending an inventory packet twice.
55
          <p>
56
          This can be caused when inventory-managing modules silently open inventory and the user tries to manually open
57
          their inventory, which results in the same packet being sent twice.
58
         */
59
        if (packetType == ServerboundPackets1_9_3.CLIENT_COMMAND && this.get(Types.VAR_INT, 0) == 2 &&
60
                InventoryManager.INSTANCE.isInventoryOpenServerSide()) {
61
            ci.cancel();
62
        }
63
64
        /*
65
          Handles old protocol version of {@link ServerboundContainerClickPacket} (containerId = 0)
66
67
          https://github.com/ViaVersion/ViaFabricPlus/blob/e7a6c9d193e278120942a805f14201048ceb43ff/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/interaction/container_clicking/MixinMultiPlayerGameMode.java#L79
68
         */
69
        if (packetType == ServerboundPackets1_16_2.CONTAINER_CLICK && this.get(Types.BYTE, 0) == 0
70
            || packetType == ServerboundPackets1_21_4.CONTAINER_CLICK && this.get(Types.VAR_INT, 0) == 0) {
71
            // Note: this doesn't cover all handlers of PacketEvent
72
            InventoryManager.onClickOccurs();
73
            InventoryManager.INSTANCE.setInventoryOpenServerSide(true);
74
        }
75
    }
76
77
}
78