3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-05 15:50:12 +01:00

Correct the loading of the block registries and the common registries

Dieser Commit ist enthalten in:
Tim203 2024-10-28 00:56:39 +01:00
Ursprung d6d19b02b2
Commit 8f7a0d0778
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
3 geänderte Dateien mit 37 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -231,9 +231,15 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
} }
logger.info("******************************************"); logger.info("******************************************");
/* Initialize registries */ /*
Registries.init(); First load the registries and then populate them.
BlockRegistries.init(); 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(); RegistryCache.init();

Datei anzeigen

@ -69,7 +69,7 @@ public class BlockRegistries {
/** /**
* A mapped registry containing which holds block IDs to its {@link BlockCollision}. * A mapped registry containing which holds block IDs to its {@link BlockCollision}.
*/ */
public static final ListRegistry<BlockCollision> COLLISIONS; public static final ListRegistry<BlockCollision> 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 * A registry which stores Java IDs to {@link Block}, containing miscellaneous information about
@ -130,22 +130,36 @@ public class BlockRegistries {
*/ */
public static final SimpleMappedRegistry<String, CustomSkull> CUSTOM_SKULLS = SimpleMappedRegistry.create(RegistryLoaders.empty(Object2ObjectOpenHashMap::new)); public static final SimpleMappedRegistry<String, CustomSkull> 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 Blocks.VAULT.javaId(); // FIXME
CustomSkullRegistryPopulator.populate(); CustomSkullRegistryPopulator.populate();
BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.PRE_INIT); BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.PRE_INIT);
CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.DEFINITION); CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.DEFINITION);
CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.NON_VANILLA_REGISTRATION); CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.NON_VANILLA_REGISTRATION);
BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.INIT_JAVA); 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.VANILLA_REGISTRATION);
CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.CUSTOM_REGISTRATION); CustomBlockRegistryPopulator.populate(CustomBlockRegistryPopulator.Stage.CUSTOM_REGISTRATION);
BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.INIT_BEDROCK); BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.INIT_BEDROCK);
BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.POST_INIT); BlockRegistryPopulator.populate(BlockRegistryPopulator.Stage.POST_INIT);
} }
public static void init() { }
// no-op
}
}

Datei anzeigen

@ -62,7 +62,7 @@ import java.util.*;
* Holds all the common registries in Geyser. * Holds all the common registries in Geyser.
*/ */
public final class Registries { public final class Registries {
private static boolean initialized = false; private static boolean loaded = false;
/** /**
* A registry holding all the providers. * A registry holding all the providers.
@ -167,9 +167,9 @@ public final class Registries {
*/ */
public static final SimpleMappedRegistry<SoundTranslator, SoundInteractionTranslator<?>> SOUND_TRANSLATORS = SimpleMappedRegistry.create("org.geysermc.geyser.translator.sound.SoundTranslator", SoundTranslatorRegistryLoader::new); public static final SimpleMappedRegistry<SoundTranslator, SoundInteractionTranslator<?>> SOUND_TRANSLATORS = SimpleMappedRegistry.create("org.geysermc.geyser.translator.sound.SoundTranslator", SoundTranslatorRegistryLoader::new);
public static void init() { public static void load() {
if (initialized) return; if (loaded) return;
initialized = true; loaded = true;
PROVIDERS.load(); PROVIDERS.load();
BEDROCK_ENTITY_IDENTIFIERS.load(); BEDROCK_ENTITY_IDENTIFIERS.load();
@ -191,7 +191,9 @@ public final class Registries {
SOUNDS.load(); SOUNDS.load();
SOUND_LEVEL_EVENTS.load(); SOUND_LEVEL_EVENTS.load();
SOUND_TRANSLATORS.load(); SOUND_TRANSLATORS.load();
}
public static void populate() {
PacketRegistryPopulator.populate(); PacketRegistryPopulator.populate();
ItemRegistryPopulator.populate(); ItemRegistryPopulator.populate();