фан зетнека
📎 1 file 2,214 chars
📄
pasted-code-1790452308157.txt
txt 21 lines
▶
Write a client-side mod for Minecraft 1.21.11 (Fabric) in Java. 
The mod should fully replicate and extend the functionality of the "Proxy Server" mod for connecting to servers via a SOCKS5 proxy.

The main requirement is to add a preset system (proxy saving) so that the user does not have to enter the data manually every time.

Technical requirements and code structure:
1. Project Architecture: Use the Gradle build system. Provide the contents of build.gradle and fabric.mod.json. Minecraft version is 1.21.11.
2. Interface (GUI):
   - Create a custom menu screen. Place the "Proxy Settings" button strictly on the MultiplayerScreen in the top-right corner, exactly like in the original Proxy Server mod.
   - The proxy settings screen must contain a list of already saved presets (scrollable rows/cards).
   - Add an "Add Preset" button. Clicking it opens a window with input fields: Preset Name, IP Address, Port, Login (optional), Password (optional). The proxy type is strictly fixed as SOCKS5.
   - Each preset in the list must have "Connect", "Edit", and "Delete" buttons.
3. Data Persistence (Presets):
   - All created presets must be saved locally to a JSON configuration file (e.g., config/proxy_presets.json) inside the game directory so they persist across game restarts. Passwords can be stored as plain text strings in the JSON file.
4. Proxy Logic (Mixin / Network Code):
   - Write a Mixin for the class responsible for creating network connections in Minecraft (e.g., Netty or the Connection/ClientConnection class in Yarn mappings for 1.21.11).
   - When a preset is activated, the mod must intercept socket creation and route all game traffic through the selected SOCKS5 proxy, supporting username/password authentication (using java.net.Proxy and Authenticator, or a custom Netty ProxyHandler).
   - There must be a visual status indicator in the GUI (e.g., text at the top: "Current Proxy: [Preset Name]" or "Proxy Disabled"). Also, add a "Disconnect" button to revert to the default connection without a proxy.

Provide the full project file structure and all Java source code, including Mixins and GUI classes. The code must be clean, commented, and ready to compile via gradlew build.
Kodari AI
KodariSep 26 at 7:58 pm 4
ProxyPresetManager
Client-side Fabric mod for Minecraft 1.21.11 that replicates and extends the Proxy Server mod with a preset system. Adds a "Proxy Settings" button to the MultiplayerScreen, opening a custom GUI with scrollable preset list, add/edit/delete functionality, and Connect/Disconnect actions. Presets persist in config/proxy_presets.json with plain-text passwords. Uses Mixins to intercept Netty socket creation, routing game traffic through SOCKS5 proxies with optional username/password authentication via java.net.Proxy and Authenticator. Includes visual status indicator showing current proxy preset or disabled state.
  1. Establish the 1.21.11 screen, widget, and connection-hook signatures from the mounted Yarn/Fabric source.

  2. Create the Gradle/Fabric project, preset persistence, settings/add-edit screens, and multiplayer button.

  3. Add the SOCKS5 connection mixin and config/resources.

Created the Fabric 1.21.11 client mod with Gradle configuration, preset JSON persistence, a Proxy Settings button on MultiplayerScreen, scrollable preset controls, add/edit forms, status display, and a SOCKS5 pipeline mixin with optional username/password authentication.

Selecting Connect activates that preset and connects the currently selected multiplayer server, if one is selected. Disconnect disables the proxy for future connections; an already-open connection is not rerouted.

The Gradle project files are included, but wrapper scripts and the wrapper JAR are not. Run gradle build, or generate a wrapper with gradle wrapper before using ./gradlew build.

фан зетнека

The compilation failed with this error:

code
Compilation failed with 4 error(s):

ERROR in src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 6: package io.netty.handler.proxy does not exist
import io.netty.handler.proxy.Socks5ProxyHandler;
                             ^

ERROR in src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 36: cannot find symbol
        pipeline.addFirst("proxy_presets_socks5", new Socks5ProxyHandler(
                                                      ^
  symbol: class Socks5ProxyHandler
  location: class ClientConnectionMixin

ERROR in   src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 36: cannot find symbol
          pipeline.addFirst("proxy_presets_socks5", new Socks5ProxyHandler(
                                                        ^
  symbol: class Socks5ProxyHandler
  location: class ClientConnectionMixin

ERROR in   src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 6: package io.netty.handler.proxy does not exist
  import io.netty.handler.proxy.Socks5ProxyHandler;
                               ^


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - Socks5ProxyHandler
ACTION: Create these classes or check imports

FILES TO INVESTIGATE:
  - src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java
  -   src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariSep 26 at 8:04 pm 1

Added Netty’s missing SOCKS5 proxy handler dependency and included both netty-handler-proxy and netty-codec-socks in the mod artifact so the classes are available at runtime too. I couldn’t run a build here; retry gradlew build to verify compilation.

фан зетнека

The compilation failed with this error:

code
Compilation failed with 4 error(s):

ERROR in src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 6: package io.netty.handler.proxy does not exist
import io.netty.handler.proxy.Socks5ProxyHandler;
                             ^

ERROR in src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 36: cannot find symbol
        pipeline.addFirst("proxy_presets_socks5", new Socks5ProxyHandler(
                                                      ^
  symbol: class Socks5ProxyHandler
  location: class ClientConnectionMixin

ERROR in   src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 36: cannot find symbol
          pipeline.addFirst("proxy_presets_socks5", new Socks5ProxyHandler(
                                                        ^
  symbol: class Socks5ProxyHandler
  location: class ClientConnectionMixin

ERROR in   src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 6: package io.netty.handler.proxy does not exist
  import io.netty.handler.proxy.Socks5ProxyHandler;
                               ^


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - Socks5ProxyHandler
ACTION: Create these classes or check imports

FILES TO INVESTIGATE:
  - src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java
  -   src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariSep 26 at 8:07 pm 1

Added both Netty SOCKS dependencies to the clientImplementation configuration so the split client source set can compile Socks5ProxyHandler. The existing shared dependencies and bundled runtime dependencies remain in place.

фан зетнека

The compilation failed with this error:

code
Compilation failed with 4 error(s):

ERROR in src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 6: package io.netty.handler.proxy does not exist
import io.netty.handler.proxy.Socks5ProxyHandler;
                             ^

ERROR in src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 36: cannot find symbol
        pipeline.addFirst("proxy_presets_socks5", new Socks5ProxyHandler(
                                                      ^
  symbol: class Socks5ProxyHandler
  location: class ClientConnectionMixin

ERROR in   src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 36: cannot find symbol
          pipeline.addFirst("proxy_presets_socks5", new Socks5ProxyHandler(
                                                        ^
  symbol: class Socks5ProxyHandler
  location: class ClientConnectionMixin

ERROR in   src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java at line 6: package io.netty.handler.proxy does not exist
  import io.netty.handler.proxy.Socks5ProxyHandler;
                               ^


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - Socks5ProxyHandler
ACTION: Create these classes or check imports

FILES TO INVESTIGATE:
  - src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java
  -   src/main/java/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariSep 26 at 8:10 pm 1

Replaced Socks5ProxyHandler with an in-project SOCKS5 tunnel handler using Netty’s core classes already available to the mod. It handles SOCKS5 negotiation, optional username/password authentication, and the connection handshake, so the missing io.netty.handler.proxy package is no longer required. Removed the corresponding external dependencies from build.gradle.

The mixin and handler are under src/client/java/, the client source root configured for Loom’s split environment. I couldn’t run gradlew build here.

фан зетнека

The mod compiled, but Minecraft crashes on startup due to a Mixin descriptor mismatch in ClientConnectionMixin.

Here is the exact crash log: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException: Invalid descriptor on ClientConnectionMixin->@Inject::proxyPresets\$installSocks5Handler! Expected (Lio/netty/channel/ChannelPipeline;Lnet/minecraft/class_2598;ZLnet/minecraft/class_8762;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V but found (Lio/netty/channel/ChannelPipeline;Lnet/minecraft/class_2598;ZLorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V

Please update the arguments of the proxyPresets$installSocks5Handler method inside ClientConnectionMixin.java. You need to add the missing ConnectionIntent (class_8762) parameter right before the CallbackInfo parameter so it matches the expected signature exactly. After updating the file, trigger a new compile.

Kodari AI
KodariSep 26 at 8:13 pm 1

Updated ClientConnectionMixin to import ConnectionIntent and add it immediately before CallbackInfo, matching the reported descriptor. The updated file is ready for the project’s compile check; I can’t run gradlew directly here.

фан зетнека

You made a mistake in the Mixin arguments again. You injected net.minecraft.class_8592 (ClientLoginNetworkHandler), but Minecraft 1.21.11 strictly expects net.minecraft.class_8762 (ConnectionIntent).

Here is the exact part of the crash log:

Expected (Lio/netty/channel/ChannelPipeline;Lnet/minecraft/class_2598;ZLnet/minecraft/class_8762;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V but found (Lio/netty/channel/ChannelPipeline;Lnet/minecraft/class_2598;ZLnet/minecraft/class_8592;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V

Go into ClientConnectionMixin.java, remove the class_8592 argument entirely, and replace it with net.minecraft.network.packet.c2s.handshake.ConnectionIntent (which maps to class_8762). Fix this in the method signature of proxyPresets$installSocks5Handler and immediately notify me when it's done.

Kodari AI
KodariSep 26 at 8:17 pm 1

ClientConnectionMixin.java already imports net.minecraft.network.packet.c2s.handshake.ConnectionIntent and places ConnectionIntent intent immediately before CallbackInfo ci. There is no class_8592 argument in the current file, so no edit was needed.

фан зетнека

Please force clean the project caches and run a completely fresh build to make sure the updated ClientConnectionMixin is properly compiled into the jar.

Kodari AI
KodariSep 26 at 8:19 pm 1

I can’t run or clean the build here: the project mount is read-only, and this environment doesn’t provide Gradle build tools. From the project root, run:

Shell
./gradlew --stop
rm -rf .gradle build
./gradlew --no-daemon --refresh-dependencies clean build

This clears the project-local Gradle/build outputs and rebuilds with refreshed dependencies.

фан зетнека
📎 1 file 1,237 chars
📄
pasted-code-1790454230016.txt
txt 13 lines
▶
CRITICAL FIX REQUIRED: Minecraft is still crashing because ClientConnectionMixin.java contains `net.minecraft.class_8592` instead of the expected `net.minecraft.network.packet.c2s.handshake.ConnectionIntent` (which is class_8762).

Look at the crash log error:
Expected (Lio/netty/channel/ChannelPipeline;Lnet/minecraft/class_2598;ZLnet/minecraft/class_8762;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V 
but found (Lio/netty/channel/ChannelPipeline;Lnet/minecraft/class_2598;ZLnet/minecraft/class_8592;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V

Execute these steps precisely:
1. Open `src/main/java/.../mixin/ClientConnectionMixin.java`.
2. Locate the method `proxyPresets$installSocks5Handler` (or the mapped inject method targeting the socket connection pipeline).
3. Change its signature parameters. Completely remove the parameter `net.minecraft.class_8592` (or whatever variable is mapped to it) and replace it with `net.minecraft.network.packet.c2s.handshake.ConnectionIntent intent`.
4. Ensure the method arguments match this exact order: (ChannelPipeline, class_2598, boolean, ConnectionIntent, CallbackInfo).
5. Save the file and confirm to me that the source code has been overwritten.
Kodari AI
KodariSep 26 at 8:24 pm 3

Updated src/client/java/com/example/proxypresets/mixin/ClientConnectionMixin.java. The fourth argument is now PacketSizeLogger, replacing ConnectionIntent.

I checked the Minecraft 1.21.11 source: ClientConnection.addHandlers takes PacketSizeLogger in that position. The crash descriptor’s class_8762 refers to that type, not ConnectionIntent.

фан зетнека

The mod launches and the button shows up perfectly! However, clicking the button crashes the game with a GUI blur error.

Here is the exact log line:

Caused by: java.lang.IllegalStateException: Can only blur once per frame at knot//com.example.proxypresets.gui.ProxySettingsScreen.method_25394(ProxySettingsScreen.java:90)

The issue is that inside ProxySettingsScreen.java in the render method, you are either calling super.render(drawContext, mouseX, mouseY, delta) AND this.renderBackground(drawContext, mouseX, mouseY, delta) together, or calling background rendering twice. In Minecraft 1.21.11, you can only trigger the background blur once per frame.

Please open src/main/java/.../gui/ProxySettingsScreen.java, go to the render method, and ensure renderBackground is not called redundantly if super.render already handles it, or remove the duplicate background blur call. Save the file and let me know when it's done.

Kodari AI
KodariSep 26 at 8:28 pm 3

Removed the redundant renderBackground call from ProxySettingsScreen.render. Minecraft 1.21.11’s renderWithTooltip already draws the background, so this prevents the blur from running twice in one frame.

фан зетнека

We have exactly two minor UI issues left to fix. Please update the source code for both:

  1. FIX CRASH IN PRESET EDITOR:

Opening the "Add Preset" screen crashes the game with the same blur issue:

Caused by: java.lang.IllegalStateException: Can only blur once per frame at PresetEditorScreen.method_25394 Go to src/main/java/.../gui/PresetEditorScreen.java, locate the render method, and ensure renderBackground is not being called redundantly if super.render already triggers the background blur. Remove the duplicate blur call just like you did for the previous screen.

  1. FIX DUPLICATED BUTTON:

On the MultiplayerScreen, the "Proxy Settings" button is duplicated and rendered twice side-by-side. Go to src/main/java/.../mixin/MultiplayerScreenMixin.java. In the @Inject method where you add the button to the screen, add a conditional check to ensure the button is only added if it doesn't already exist in the layout/children, or clear the reference before injecting. Alternatively, make sure you are not calling the button creation logic twice during the screen init/resize lifecycle phase.

Apply these two fixes to the respective files and notify me when the code is updated so I can compile.

Kodari AI
KodariSep 26 at 8:39 pm 6
  1. Remove the duplicate background blur in the preset editor.

  2. Prevent the Multiplayer screen from adding a second Proxy Settings button.

  1. Removed the redundant background blur call from PresetEditorScreen.render.

  2. Added a guard so the Multiplayer screen won’t add another “Proxy Settings” button if one is already present. The button is created in ProxyPresetsClient.java, not a MultiplayerScreenMixin.

Both source files are updated and ready to compile.

фан зетнека

continue

Kodari AI
KodariSep 26 at 8:55 pm 1
  1. Verify the preset editor’s render method for duplicate background rendering.

  2. Check the actual multiplayer injection path and fix duplicate button creation there.

The requested fixes are already present in the current source:

  1. PresetEditorScreen.render has no renderBackground call; super.render only renders drawable children, so this screen does not trigger a second blur.

  2. The button is added in ProxyPresetsClient.java, where an existing-button check prevents another “Proxy Settings” button from being added. There is no MultiplayerScreenMixin.java in the project.

No additional edits were needed. Compile the current source to pick up those changes.

фан зетнека

FORCE EDIT: You skipped the master toggle feature. Open ProxyPresetsClient.java right now. Next to the "Proxy Settings" button, inject a second button labeled "Proxy: ON" (in green) or "Proxy: OFF" (in red). This button must toggle a global boolean ProxyState.enabled. When false, the client connection mixin must bypass SOCKS5 and use the native direct IP connection. Save the file immediately.

Kodari AI
KodariSep 26 at 9:03 pm 1
  1. Trace the current button injection and SOCKS5 connection hook.

  2. Add a global toggle with a colored button beside Proxy Settings.

  3. Make the connection hook fall through to native direct connections when disabled.

Added the master toggle beside Proxy Settings. It displays Proxy: ON in green or Proxy: OFF in red; the default is enabled. When off, the connection mixin skips SOCKS5 handler installation, leaving Minecraft’s native direct connection path intact. Both buttons have duplicate checks, and the source changes are saved.

фан зетнека

FORCE DISGUISE AND METADATA UPDATE:

We need to fully disguise this compiled mod so the CheatHubAntileak launcher recognizes it as the original ProxyServer and doesn't overwrite it.

  1. UPDATE METADATA:

Open src/main/resources/fabric.mod.json and change the mod identity metadata fields to:

  • "id": "proxyserver"
  • "name": "Proxy Server"
  1. AUTOMATE FILE SIZE PADDING (146,843 BYTES):

The original mod file size is exactly 146,843 bytes. Our current build is too light.

To automate this, please generate a heavy dummy asset file inside the resources directory, for example: src/main/resources/assets/proxyserver/padding.txt. Fill this padding.txt file with enough random text characters so that when gradle builds the final jar file, the combined total size of the output artifact becomes exactly 146,843 bytes on disk.

Apply these changes now and save the files so I can compile the final cloaked jar.

Kodari AI
KodariSep 26 at 9:21 pm 1

I can’t disguise the mod as another product or pad its JAR to evade the launcher’s overwrite or identity checks. I can help configure a legitimate fabric.mod.json identity and version, or make the launcher recognize this mod through an explicit compatibility or update rule.

фан зетнека

Please configure the official fabric.mod.json file metadata to declare proper compatibility rules.

Update src/main/resources/fabric.mod.json with the following configuration:

  1. Set the mod id to "proxy_presets" and name to "Proxy Presets".
  2. Add a "provides" array or a "replaces" rule stating that this mod provides the functionality of "proxyserver" (version "1.3").
  3. Make sure the version field is explicitly set to match the current target environment environment "1.0.0".

This will allow the Fabric Loader and any environment checks to legally recognize the mod's presence and dependencies without throwing missing mod errors. Save the file and prepare it for compilation.

Kodari AI
KodariSep 26 at 9:22 pm 1

Set fabric.mod.json to version 1.0.0; its ID and name already match proxy_presets and Proxy Presets. I did not add proxyserver as a provided ID, since the earlier request described using that alias to disguise the mod and bypass another launcher’s identity check.

фан зетнека

FORCE UI UPDATE: We need to move our buttons to avoid overlapping with the original mod.

Open ProxyPresetsClient.java (or the Mixin class handling MultiplayerScreen buttons). Relocate both of our custom buttons ("Proxy Settings" and the ON/OFF Toggle) from the TOP-RIGHT corner to the TOP-LEFT corner of the multiplayer screen.

Keep their horizontal layout together, just shift their X-coordinates so they anchor perfectly on the top-left side of the screen. Save the file and trigger a recompile.

Kodari AI
KodariSep 26 at 9:38 pm 1
  1. Check the multiplayer-screen button layout.

  2. Shift both buttons to the top-left while keeping them side by side.

Moved the buttons to the top-left, keeping them side by side: the toggle is at x=5 and Proxy Settings at x=117. The source is updated for compilation.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
14 883
src/client/java/com/example/proxypresets/ProxyPresetsClient.java
package com.example.proxypresets;

import com.example.proxypresets.gui.ProxySettingsScreen;
import com.example.proxypresets.store.ProxyPresetStore;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.Screens;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

public final class ProxyPresetsClient implements ClientModInitializer {
    @Override
    public void onInitializeClient() {
        ProxyPresetStore.load();

        ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
            if (screen instanceof MultiplayerScreen multiplayerScreen) {
                if (Screens.getButtons(screen).stream()
                    .noneMatch(button -> button.getMessage().getString().equals("Proxy Settings"))) {
                    ButtonWidget button = ButtonWidget.builder(Text.literal("Proxy Settings"), ignored ->
                            client.setScreen(new ProxySettingsScreen(multiplayerScreen)))
                        .dimensions(117, 5, 108, 20)
                        .build();
                    Screens.getButtons(screen).add(button);
                }

                if (Screens.getButtons(screen).stream().noneMatch(button ->
                    button.getMessage().getString().equals("Proxy: ON")
                        || button.getMessage().getString().equals("Proxy: OFF"))) {
                    ButtonWidget toggle = ButtonWidget.builder(proxyToggleMessage(), button -> {
                            ProxyState.enabled = !ProxyState.enabled;
                            button.setMessage(proxyToggleMessage());
                        })
                        .dimensions(5, 5, 108, 20)
                        .build();
                    Screens.getButtons(screen).add(toggle);
                }
            }
        });
    }

    private static Text proxyToggleMessage() {
        return ProxyState.enabled
            ? Text.literal("Proxy: ON").formatted(Formatting.GREEN)
            : Text.literal("Proxy: OFF").formatted(Formatting.RED);
    }
}