Skip to content

Commit 0f56c8f

Browse files
Feature: Upgrade AutoDisconnect
1 parent df268a9 commit 0f56c8f

8 files changed

Lines changed: 832 additions & 32 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2026 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.network;
19+
20+
import com.lambda.module.modules.combat.autodisconnect.AutoDisconnect;
21+
import com.lambda.module.modules.combat.autodisconnect.AutoDisconnectScreen;
22+
import com.lambda.module.modules.combat.autodisconnect.DisconnectDetails;
23+
import net.minecraft.client.gui.screen.Screen;
24+
import net.minecraft.client.network.ClientCommonNetworkHandler;
25+
import net.minecraft.network.DisconnectionInfo;
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(value = ClientCommonNetworkHandler.class)
32+
public class ClientCommonNetworkHandlerMixin {
33+
@Inject(method = "createDisconnectedScreen", at = @At("HEAD"), cancellable = true)
34+
private void createDisconnectedScreen(DisconnectionInfo info, CallbackInfoReturnable<Screen> cir) {
35+
DisconnectDetails details = AutoDisconnect.INSTANCE.consumeDetails();
36+
if (details != null) {
37+
cir.setReturnValue(new AutoDisconnectScreen(details));
38+
}
39+
}
40+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2026 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.render;
19+
20+
import com.lambda.module.modules.combat.autodisconnect.AutoDisconnect;
21+
import com.lambda.module.modules.combat.autodisconnect.MultiplayerReconnectTarget;
22+
import net.minecraft.client.MinecraftClient;
23+
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
24+
import net.minecraft.client.network.CookieStorage;
25+
import net.minecraft.client.network.ServerAddress;
26+
import net.minecraft.client.network.ServerInfo;
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(value = ConnectScreen.class)
33+
public class ConnectScreenMixin {
34+
35+
@Inject(method = "connect(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ServerAddress;Lnet/minecraft/client/network/ServerInfo;Lnet/minecraft/client/network/CookieStorage;)V", at= @At("HEAD"))
36+
private void connectHead(MinecraftClient client, ServerAddress address, ServerInfo info, CookieStorage cookieStorage, CallbackInfo ci) {
37+
AutoDisconnect.INSTANCE.setLastReconnectTarget(new MultiplayerReconnectTarget(address, info, cookieStorage));
38+
}
39+
}

src/main/java/com/lambda/mixin/render/GameRendererMixin.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.mixin.render;
1919

20+
import com.lambda.Lambda;
2021
import com.lambda.event.EventFlow;
2122
import com.lambda.event.events.RenderEvent;
2223
import com.lambda.graphics.RenderMain;
@@ -26,16 +27,20 @@
2627
import com.lambda.module.modules.render.Bobbing;
2728
import com.lambda.module.modules.render.NoRender;
2829
import com.lambda.module.modules.render.Zoom;
30+
import com.lambda.util.render.CursorOverrideProvider;
2931
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
3032
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
3133
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
3234
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
3335
import com.mojang.blaze3d.buffers.GpuBufferSlice;
36+
import net.minecraft.client.gui.DrawContext;
37+
import net.minecraft.client.gui.cursor.Cursor;
3438
import net.minecraft.client.render.Camera;
3539
import net.minecraft.client.render.GameRenderer;
3640
import net.minecraft.client.render.RenderTickCounter;
3741
import net.minecraft.client.render.WorldRenderer;
3842
import net.minecraft.client.render.command.OrderedRenderCommandQueueImpl;
43+
import net.minecraft.client.util.Window;
3944
import net.minecraft.client.util.ObjectAllocator;
4045
import net.minecraft.item.ItemStack;
4146
import org.joml.Matrix4f;
@@ -89,6 +94,23 @@ private void onGuiRenderComplete(RenderTickCounter tickCounter, boolean tick, Ca
8994
DearImGui.INSTANCE.render();
9095
}
9196

97+
@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;applyCursorTo(Lnet/minecraft/client/util/Window;)V"))
98+
private void applyCursorOverride(DrawContext context, Window window, Operation<Void> original) {
99+
original.call(context, window);
100+
101+
if (Lambda.getMc().currentScreen instanceof CursorOverrideProvider provider) {
102+
int mouseX = (int) Lambda.getMc().mouse.getScaledX(window);
103+
int mouseY = (int) Lambda.getMc().mouse.getScaledY(window);
104+
Cursor cursor = provider.getCursorOverride(mouseX, mouseY);
105+
106+
if (cursor != null) {
107+
cursor.applyTo(window);
108+
return;
109+
}
110+
}
111+
Cursor.DEFAULT.applyTo(window);
112+
}
113+
92114
@Inject(method = "shouldRenderBlockOutline()Z", at = @At("HEAD"), cancellable = true)
93115
private void injectShouldRenderBlockOutline(CallbackInfoReturnable<Boolean> cir) {
94116
if (BlockOutline.INSTANCE.isEnabled()) cir.setReturnValue(false);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2026 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.world;
19+
20+
import com.lambda.module.modules.combat.autodisconnect.AutoDisconnect;
21+
import com.lambda.module.modules.combat.autodisconnect.SingleplayerReconnectTarget;
22+
import net.minecraft.server.integrated.IntegratedServerLoader;
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(IntegratedServerLoader.class)
29+
public class IntegratedServerLoaderMixin {
30+
@Inject(method = "start(Ljava/lang/String;Ljava/lang/Runnable;)V", at = @At("HEAD"))
31+
private void onStart(String name, Runnable onCancel, CallbackInfo ci) {
32+
AutoDisconnect.INSTANCE.setLastReconnectTarget(new SingleplayerReconnectTarget(name));
33+
}
34+
35+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2026 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.util.render;
19+
20+
import net.minecraft.client.gui.cursor.Cursor;
21+
22+
public interface CursorOverrideProvider {
23+
Cursor getCursorOverride(int mouseX, int mouseY);
24+
}

0 commit comments

Comments
 (0)