Skip to content

Commit 274e264

Browse files
authored
Fix registering to builtin registries with dependencies (#4249)
1 parent a6f8537 commit 274e264

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/org/spongepowered/common/SpongeLifecycle.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public void callRegisterBuilderEvent() {
122122
public void establishEarlyGlobalRegistries() {
123123
final SpongeRegistryHolder holder = (SpongeRegistryHolder) this.game;
124124
holder.setRootMinecraftRegistry((Registry<Registry<?>>) BuiltInRegistries.REGISTRY);
125+
holder.streamRegistries().forEach(r -> ((WritableRegistryBridge<?>) r).bridge$setRegistryHolder(this.game));
125126

126127
SpongeRegistries.registerEarlyGlobalRegistries(holder);
127128
}
@@ -136,8 +137,12 @@ public void establishGlobalRegistries() {
136137
// Freeze Sponge Root - Registries are now available
137138
holder.registryHolder().freezeSpongeRootRegistry();
138139

139-
this.game.eventManager().post(new AbstractRegisterRegistryValueEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game,
140-
holder.streamRegistries().collect(Collectors.toMap(org.spongepowered.api.registry.Registry::type, Function.identity()))));
140+
final Map<RegistryType<?>, org.spongepowered.api.registry.Registry<?>> map =
141+
holder.streamRegistries().collect(Collectors.toMap(org.spongepowered.api.registry.Registry::type, Function.identity()));
142+
143+
this.game.eventManager().post(new AbstractRegisterRegistryValueEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game, map));
144+
map.values().forEach(r -> ((WritableRegistryBridge<?>) r).bridge$markEventCalled());
145+
holder.registryHolder().freezeSpongeDynamicRegistries(false);
141146
}
142147

143148
public void endEstablishGlobalRegistries() {

0 commit comments

Comments
 (0)