Spartan Weaponry

Spartan Weaponry

48M Downloads

Crashing on 1.20.1 forge

baronpalmer opened this issue · 3 comments

commented

When the mod attempts to spawn a zombie with a weapon from this mod

crash-2025-08-03_22.40.19-server.txt

commented

It's weird because the crash doesn't happen all the time, i'm assuming only for certain weapons? I've seen zombies spawn with one handed weapons no problem

commented

Hello ! I am having the same kind of crash on the devbuild of the legendary modpack, with the latest versions of Spartan Weaponry

crash-2025-08-09_05.02.13-server.txt

It always involve C2ME/Spartan Weaponry/Blueprint mods.
As Chat GPT 5 just released, it helped me read the crash log and this new version is more precise and helped me understand some parts of the issue. I'll send what it said :

_**Short version: C2ME’s async worldgen put mob-equipping code from Spartan Weaponry on a background thread during Nether bastion generation, and C2ME caught ThreadLocalRandom being used from the wrong thread. It throws on purpose to stop unsafe cross-thread access—so your server hard-crashed while placing a structure (bastion) and spawning its mobs.

What the stacktrace says (plain English)
Crash reason: “ThreadLocalRandom accessed from a different thread (owner: Server thread, current: C2ME worker #1)”. That’s C2ME’s safety check firing.

Context: Feature placement for minecraft:bastion_remnant in the Nether; while adding entities to the structure, Spartan Weaponry tries to randomize gear, which touches the random source on the wrong thread.

Offending path: SpartanWeaponry -> MobMixin -> PiglinBrute equipment -> StructureTemplate.addEntitiesToWorld -> ChunkGenerator under c2me_threading_worldgen.

C2ME even tells you: you can make this a fatal warning instead of a hard crash via a config toggle.

Quick ways to stop it crashing
Pick one of these (top to bottom = least to most intrusive):

Flip the C2ME safety switch
Set fixes.enforceSafeWorldRandomAccess = true in config/c2me.toml. This turns the throw into a (fatal) warning so you don’t crash while you test, though the underlying bug is still there.

Disable C2ME async worldgen (keeps C2ME other tweaks)
Remove or disable the c2me_threading_worldgen module, or set C2ME’s worldgen threading to off. That keeps everything on the main thread so mods that aren’t thread-safe (like gear randomization on spawn) won’t trip the check.

Temporarily pull Spartan Weaponry (and add-ons like SpartanFire)
If you want to keep C2ME threading, removing the mod that calls random during spawn fixes the immediate crash. You can also try testing without its add-ons first. The stack shows Spartan Weaponry’s ItemRandomizer.generate as the caller.

Avoid generating bastions while testing
It’s specifically crashing while placing a bastion and spawning its mobs. Moving away/using a different dimension while you try configs can help verify the fix.

Why your setup is extra fragile
You’re running Forge with Fabric mods via Sinytra Connector plus lots of worldgen/structure mods; C2ME makes worldgen multithreaded; Spartan Weaponry hooks mob spawn to randomize gear—classic recipe for cross-thread random use. The crash report even flags Connector/Embeddium taint and a long list of mixins touching worldgen and spawning.**_

So apparently, this has to do with the enforceSafeWorldRandomAccess option c2me and the feature placement when giving some mobs spartan gears

commented

I can't seem to reproduce this crash myself, but I believe I can at least mitigate it.
The problem is that without reproducing the crash, I can't verify if this can be fixed.
The cause of this is the fabric mod "Concurrent Chunk Management Engine" not liking that the mod is accessing the levels random value.
I'll change it so my mod accesses the spawning entity's random value instead and that should hopefully fix the problem. I should have it implemented in the next update.