Dynamic Surroundings: Fabric Edition

Dynamic Surroundings: Fabric Edition

867k Downloads

Xoroshiro128PlusPlus not available in OpenJDK 21 implementations

smbarbour opened this issue ยท 3 comments

commented

When using an OpenJDK implementation such as Eclipse Adoptium (used by default by most launchers), Xoroshiro128PlusPlus is not an available RandomGenerator algorithm. This algorithm is available via the full Oracle JDK, however.

While this may be a fairly minor issue, Minecraft can, and does, crash if multiple threads access the LegacyRandomSource

java.lang.IllegalStateException: Accessing LegacyRandomSource from multiple threads

at TRANSFORMER/[email protected]/net.minecraft.util.ThreadingDetector.makeThreadingException(ThreadingDetector.java:84) ~[client-1.21.1-20240808.144430-srg.jar%23429!/:?] {re:mixin,pl:connector_pre_launch:A,re:classloading,pl:mixin:APP:cupboard.mixins.json:ThreadingDetectorMixin from mod cupboard,pl:mixin:A,pl:connector_pre_launch:A}

While manually switching to the full Oracle JDK is an option, it may be better to switch to using and packaging something like Apache Commons RNG Core to ensure a proper RNG algorithm gets used, instead of relying on the fallback to the Mojang implementation.

commented

This may not be possible, but do you have a complete stack trace of the crash? I thought I found all the cross thread RNG issues with DS but it's possible I missed something. I will look into the Apache Commons SDK - Xoroshiro issues of one shape or another has cropped up in several different forms in the past. If anything, I can resurrect my old implementation and use that. :)

commented
commented

Thanks! Looking at the code, Minecraft has a Xorisho random source that I could leverage. I reworked my code to use an instance of that class instead of relying on JDK or legacy. Also added a thread safety wrapper to catch any bonehead mistakes I make. In a nutshell the randomizer instances DS will use are totally independent of whatever other mods (or Minecraft) is using.