introduce scoped registry holder using PhaseTracker#4194
Conversation
f0ad0c9 to
799348a
Compare
| } | ||
|
|
||
| public static SpongeRegistryHolder scopedHolder() { | ||
| var holder = PhaseTracker.getInstance().currentCause().first(SpongeRegistryHolder.class); |
There was a problem hiding this comment.
I still strongly feel that this is violating Cause. We need a static area to store this field, separate from an engine per my original idea. So, it is perfectly fine to put it on the PhaseTracker as an optional field. But not in the Cause. Cause is meant to be inspected, and plugin developers are told to take it as face value. Not for us to use it as a dumping ground.
There was a problem hiding this comment.
Not to mention, you are creating frames where they were not needed before. If you put the field on the tracker directly, no need for these pointless frames.
There was a problem hiding this comment.
the frames are created 6 times on async threads
There was a problem hiding this comment.
But I guess now that I realized I never needed to push the Server at #initServer I could just put a try finally block around there
SpongeAPI | Sponge
Intruduces
SpongeCommon#scopedHolderwhich attempts to find aRegistryHolderin the current cause.SpongeCommon#vanillaRegistrynow uses this.Fallback to Server -> Game depending on availability.
During Startup
SpongeLifecycle#processerverRegistriesthe current RegistryHolder is pushed on the stack allowing plugins during registration to access registries earlier.Later when
DedicatedServer#initServeris called the Server is pushed on the stack.