diff --git a/connector/src/main/java/org/geysermc/connector/registry/BlockRegistries.java b/connector/src/main/java/org/geysermc/connector/registry/BlockRegistries.java index 19dd40ee4..58735a2b8 100644 --- a/connector/src/main/java/org/geysermc/connector/registry/BlockRegistries.java +++ b/connector/src/main/java/org/geysermc/connector/registry/BlockRegistries.java @@ -39,16 +39,31 @@ import org.geysermc.connector.utils.Object2IntBiMap; * Holds all the block registries in Geyser. */ public class BlockRegistries { + /** + * A versioned registry which holds {@link BlockMappings} for each version. These block mappings contain + * primarily Bedrock version-specific data. + */ public static final VersionedRegistry BLOCKS = VersionedRegistry.create(RegistryLoaders.empty(Int2ObjectOpenHashMap::new)); + /** + * A mapped registry which stores Java to Bedrock block identifiers. + */ public static final SimpleMappedRegistry JAVA_TO_BEDROCK_IDENTIFIERS = SimpleMappedRegistry.create(RegistryLoaders.empty(Object2ObjectOpenHashMap::new)); + /** + * A mapped registry which stores Java IDs to {@link BlockMapping}, containing miscellaneous information about + * blocks and their behavior in many cases. + */ public static final SimpleMappedRegistry JAVA_BLOCKS = SimpleMappedRegistry.create(RegistryLoaders.empty(Int2ObjectOpenHashMap::new)); + /** + * A (bi)mapped registry containing the Java IDs to identifiers. + */ public static final MappedRegistry> JAVA_IDENTIFIERS = MappedRegistry.create(RegistryLoaders.empty(Object2IntBiMap::new)); - public static final SimpleMappedRegistry JAVA_CLEAN_IDENTIFIERS = SimpleMappedRegistry.create(RegistryLoaders.empty(Int2ObjectOpenHashMap::new)); - + /** + * A registry containing all the waterlogged blockstates. + */ public static final SimpleRegistry WATERLOGGED = SimpleRegistry.create(RegistryLoaders.empty(IntOpenHashSet::new)); static { diff --git a/connector/src/main/java/org/geysermc/connector/registry/Registries.java b/connector/src/main/java/org/geysermc/connector/registry/Registries.java index 5ad14cb5a..5cd2e4806 100644 --- a/connector/src/main/java/org/geysermc/connector/registry/Registries.java +++ b/connector/src/main/java/org/geysermc/connector/registry/Registries.java @@ -56,30 +56,72 @@ import java.util.Set; * Holds all the common registries in Geyser. */ public class Registries { + /** + * A registry holding a CompoundTag of all the known biomes. + */ public static final SimpleRegistry BIOMES = SimpleRegistry.create("bedrock/biome_definitions.dat", RegistryLoaders.NBT); + /** + * A mapped registry which stores a block entity identifier to its {@link BlockEntityTranslator}. + */ public static final SimpleMappedRegistry BLOCK_ENTITIES = SimpleMappedRegistry.create("org.geysermc.connector.network.translators.world.block.entity.BlockEntity", BlockEntityRegistryLoader::new); + /** + * A mapped registry containing which holds block IDs to its {@link BlockCollision}. + */ public static final SimpleMappedRegistry COLLISIONS = SimpleMappedRegistry.create(Pair.of("org.geysermc.connector.network.translators.collision.translators.Translator", "mappings/collision.json"), CollisionRegistryLoader::new); + /** + * A versioned registry which holds a {@link RecipeType} to a corresponding list of {@link CraftingData}. + */ public static final VersionedRegistry>> CRAFTING_DATA = VersionedRegistry.create(RegistryLoaders.empty(Int2ObjectOpenHashMap::new)); + /** + * A registry holding a CompoundTag of the known entity identifiers. + */ public static final SimpleRegistry ENTITY_IDENTIFIERS = SimpleRegistry.create("bedrock/entity_identifiers.dat", RegistryLoaders.NBT); + /** + * A versioned registry which holds {@link ItemMappings} for each version. These item mappings contain + * primarily Bedrock version-specific data. + */ public static final VersionedRegistry ITEMS = VersionedRegistry.create(RegistryLoaders.empty(Int2ObjectOpenHashMap::new)); + /** + * A mapped registry holding the {@link ParticleType} to a corresponding {@link ParticleMapping}, containing various pieces of + * data primarily for how Bedrock should handle the particle. + */ public static final SimpleMappedRegistry PARTICLES = SimpleMappedRegistry.create("mappings/particles.json", ParticleTypesRegistryLoader::new); + /** + * A registry holding all the potion mixes. + */ public static final SimpleRegistry> POTION_MIXES; + /** + * A versioned registry holding all the recipes, with the net ID being the key, and {@link Recipe} as the value. + */ public static final VersionedRegistry> RECIPES = VersionedRegistry.create(RegistryLoaders.empty(Int2ObjectOpenHashMap::new)); + /** + * A mapped registry holding the available records, with the ID of the record being the key, and the {@link SoundEvent} + * as the value. + */ public static final SimpleMappedRegistry RECORDS = SimpleMappedRegistry.create(RegistryLoaders.empty(Int2ObjectOpenHashMap::new)); + /** + * A mapped registry holding sound identifiers to their corresponding {@link SoundMapping}. + */ public static final SimpleMappedRegistry SOUNDS = SimpleMappedRegistry.create("mappings/sounds.json", SoundRegistryLoader::new); + /** + * A mapped registry holding {@link SoundEffect}s to their corresponding {@link Effect}. + */ public static final SimpleMappedRegistry SOUND_EFFECTS = SimpleMappedRegistry.create("mappings/effects.json", SoundEffectsRegistryLoader::new); + /** + * A mapped registry holding {@link SoundHandler}s to their corresponding {@link SoundInteractionHandler}. + */ public static final SimpleMappedRegistry> SOUND_HANDLERS = SimpleMappedRegistry.create("org.geysermc.connector.network.translators.sound.SoundHandler", SoundHandlerRegistryLoader::new); public static void init() { diff --git a/connector/src/main/java/org/geysermc/connector/registry/populator/BlockRegistryPopulator.java b/connector/src/main/java/org/geysermc/connector/registry/populator/BlockRegistryPopulator.java index c119967fa..8ebee1918 100644 --- a/connector/src/main/java/org/geysermc/connector/registry/populator/BlockRegistryPopulator.java +++ b/connector/src/main/java/org/geysermc/connector/registry/populator/BlockRegistryPopulator.java @@ -47,7 +47,9 @@ import org.geysermc.connector.utils.FileUtils; import java.io.DataInputStream; import java.io.InputStream; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.function.BiFunction; import java.util.zip.GZIPInputStream; @@ -235,6 +237,8 @@ public class BlockRegistryPopulator { throw new AssertionError("Unable to load Java block mappings", e); } + List cleanIdentifiers = new ArrayList<>(); + int javaRuntimeId = -1; int bellBlockId = -1; int cobwebBlockId = -1; @@ -278,9 +282,9 @@ public class BlockRegistryPopulator { String cleanJavaIdentifier = BlockUtils.getCleanIdentifier(entry.getKey()); String bedrockIdentifier = entry.getValue().get("bedrock_identifier").asText(); - if (!BlockRegistries.JAVA_CLEAN_IDENTIFIERS.get().containsValue(cleanJavaIdentifier)) { + if (!cleanIdentifiers.contains(cleanJavaIdentifier)) { uniqueJavaId++; - BlockRegistries.JAVA_CLEAN_IDENTIFIERS.register(uniqueJavaId, cleanJavaIdentifier); + cleanIdentifiers.add(cleanJavaIdentifier); } builder.javaIdentifier(javaId);