diff --git a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java index 4672aef5b..f679b412c 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java @@ -231,9 +231,15 @@ public class GeyserImpl implements GeyserApi, EventRegistrar { } logger.info("******************************************"); - /* Initialize registries */ - Registries.init(); - BlockRegistries.init(); + /* + First load the registries and then populate them. + Both the block registries and the common registries depend on each other, + so maintaining this order is crucial for Geyser to load. + */ + BlockRegistries.load(); + Registries.load(); + BlockRegistries.populate(); + Registries.populate(); RegistryCache.init(); diff --git a/core/src/main/java/org/geysermc/geyser/registry/BlockRegistries.java b/core/src/main/java/org/geysermc/geyser/registry/BlockRegistries.java index 2f15094ef..8cf11979f 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/BlockRegistries.java +++ b/core/src/main/java/org/geysermc/geyser/registry/BlockRegistries.java @@ -69,7 +69,7 @@ public class BlockRegistries { /** * A mapped registry containing which holds block IDs to its {@link BlockCollision}. */ - public static final ListRegistry COLLISIONS; + public static final ListRegistry COLLISIONS = ListRegistry.create(Pair.of("org.geysermc.geyser.translator.collision.CollisionRemapper", "mappings/collisions.nbt"), CollisionRegistryLoader::new); /** * A registry which stores Java IDs to {@link Block}, containing miscellaneous information about @@ -130,22 +130,36 @@ public class BlockRegistries { */ public static final SimpleMappedRegistry CUSTOM_SKULLS = SimpleMappedRegistry.create(RegistryLoaders.empty(Object2ObjectOpenHashMap::new)); - static { + public static void load() { + BLOCKS.load(); + BLOCK_STATES.load(); + // collisions are loaded later, because they are initialized later + JAVA_BLOCKS.load(); + JAVA_IDENTIFIER_TO_ID.load(); + WATERLOGGED.load(); + INTERACTIVE.load(); + INTERACTIVE_MAY_BUILD.load(); + CUSTOM_BLOCKS.load(); + CUSTOM_BLOCK_STATE_OVERRIDES.load(); + NON_VANILLA_BLOCK_STATE_OVERRIDES.load(); + CUSTOM_BLOCK_ITEM_OVERRIDES.load(); + EXTENDED_COLLISION_BOXES.load(); + CUSTOM_SKULLS.load(); + + COLLISIONS.load(); + } + + public static void populate() { Blocks.VAULT.javaId(); // FIXME CustomSkullRegistryPopulator.populate(); BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.PRE_INIT); CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.DEFINITION); CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.NON_VANILLA_REGISTRATION); BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.INIT_JAVA); - COLLISIONS = ListRegistry.create(Pair.of("org.geysermc.geyser.translator.collision.CollisionRemapper", "mappings/collisions.nbt"), CollisionRegistryLoader::new); CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.VANILLA_REGISTRATION); CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.CUSTOM_REGISTRATION); BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.INIT_BEDROCK); BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.POST_INIT); } - public static void init() { - // no-op - } - -} \ No newline at end of file +} diff --git a/core/src/main/java/org/geysermc/geyser/registry/Registries.java b/core/src/main/java/org/geysermc/geyser/registry/Registries.java index e9ff837ab..b86ea3bbf 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/Registries.java +++ b/core/src/main/java/org/geysermc/geyser/registry/Registries.java @@ -62,7 +62,7 @@ import java.util.*; * Holds all the common registries in Geyser. */ public final class Registries { - private static boolean initialized = false; + private static boolean loaded = false; /** * A registry holding all the providers. @@ -167,9 +167,9 @@ public final class Registries { */ public static final SimpleMappedRegistry> SOUND_TRANSLATORS = SimpleMappedRegistry.create("org.geysermc.geyser.translator.sound.SoundTranslator", SoundTranslatorRegistryLoader::new); - public static void init() { - if (initialized) return; - initialized = true; + public static void load() { + if (loaded) return; + loaded = true; PROVIDERS.load(); BEDROCK_ENTITY_IDENTIFIERS.load(); @@ -191,7 +191,9 @@ public final class Registries { SOUNDS.load(); SOUND_LEVEL_EVENTS.load(); SOUND_TRANSLATORS.load(); + } + public static void populate() { PacketRegistryPopulator.populate(); ItemRegistryPopulator.populate();