Skip to content

NeoForge 1.21.1 port (corelib bundled) — draft for discussion - #77

Draft
denjiaki wants to merge 3 commits into
talhanation:mainfrom
denjiaki:neoforge-1.21.1
Draft

NeoForge 1.21.1 port (corelib bundled) — draft for discussion#77
denjiaki wants to merge 3 commits into
talhanation:mainfrom
denjiaki:neoforge-1.21.1

Conversation

@denjiaki

@denjiaki denjiaki commented Jul 1, 2026

Copy link
Copy Markdown

NeoForge 1.21.1 port (for discussion)

This is a draft porting the mod from Forge / MC 1.20.1 to NeoForge / MC 1.21.1. Opening it as a draft because it targets a different Minecraft version and mod loader than main, so it is meant as a starting point for discussion rather than a drop-in merge.

What's here

  • Loader/MC: NeoForge 21.1.x, Minecraft 1.21.1.
  • Build: migrated from the Groovy Forge build to Kotlin ModDevGradle (build.gradle.kts / settings.gradle.kts).
  • corelib: bundled inside the jar via NeoForge Jar-in-Jar (still a REQUIRED dependency), so no separate corelib download is needed.
  • Source: migrated to 1.21.1 mappings/APIs (rendering, networking, registries, events).
  • Bug fix: RecruitsCategoryButton now overrides renderWidget() and calls super.renderWidget(...); the naive super.render(...) caused infinite recursion / StackOverflowError when the group screen opened.

Fidelity to the original

  • No features added. Every source file corresponds to existing project content.
  • Original README, CREDITS.txt, changelog.txt, update.json, and art files are retained.
  • The corpse-mod compat is dropped only because that dependency has no 1.21.1 build. All other compat (musketmod, siegeweapons, smallships, workers) is unchanged.

Notes

  • Because MC version, loader, and build system all differ from main, the diff is large by nature. Happy to restructure (e.g. target a dedicated 1.21.1 branch) if you'd prefer.
  • The migrate_*.py / parse_errors.py scripts are the one-off helpers used during the port; easy to drop if you'd rather not carry them.

Ports the mod from Forge/MC 1.20.1 to NeoForge/MC 1.21.1:

- Build migrated from the Groovy Forge build to Kotlin ModDevGradle
  (build.gradle.kts / settings.gradle.kts), targeting NeoForge 21.1.
- corelib bundled inside the jar via NeoForge Jar-in-Jar, so no separate
  corelib download is needed; it remains a REQUIRED dependency.
- Source migrated to the 1.21.1 mappings/APIs (rendering, networking,
  registries, events).
- Fix RecruitsCategoryButton: in 1.21.1 the widget draw entry point is
  renderWidget(), so it now calls super.renderWidget(...) instead of
  super.render(...), which caused StackOverflow when the group screen
  opened.

Preserves the original project's content: no features added, upstream
README/CREDITS/changelog/art retained. The corpse-mod compat is dropped
only because that dependency has no 1.21.1 build.
@dark-neon1101

Copy link
Copy Markdown

I have been working on my own port for a bit(and it is bad), so I have a question. Is this one server stable? I have been trying to get my one to be server stable, but if this current draft is server stable then, I'll use this port.

@denjiaki

denjiaki commented Jul 2, 2026

Copy link
Copy Markdown
Author

I have been working on my own port for a bit(and it is bad), so I have a question. Is this one server stable? I have been trying to get my one to be server stable, but if this current draft is server stable then, I'll use this port.

From my testing @dark-neon1101 , it boots cleanly on a dedicated server and packet handling looks correct on the thread. But I haven't load tested actual multiplayer gameplay yet. I can say with some certainty that it will work as expected, but it's not battle tested.
Everything should work, and I/We can work on bugs as they come up.

@dark-neon1101

dark-neon1101 commented Jul 2, 2026

Copy link
Copy Markdown

Found one bug that I fixed in my one. it tries to save the faction banner when it doesn't exist and crashes. That is fixed by adding a null check.

@dark-neon1101

Copy link
Copy Markdown

and also the ticking screen issue with a missing super.tick() in one of the scripts

@denjiaki

denjiaki commented Jul 2, 2026

Copy link
Copy Markdown
Author

@dark-neon1101 Thanks for the heads up, will be implementing that later today

@dark-neon1101

Copy link
Copy Markdown

strange, all of the proper code seems to be in place.

@dark-neon1101

Copy link
Copy Markdown

My mistake, the Super.tick() is present but the null issue still exists

@dark-neon1101

Copy link
Copy Markdown

Specifically the problem is in the checkcreationcondition() function as it can try to access the banner when it is empty so if we check for null anyway, we can do an if block for null and empty and return false immediately when it is null or empty and otherwise, the function does everything as before.

denjiaki added 2 commits July 2, 2026 19:13
FactionEditScreen#checkCreationCondition and #checkEditCondition called
ItemStack.save() while only guarding the banner against null. In 1.21.1
ItemStack.save() throws IllegalStateException on an empty (non-null)
stack, so opening the faction screen with an empty banner slot crashed.
(The 1.20.1 original used serializeNBT(), which was empty-safe.)

Guard both paths against empty banners before the save() call. Behaviour
is unchanged for valid banners: an empty banner already made both
conditions false. Reported by @dark-neon1101.
FactionEvents.createTeam guarded the banner against null but not empty.
MessageCreateTeam decodes the banner via OPTIONAL_STREAM_CODEC, so a
modified client can submit ItemStack.EMPTY; the subsequent
ItemStack.save() then throws IllegalStateException on the server thread
(server crash). Same 1.21.1 save()-throws-on-empty regression as the
client-side faction screen fix.

Treat empty like null and fall back to the default banner.
@denjiaki

denjiaki commented Jul 3, 2026

Copy link
Copy Markdown
Author

@dark-neon1101 I took care of the crashes you mentioned.

@dark-neon1101

Copy link
Copy Markdown

The faction screen is broken, when I use ANY banner to make a faction it says that I can't use a blank banner to make a faction. My guess is that the GUI closes before the faction creation fully goes through so it fails, I am not sure where exactly the error is though.

@denjiaki

denjiaki commented Jul 5, 2026

Copy link
Copy Markdown
Author

@dark-neon1101 Just saw your comment. I deleted a comment from another one of my accounts. I'll get on it by Wednesday this week. I'm swamped with my Job. i've handed the file and PR link to other folks in the meantime so they report any bugs they encounter

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