Skip to content

Port modflared from NeoForge 1.21.11 to Forge 1.12.2#95

Merged
HttpRafa merged 10 commits intoHttpRafa:forge/1.12.2from
hattapauzi:forge/1.12.2-port
May 2, 2026
Merged

Port modflared from NeoForge 1.21.11 to Forge 1.12.2#95
HttpRafa merged 10 commits intoHttpRafa:forge/1.12.2from
hattapauzi:forge/1.12.2-port

Conversation

@hattapauzi
Copy link
Copy Markdown

@hattapauzi hattapauzi commented Apr 30, 2026

Summary

Port the modflared Minecraft mod from NeoForge 1.21.11 to Forge 1.12.2, downgrading from Java 21 to Java 8 compatibility while preserving all core functionality including tunnel management, cloudflared binary download, and Mixin-based connection interception.

Changes

Build System Migration

  • Migrated from NeoForge 1.21.11 to ForgeGradle 2.3 + Forge 1.12.2
  • Set Java source/target compatibility to 1.8
  • Replaced neoforge.mods.toml with legacy mcmod.info
  • Updated modflared.mixins.json for 1.12.2 MCP class names
  • Added Mixin 0.8.2 dependency with shadowJar bundling
  • Replaced JSON language files with .lang format

Mod Entrypoint & Mixin Bootstrap

  • Replaced NeoForge @Mod entrypoint with legacy @Mod + IFMLLoadingPlugin
  • Created ModflaredMixinLoader coremod for Mixin initialization
  • Removed TweakClass from manifest to avoid LaunchClassLoader conflicts
  • Initialize MixinBootstrap in coremod constructor

Mixin Renaming (1.21 → 1.12.2)

  • ConnectionMixinNetworkManagerMixin (func_150718_a)
  • ConnectScreenMixinGuiConnectingMixin (func_73863_a)
  • ConnectScreenRunnableMixinGuiConnectingThreadMixin (redirects func_181124_a)
  • ServerStatusPingerMixinServerPingerMixin (func_147224_a)
  • Added null guards in mixins for failed tunnel creation

Java 8 Compatibility Refactoring

  • Converted Java 21 records to standard Java 8 classes
  • Replaced var keyword with explicit types
  • Replaced Files.writeString/readString with FileWriter/BufferedReader
  • Replaced String.strip() with String.trim()
  • Replaced CompletableFuture chaining with explicit BiConsumer callbacks
  • Replaced Platform.OS with System.getProperty(os.name) checks
  • Updated Gson API from JsonParser.parseReader to new JsonParser().parse
  • Replaced SLF4J with Log4j2 LogManager.getLogger

Tunnel Manager Updates

  • Replaced NeoForge FMLPaths with Minecraft.getMinecraft().gameDir
  • Replaced ServerAddress.parseString with ServerAddress.fromString + try/catch
  • Updated all record-style accessors to getter methods (getAccess, getState)
  • Replaced modern toast notifications with logging-only error reporting

Testing

  • Added RunningTunnelAccessTest for deterministic CRC32 port generation
  • Added CloudflaredDownloadTest for OS/arch binary selection logic
  • Added ForcedTunnelsJsonTest for forced_tunnels.json array validation

Manual Testing

As for now, I just tested a successful connectivity from client machine -> server in which playable in vanilla Minecraft...
(I use arch btw)
I have not got the chance to do the testing for Windows machine(would be in the near future) + Mac machine (which I dont have)...

Have serveral small details in need of fixing which I did not make changes for yet:

  • The modflared icon not showing in the server list for cloudflared configured server
  • Improper loading info when entering a server (gui.tunnel.status.use in the en_us.lang)

Disclosure

Yes, I did vibe my way out with AI to make this possible... I am not a skilled Java programmer(still actively learning and wanted to contribute) but I did do a proper way of prompting(they call it agentic engineering for some reason)
If you interested in looking into this(I just wanted to be transparent), it is called Spec-Driven Development...
https://github.com/hattapauzi/modflared/tree/spec-driven-dev
I would like to contribute more in the future as I would use this mod regularly(me and the boys love to play RLcraft)...

Dependencies

https://www.curseforge.com/minecraft/mc-mods/mixinbootstrap/files/3437402

Yeah, unfortunately this is the side effect of using coding agent... For some reason Kimi K2.6 decided to use another mod as a dependency... I used a free credits given by Fireworks AI (10$ worth 😆 took me 2 attempt to make this work)... If there is a work around to do this that uses only one single .jar file like the other modflared versions please let me know!

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request ports the modflared mod to Minecraft 1.12.2 (Legacy). The changes involve a complete overhaul of the build system to use ForgeGradle 2.3, downgrading the project to Java 8, and reimplementing the core logic and mixins to align with the legacy Minecraft codebase. Feedback focuses on a critical bug in the binary update logic where the new version string is discarded, and a regression regarding the removal of macOS support.

Comment thread src/main/java/dev/httxrafa/modflared/binary/download/DownloadedCloudflared.java Outdated
Comment thread src/main/java/dev/httxrafa/modflared/binary/download/DownloadedCloudflared.java Outdated
@hattapauzi hattapauzi mentioned this pull request Apr 30, 2026
@HttpRafa
Copy link
Copy Markdown
Owner

@hattapauzi Can you rebase your branch on top of the new forge/1.12.2 branch? I merged the latest changes from NeoForge 1.20.11 into it so your PR doesn't include them.

- Switch build.gradle to ForgeGradle 2.3 with MCP mappings
- Set Java source/target compatibility to 1.8
- Add Mixin 0.8.2 dependency with shadowJar bundling
- Replace neoforge.mods.toml with legacy mcmod.info
- Replace JSON language files with .lang format
- Update modflared.mixins.json for 1.12.2 MCP class names
- Replace NeoForge @mod entrypoint with legacy @mod + IFMLLoadingPlugin
- Create ModflaredMixinLoader coremod for Mixin initialization
- Remove TweakClass from manifest to avoid LaunchClassLoader conflicts
- Initialize MixinBootstrap in coremod constructor
- Convert Java 21 records to standard Java 8 classes
- Replace var keyword with explicit types
- Replace Files.writeString/readString with FileWriter/BufferedReader
- Replace String.strip() with String.trim()
- Preserve deterministic CRC32 port algorithm
- Fix cloudflared access tcp command to use --destination host:port
- Replace CompletableFuture chaining with explicit BiConsumer callbacks
- Replace Platform.OS with System.getProperty(os.name) checks
- Update Gson API from JsonParser.parseReader to new JsonParser().parse
- Replace SLF4J with Log4j2 LogManager.getLogger
- Replaced var keyword with explicit types
- Replace NeoForge FMLPaths with Minecraft.getMinecraft().gameDir
- Replace ServerAddress.parseString with ServerAddress.fromString + try/catch
- Update all record-style accessors to getter methods (getAccess, getState)
- Replace modern toast notifications with logging-only error reporting
- Update JsonParser API for Gson Java 8 compatibility
- Replace ConnectionMixin with NetworkManagerMixin (func_150718_a)
- Replace ConnectScreenMixin with GuiConnectingMixin (func_73863_a)
- Replace ConnectScreenRunnableMixin with GuiConnectingThreadMixin
  (redirects func_181124_a / createNetworkManagerAndConnect)
- Replace ServerStatusPingerMixin with ServerPingerMixin (func_147224_a)
- Add null guards in mixins for failed tunnel creation
- Remove obsolete 1.21 mixin classes
- Add RunningTunnelAccessTest for deterministic CRC32 port generation
- Add CloudflaredDownloadTest for OS/arch binary selection logic
- Add ForcedTunnelsJsonTest for forced_tunnels.json array validation
@hattapauzi
Copy link
Copy Markdown
Author

hattapauzi commented Apr 30, 2026

@hattapauzi Can you rebase your branch on top of the new forge/1.12.2 branch? I merged the latest changes from NeoForge 1.20.11 into it so your PR doesn't include them.

Am I doing this right? I am not quite sure

@HttpRafa
Copy link
Copy Markdown
Owner

HttpRafa commented Apr 30, 2026

@hattapauzi Can you rebase your branch on top of the new forge/1.12.2 branch? I merged the latest changes from NeoForge 1.20.11 into it so your PR doesn't include them.

Am I do this right? I am not quite sure

You got it right.

@HttpRafa
Copy link
Copy Markdown
Owner

@gemini-code-assist review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request ports modflared to Minecraft 1.12.2, downgrading the project to Java 8 and Gradle 4.10.3 while migrating from NeoForge to Forge and Mixins. The changes involve replacing modern Java syntax with legacy-compatible alternatives and updating Mixin targets for the 1.12.2 environment. Feedback highlights several issues, including a hardcoded Java path in the build configuration that hinders portability and a bug in the update logic that prevents downloading new versions. Additionally, the reviewer noted misleading error messages, a regression in user-facing error notifications, and improper exception handling that disrupts the original connection error UI.

Comment thread gradle.properties Outdated
Comment thread src/main/java/dev/httxrafa/modflared/binary/download/DownloadedCloudflared.java Outdated
Comment thread src/main/java/dev/httxrafa/modflared/binary/download/DownloadedCloudflared.java Outdated
Comment thread src/main/java/dev/httxrafa/modflared/binary/download/DownloadedCloudflared.java Outdated
Comment thread src/main/java/dev/httxrafa/modflared/tunnel/manager/TunnelManager.java Outdated
Comment thread src/main/java/dev/httxrafa/modflared/mixin/client/GuiConnectingThreadMixin.java Outdated
hattapauzi and others added 3 commits April 30, 2026 19:09
…dCloudflared.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…dCloudflared.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Author

@hattapauzi hattapauzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@HttpRafa
Copy link
Copy Markdown
Owner

HttpRafa commented May 1, 2026

@gemini-code-assist review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request downgrades the project from NeoForge (Java 21) to Forge 1.12.2 (Java 8), requiring a complete overhaul of the build system, mixins, and codebase for legacy compatibility. Modern Java features like records, the var keyword, and stream APIs have been replaced with Java 8 compatible constructs. Feedback identifies a critical issue where the shadowJar task lacks necessary reobfuscation for production environments and a bug in the tunnel command generation where an unsupported --destination flag would cause the cloudflared process to fail.

Comment thread build.gradle
Comment thread src/main/java/dev/httxrafa/modflared/tunnel/RunningTunnel.java
@HttpRafa HttpRafa merged commit a66219b into HttpRafa:forge/1.12.2 May 2, 2026
1 check failed
@HttpRafa
Copy link
Copy Markdown
Owner

HttpRafa commented May 2, 2026

@hattapauzi It might take a minute before this version is available on Modrinth, because I still need to fix the CI and a few other things.

@hattapauzi
Copy link
Copy Markdown
Author

hattapauzi commented May 3, 2026

@hattapauzi It might take a minute before this version is available on Modrinth, because I still need to fix the CI and a few other things.

Its okay, take your time... I am just happy that my pr is merged...
btw, when it is available on Modrinth, is MixinBootstrap would still be needed as its dependency?
kind of a hassle for the end user dont you think?

@hattapauzi hattapauzi deleted the forge/1.12.2-port branch May 4, 2026 08:54
@hattapauzi hattapauzi restored the forge/1.12.2-port branch May 4, 2026 08:55
@hattapauzi hattapauzi deleted the forge/1.12.2-port branch May 5, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants