package net.minecraft.core;

import com.google.common.collect.Maps;
import org.apache.logging.log4j.LogManager;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.stats.Stats;
import net.minecraft.world.level.storage.loot.entries.LootPoolEntries;
import net.minecraft.world.level.storage.loot.functions.LootItemFunctions;
import net.minecraft.world.level.storage.loot.predicates.LootItemConditions;
import org.apache.commons.lang3.Validate;
import net.minecraft.SharedConstants;
import java.util.stream.StreamSupport;
import java.util.Set;
import java.util.Optional;
import javax.annotation.Nullable;
import java.util.stream.Stream;
import java.util.function.Function;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.DynamicOps;
import com.mojang.serialization.Lifecycle;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType;
import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType;
import net.minecraft.world.level.storage.loot.entries.LootPoolEntryType;
import net.minecraft.world.entity.schedule.Activity;
import net.minecraft.world.entity.schedule.Schedule;
import net.minecraft.world.entity.ai.sensing.SensorType;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.npc.VillagerType;
import net.minecraft.stats.StatType;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.level.levelgen.feature.structures.StructurePoolElementType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTestType;
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTestType;
import net.minecraft.world.level.levelgen.feature.StructurePieceType;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.entity.decoration.Motive;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.world.level.levelgen.feature.featuresize.FeatureSizeType;
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType;
import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType;
import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType;
import net.minecraft.world.level.levelgen.feature.blockplacers.BlockPlacerType;
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.placement.FeatureDecorator;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.level.levelgen.carver.WorldCarver;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.Item;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.resources.ResourceKey;
import java.util.function.Supplier;
import net.minecraft.resources.ResourceLocation;
import java.util.Map;
import org.apache.logging.log4j.Logger;
import com.mojang.serialization.Keyable;
import com.mojang.serialization.Codec;

public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
    protected static final Logger LOGGER;
    private static final Map<ResourceLocation, Supplier<?>> LOADERS;
    public static final ResourceLocation ROOT_REGISTRY_NAME;
    protected static final WritableRegistry<WritableRegistry<?>> WRITABLE_REGISTRY;
    public static final Registry<? extends Registry<?>> REGISTRY;
    public static final ResourceKey<Registry<SoundEvent>> SOUND_EVENT_REGISTRY;
    public static final ResourceKey<Registry<Fluid>> FLUID_REGISTRY;
    public static final ResourceKey<Registry<MobEffect>> MOB_EFFECT_REGISTRY;
    public static final ResourceKey<Registry<Block>> BLOCK_REGISTRY;
    public static final ResourceKey<Registry<Enchantment>> ENCHANTMENT_REGISTRY;
    public static final ResourceKey<Registry<EntityType<?>>> ENTITY_TYPE_REGISTRY;
    public static final ResourceKey<Registry<Item>> ITEM_REGISTRY;
    public static final ResourceKey<Registry<Potion>> POTION_REGISTRY;
    public static final ResourceKey<Registry<WorldCarver<?>>> CARVER_REGISTRY;
    public static final ResourceKey<Registry<SurfaceBuilder<?>>> SURFACE_BUILDER_REGISTRY;
    public static final ResourceKey<Registry<Feature<?>>> FEATURE_REGISTRY;
    public static final ResourceKey<Registry<FeatureDecorator<?>>> DECORATOR_REGISTRY;
    public static final ResourceKey<Registry<Biome>> BIOME_REGISTRY;
    public static final ResourceKey<Registry<BlockStateProviderType<?>>> BLOCK_STATE_PROVIDER_TYPE_REGISTRY;
    public static final ResourceKey<Registry<BlockPlacerType<?>>> BLOCK_PLACER_TYPE_REGISTRY;
    public static final ResourceKey<Registry<FoliagePlacerType<?>>> FOLIAGE_PLACER_TYPE_REGISTRY;
    public static final ResourceKey<Registry<TrunkPlacerType<?>>> TRUNK_PLACER_TYPE_REGISTRY;
    public static final ResourceKey<Registry<TreeDecoratorType<?>>> TREE_DECORATOR_TYPE_REGISTRY;
    public static final ResourceKey<Registry<FeatureSizeType<?>>> FEATURE_SIZE_TYPE_REGISTRY;
    public static final ResourceKey<Registry<ParticleType<?>>> PARTICLE_TYPE_REGISTRY;
    public static final ResourceKey<Registry<Codec<? extends BiomeSource>>> BIOME_SOURCE_REGISTRY;
    public static final ResourceKey<Registry<Codec<? extends ChunkGenerator>>> CHUNK_GENERATOR_REGISTRY;
    public static final ResourceKey<Registry<BlockEntityType<?>>> BLOCK_ENTITY_TYPE_REGISTRY;
    public static final ResourceKey<Registry<Motive>> MOTIVE_REGISTRY;
    public static final ResourceKey<Registry<ResourceLocation>> CUSTOM_STAT_REGISTRY;
    public static final ResourceKey<Registry<ChunkStatus>> CHUNK_STATUS_REGISTRY;
    public static final ResourceKey<Registry<StructureFeature<?>>> STRUCTURE_FEATURE_REGISTRY;
    public static final ResourceKey<Registry<StructurePieceType>> STRUCTURE_PIECE_REGISTRY;
    public static final ResourceKey<Registry<RuleTestType<?>>> RULE_TEST_REGISTRY;
    public static final ResourceKey<Registry<PosRuleTestType<?>>> POS_RULE_TEST_REGISTRY;
    public static final ResourceKey<Registry<StructureProcessorType<?>>> STRUCTURE_PROCESSOR_REGISTRY;
    public static final ResourceKey<Registry<StructurePoolElementType<?>>> STRUCTURE_POOL_ELEMENT_REGISTRY;
    public static final ResourceKey<Registry<MenuType<?>>> MENU_REGISTRY;
    public static final ResourceKey<Registry<RecipeType<?>>> RECIPE_TYPE_REGISTRY;
    public static final ResourceKey<Registry<RecipeSerializer<?>>> RECIPE_SERIALIZER_REGISTRY;
    public static final ResourceKey<Registry<Attribute>> ATTRIBUTE_REGISTRY;
    public static final ResourceKey<Registry<StatType<?>>> STAT_TYPE_REGISTRY;
    public static final ResourceKey<Registry<VillagerType>> VILLAGER_TYPE_REGISTRY;
    public static final ResourceKey<Registry<VillagerProfession>> VILLAGER_PROFESSION_REGISTRY;
    public static final ResourceKey<Registry<PoiType>> POINT_OF_INTEREST_TYPE_REGISTRY;
    public static final ResourceKey<Registry<MemoryModuleType<?>>> MEMORY_MODULE_TYPE_REGISTRY;
    public static final ResourceKey<Registry<SensorType<?>>> SENSOR_TYPE_REGISTRY;
    public static final ResourceKey<Registry<Schedule>> SCHEDULE_REGISTRY;
    public static final ResourceKey<Registry<Activity>> ACTIVITY_REGISTRY;
    public static final ResourceKey<Registry<LootPoolEntryType>> LOOT_ENTRY_REGISTRY;
    public static final ResourceKey<Registry<LootItemFunctionType>> LOOT_FUNCTION_REGISTRY;
    public static final ResourceKey<Registry<LootItemConditionType>> LOOT_ITEM_REGISTRY;
    public static final ResourceKey<Registry<DimensionType>> DIMENSION_TYPE_REGISTRY;
    public static final ResourceKey<Registry<Level>> DIMENSION_REGISTRY;
    public static final ResourceKey<Registry<LevelStem>> LEVEL_STEM_REGISTRY;
    public static final Registry<SoundEvent> SOUND_EVENT;
    public static final DefaultedRegistry<Fluid> FLUID;
    public static final Registry<MobEffect> MOB_EFFECT;
    public static final DefaultedRegistry<Block> BLOCK;
    public static final Registry<Enchantment> ENCHANTMENT;
    public static final DefaultedRegistry<EntityType<?>> ENTITY_TYPE;
    public static final DefaultedRegistry<Item> ITEM;
    public static final DefaultedRegistry<Potion> POTION;
    public static final Registry<WorldCarver<?>> CARVER;
    public static final Registry<SurfaceBuilder<?>> SURFACE_BUILDER;
    public static final Registry<Feature<?>> FEATURE;
    public static final Registry<FeatureDecorator<?>> DECORATOR;
    public static final Registry<Biome> BIOME;
    public static final Registry<BlockStateProviderType<?>> BLOCKSTATE_PROVIDER_TYPES;
    public static final Registry<BlockPlacerType<?>> BLOCK_PLACER_TYPES;
    public static final Registry<FoliagePlacerType<?>> FOLIAGE_PLACER_TYPES;
    public static final Registry<TrunkPlacerType<?>> TRUNK_PLACER_TYPES;
    public static final Registry<TreeDecoratorType<?>> TREE_DECORATOR_TYPES;
    public static final Registry<FeatureSizeType<?>> FEATURE_SIZE_TYPES;
    public static final Registry<ParticleType<?>> PARTICLE_TYPE;
    public static final Registry<Codec<? extends BiomeSource>> BIOME_SOURCE;
    public static final Registry<Codec<? extends ChunkGenerator>> CHUNK_GENERATOR;
    public static final Registry<BlockEntityType<?>> BLOCK_ENTITY_TYPE;
    public static final DefaultedRegistry<Motive> MOTIVE;
    public static final Registry<ResourceLocation> CUSTOM_STAT;
    public static final DefaultedRegistry<ChunkStatus> CHUNK_STATUS;
    public static final Registry<StructureFeature<?>> STRUCTURE_FEATURE;
    public static final Registry<StructurePieceType> STRUCTURE_PIECE;
    public static final Registry<RuleTestType<?>> RULE_TEST;
    public static final Registry<PosRuleTestType<?>> POS_RULE_TEST;
    public static final Registry<StructureProcessorType<?>> STRUCTURE_PROCESSOR;
    public static final Registry<StructurePoolElementType<?>> STRUCTURE_POOL_ELEMENT;
    public static final Registry<MenuType<?>> MENU;
    public static final Registry<RecipeType<?>> RECIPE_TYPE;
    public static final Registry<RecipeSerializer<?>> RECIPE_SERIALIZER;
    public static final Registry<Attribute> ATTRIBUTE;
    public static final Registry<StatType<?>> STAT_TYPE;
    public static final DefaultedRegistry<VillagerType> VILLAGER_TYPE;
    public static final DefaultedRegistry<VillagerProfession> VILLAGER_PROFESSION;
    public static final DefaultedRegistry<PoiType> POINT_OF_INTEREST_TYPE;
    public static final DefaultedRegistry<MemoryModuleType<?>> MEMORY_MODULE_TYPE;
    public static final DefaultedRegistry<SensorType<?>> SENSOR_TYPE;
    public static final Registry<Schedule> SCHEDULE;
    public static final Registry<Activity> ACTIVITY;
    public static final Registry<LootPoolEntryType> LOOT_POOL_ENTRY_TYPE;
    public static final Registry<LootItemFunctionType> LOOT_FUNCTION_TYPE;
    public static final Registry<LootItemConditionType> LOOT_CONDITION_TYPE;
    private final ResourceKey<Registry<T>> key;
    private final Lifecycle lifecycle;
    
    private static <T> ResourceKey<Registry<T>> createRegistryKey(final String string) {
        return ResourceKey.<T>createRegistryKey(new ResourceLocation(string));
    }
    
    private static <T extends WritableRegistry<?>> void checkRegistry(final WritableRegistry<T> gs) {
        // 
        // This method could not be decompiled.
        // 
        // Original Bytecode:
        // 
        //     1: aload_0         /* gs */
        //     2: invokedynamic   BootstrapMethod #0, accept:(Lnet/minecraft/core/WritableRegistry;)Ljava/util/function/Consumer;
        //     7: invokevirtual   net/minecraft/core/WritableRegistry.forEach:(Ljava/util/function/Consumer;)V
        //    10: return         
        //    Signature:
        //  <T:Lnet/minecraft/core/WritableRegistry<*>;>(Lnet/minecraft/core/WritableRegistry<TT;>;)V
        //    MethodParameters:
        //  Name  Flags  
        //  ----  -----
        //  gs    
        // 
        // The error that occurred was:
        // 
        // java.lang.IllegalStateException: Could not infer any expression.
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:374)
        //     at com.strobel.decompiler.ast.TypeAnalysis.run(TypeAnalysis.java:96)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:344)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:42)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:214)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:99)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethodBody(AstBuilder.java:782)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethod(AstBuilder.java:675)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addTypeMembers(AstBuilder.java:552)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeCore(AstBuilder.java:519)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeNoCache(AstBuilder.java:161)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createType(AstBuilder.java:150)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addType(AstBuilder.java:125)
        //     at cuchaz.enigma.SourceProvider.getSources(SourceProvider.java:85)
        //     at cuchaz.enigma.EnigmaProject$JarExport.decompileClass(EnigmaProject.java:241)
        //     at cuchaz.enigma.EnigmaProject$JarExport.lambda$decompile$1(EnigmaProject.java:230)
        //     at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        //     at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
        //     at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        //     at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        //     at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:952)
        //     at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:926)
        //     at java.base/java.util.stream.AbstractTask.compute(AbstractTask.java:327)
        //     at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
        //     at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        //     at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        //     at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        //     at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        //     at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
        // 
        throw new IllegalStateException("An error occurred while decompiling this method.");
    }
    
    private static <T> Registry<T> registerSimple(final ResourceKey<Registry<T>> ug, final Supplier<T> supplier) {
        return Registry.<T>registerSimple(ug, Lifecycle.experimental(), supplier);
    }
    
    private static <T> DefaultedRegistry<T> registerDefaulted(final ResourceKey<Registry<T>> ug, final String string, final Supplier<T> supplier) {
        return Registry.<T>registerDefaulted(ug, string, Lifecycle.experimental(), supplier);
    }
    
    private static <T> Registry<T> registerSimple(final ResourceKey<Registry<T>> ug, final Lifecycle lifecycle, final Supplier<T> supplier) {
        return Registry.<T, MappedRegistry<T>>internalRegister(ug, new MappedRegistry<T>(ug, lifecycle), supplier);
    }
    
    private static <T> DefaultedRegistry<T> registerDefaulted(final ResourceKey<Registry<T>> ug, final String string, final Lifecycle lifecycle, final Supplier<T> supplier) {
        return Registry.<T, DefaultedRegistry<T>>internalRegister(ug, new DefaultedRegistry<T>(string, ug, lifecycle), supplier);
    }
    
    private static <T, R extends WritableRegistry<T>> R internalRegister(final ResourceKey<Registry<T>> ug, final R gs, final Supplier<T> supplier) {
        final ResourceLocation uh4 = ug.location();
        Registry.LOADERS.put(uh4, supplier);
        final WritableRegistry<R> gs2 = (WritableRegistry<R>)Registry.WRITABLE_REGISTRY;
        return gs2.<R>register((ResourceKey<R>)ug, gs);
    }
    
    protected Registry(final ResourceKey<Registry<T>> ug, final Lifecycle lifecycle) {
        this.key = ug;
        this.lifecycle = lifecycle;
    }
    
    @Override
    public String toString() {
        return "Registry[" + this.key + " (" + this.lifecycle + ")]";
    }
    
    public <U> DataResult<Pair<T, U>> decode(final DynamicOps<U> dynamicOps, final U object) {
        if (dynamicOps.compressMaps()) {
            final int integer3;
            T object2;
            return (DataResult<Pair<T, U>>)dynamicOps.getNumberValue(object).flatMap(number -> {
                integer3 = number.intValue();
                if (!this.containsId(integer3)) {
                    return DataResult.error("Unknown registry id: " + number);
                }
                else {
                    object2 = this.byId(integer3);
                    return DataResult.success(object2, this.lifecycle);
                }
            }).map(object -> Pair.of(object, dynamicOps.empty()));
        }
        return (DataResult<Pair<T, U>>)ResourceLocation.CODEC.decode((DynamicOps)dynamicOps, object).addLifecycle(this.lifecycle).flatMap(pair -> {
            if (!this.containsKey((ResourceLocation)pair.getFirst())) {
                return DataResult.error("Unknown registry key: " + pair.getFirst());
            }
            else {
                return DataResult.success(pair.mapFirst((Function)this::get), this.lifecycle);
            }
        });
    }
    
    public <U> DataResult<U> encode(final T object1, final DynamicOps<U> dynamicOps, final U object3) {
        final ResourceLocation uh5 = this.getKey(object1);
        if (uh5 == null) {
            return (DataResult<U>)DataResult.error("Unknown registry element " + object1);
        }
        if (dynamicOps.compressMaps()) {
            return (DataResult<U>)dynamicOps.mergeToPrimitive(object3, dynamicOps.createInt(this.getId(object1))).setLifecycle(this.lifecycle);
        }
        return (DataResult<U>)dynamicOps.mergeToPrimitive(object3, dynamicOps.createString(uh5.toString())).setLifecycle(this.lifecycle);
    }
    
    public <U> Stream<U> keys(final DynamicOps<U> dynamicOps) {
        return this.keySet().stream().<U>map(uh -> dynamicOps.createString(uh.toString()));
    }
    
    @Nullable
    public abstract ResourceLocation getKey(final T object);
    
    public abstract Optional<ResourceKey<T>> getResourceKey(final T object);
    
    public abstract int getId(@Nullable final T object);
    
    @Nullable
    public abstract T get(@Nullable final ResourceKey<T> ug);
    
    @Nullable
    public abstract T get(@Nullable final ResourceLocation uh);
    
    public abstract Optional<T> getOptional(@Nullable final ResourceLocation uh);
    
    public abstract Set<ResourceLocation> keySet();
    
    public Stream<T> stream() {
        return StreamSupport.<T>stream(this.spliterator(), false);
    }
    
    public abstract boolean containsKey(final ResourceLocation uh);
    
    public abstract boolean persistent(final ResourceKey<T> ug);
    
    public abstract boolean containsId(final int integer);
    
    public static <T> T register(final Registry<? super T> gl, final String string, final T object) {
        return Registry.register(gl, new ResourceLocation(string), object);
    }
    
    public static <V, T extends V> T register(final Registry<V> gl, final ResourceLocation uh, final T object) {
        return ((WritableRegistry)gl).<T>register(ResourceKey.<V>create(gl.key, uh), object);
    }
    
    public static <V, T extends V> T registerMapping(final Registry<V> gl, final int integer, final String string, final T object) {
        return ((WritableRegistry)gl).<T>registerMapping(integer, ResourceKey.<V>create(gl.key, new ResourceLocation(string)), object);
    }
    
    static {
        LOGGER = LogManager.getLogger();
        LOADERS = Maps.newLinkedHashMap();
        ROOT_REGISTRY_NAME = new ResourceLocation("root");
        WRITABLE_REGISTRY = new MappedRegistry<WritableRegistry<?>>(Registry.<WritableRegistry<?>>createRegistryKey("root"), Lifecycle.experimental());
        REGISTRY = Registry.WRITABLE_REGISTRY;
        SOUND_EVENT_REGISTRY = Registry.<SoundEvent>createRegistryKey("sound_event");
        FLUID_REGISTRY = Registry.<Fluid>createRegistryKey("fluid");
        MOB_EFFECT_REGISTRY = Registry.<MobEffect>createRegistryKey("mob_effect");
        BLOCK_REGISTRY = Registry.<Block>createRegistryKey("block");
        ENCHANTMENT_REGISTRY = Registry.<Enchantment>createRegistryKey("enchantment");
        ENTITY_TYPE_REGISTRY = Registry.<EntityType<?>>createRegistryKey("entity_type");
        ITEM_REGISTRY = Registry.<Item>createRegistryKey("item");
        POTION_REGISTRY = Registry.<Potion>createRegistryKey("potion");
        CARVER_REGISTRY = Registry.<WorldCarver<?>>createRegistryKey("carver");
        SURFACE_BUILDER_REGISTRY = Registry.<SurfaceBuilder<?>>createRegistryKey("surface_builder");
        FEATURE_REGISTRY = Registry.<Feature<?>>createRegistryKey("feature");
        DECORATOR_REGISTRY = Registry.<FeatureDecorator<?>>createRegistryKey("decorator");
        BIOME_REGISTRY = Registry.<Biome>createRegistryKey("biome");
        BLOCK_STATE_PROVIDER_TYPE_REGISTRY = Registry.<BlockStateProviderType<?>>createRegistryKey("block_state_provider_type");
        BLOCK_PLACER_TYPE_REGISTRY = Registry.<BlockPlacerType<?>>createRegistryKey("block_placer_type");
        FOLIAGE_PLACER_TYPE_REGISTRY = Registry.<FoliagePlacerType<?>>createRegistryKey("foliage_placer_type");
        TRUNK_PLACER_TYPE_REGISTRY = Registry.<TrunkPlacerType<?>>createRegistryKey("trunk_placer_type");
        TREE_DECORATOR_TYPE_REGISTRY = Registry.<TreeDecoratorType<?>>createRegistryKey("tree_decorator_type");
        FEATURE_SIZE_TYPE_REGISTRY = Registry.<FeatureSizeType<?>>createRegistryKey("feature_size_type");
        PARTICLE_TYPE_REGISTRY = Registry.<ParticleType<?>>createRegistryKey("particle_type");
        BIOME_SOURCE_REGISTRY = Registry.<Codec<? extends BiomeSource>>createRegistryKey("biome_source");
        CHUNK_GENERATOR_REGISTRY = Registry.<Codec<? extends ChunkGenerator>>createRegistryKey("chunk_generator");
        BLOCK_ENTITY_TYPE_REGISTRY = Registry.<BlockEntityType<?>>createRegistryKey("block_entity_type");
        MOTIVE_REGISTRY = Registry.<Motive>createRegistryKey("motive");
        CUSTOM_STAT_REGISTRY = Registry.<ResourceLocation>createRegistryKey("custom_stat");
        CHUNK_STATUS_REGISTRY = Registry.<ChunkStatus>createRegistryKey("chunk_status");
        STRUCTURE_FEATURE_REGISTRY = Registry.<StructureFeature<?>>createRegistryKey("structure_feature");
        STRUCTURE_PIECE_REGISTRY = Registry.<StructurePieceType>createRegistryKey("structure_piece");
        RULE_TEST_REGISTRY = Registry.<RuleTestType<?>>createRegistryKey("rule_test");
        POS_RULE_TEST_REGISTRY = Registry.<PosRuleTestType<?>>createRegistryKey("pos_rule_test");
        STRUCTURE_PROCESSOR_REGISTRY = Registry.<StructureProcessorType<?>>createRegistryKey("structure_processor");
        STRUCTURE_POOL_ELEMENT_REGISTRY = Registry.<StructurePoolElementType<?>>createRegistryKey("structure_pool_element");
        MENU_REGISTRY = Registry.<MenuType<?>>createRegistryKey("menu");
        RECIPE_TYPE_REGISTRY = Registry.<RecipeType<?>>createRegistryKey("recipe_type");
        RECIPE_SERIALIZER_REGISTRY = Registry.<RecipeSerializer<?>>createRegistryKey("recipe_serializer");
        ATTRIBUTE_REGISTRY = Registry.<Attribute>createRegistryKey("attribute");
        STAT_TYPE_REGISTRY = Registry.<StatType<?>>createRegistryKey("stat_type");
        VILLAGER_TYPE_REGISTRY = Registry.<VillagerType>createRegistryKey("villager_type");
        VILLAGER_PROFESSION_REGISTRY = Registry.<VillagerProfession>createRegistryKey("villager_profession");
        POINT_OF_INTEREST_TYPE_REGISTRY = Registry.<PoiType>createRegistryKey("point_of_interest_type");
        MEMORY_MODULE_TYPE_REGISTRY = Registry.<MemoryModuleType<?>>createRegistryKey("memory_module_type");
        SENSOR_TYPE_REGISTRY = Registry.<SensorType<?>>createRegistryKey("sensor_type");
        SCHEDULE_REGISTRY = Registry.<Schedule>createRegistryKey("schedule");
        ACTIVITY_REGISTRY = Registry.<Activity>createRegistryKey("activity");
        LOOT_ENTRY_REGISTRY = Registry.<LootPoolEntryType>createRegistryKey("loot_pool_entry_type");
        LOOT_FUNCTION_REGISTRY = Registry.<LootItemFunctionType>createRegistryKey("loot_function_type");
        LOOT_ITEM_REGISTRY = Registry.<LootItemConditionType>createRegistryKey("loot_condition_type");
        DIMENSION_TYPE_REGISTRY = Registry.<DimensionType>createRegistryKey("dimension_type");
        DIMENSION_REGISTRY = Registry.<Level>createRegistryKey("dimension");
        LEVEL_STEM_REGISTRY = Registry.<LevelStem>createRegistryKey("dimension");
        SOUND_EVENT = Registry.<SoundEvent>registerSimple(Registry.SOUND_EVENT_REGISTRY, () -> SoundEvents.ITEM_PICKUP);
        FLUID = Registry.<Fluid>registerDefaulted(Registry.FLUID_REGISTRY, "empty", () -> Fluids.EMPTY);
        MOB_EFFECT = Registry.<MobEffect>registerSimple(Registry.MOB_EFFECT_REGISTRY, () -> MobEffects.LUCK);
        BLOCK = Registry.<Block>registerDefaulted(Registry.BLOCK_REGISTRY, "air", () -> Blocks.AIR);
        ENCHANTMENT = Registry.<Enchantment>registerSimple(Registry.ENCHANTMENT_REGISTRY, () -> Enchantments.BLOCK_FORTUNE);
        ENTITY_TYPE = Registry.<EntityType<?>>registerDefaulted(Registry.ENTITY_TYPE_REGISTRY, "pig", () -> EntityType.PIG);
        ITEM = Registry.<Item>registerDefaulted(Registry.ITEM_REGISTRY, "air", () -> Items.AIR);
        POTION = Registry.<Potion>registerDefaulted(Registry.POTION_REGISTRY, "empty", () -> Potions.EMPTY);
        CARVER = Registry.<WorldCarver<?>>registerSimple(Registry.CARVER_REGISTRY, () -> WorldCarver.CAVE);
        SURFACE_BUILDER = Registry.<SurfaceBuilder<?>>registerSimple(Registry.SURFACE_BUILDER_REGISTRY, () -> SurfaceBuilder.DEFAULT);
        FEATURE = Registry.<Feature<?>>registerSimple(Registry.FEATURE_REGISTRY, () -> Feature.ORE);
        DECORATOR = Registry.<FeatureDecorator<?>>registerSimple(Registry.DECORATOR_REGISTRY, () -> FeatureDecorator.NOPE);
        BIOME = Registry.<Biome>registerSimple(Registry.BIOME_REGISTRY, () -> Biomes.DEFAULT);
        BLOCKSTATE_PROVIDER_TYPES = Registry.<BlockStateProviderType<?>>registerSimple(Registry.BLOCK_STATE_PROVIDER_TYPE_REGISTRY, () -> BlockStateProviderType.SIMPLE_STATE_PROVIDER);
        BLOCK_PLACER_TYPES = Registry.<BlockPlacerType<?>>registerSimple(Registry.BLOCK_PLACER_TYPE_REGISTRY, () -> BlockPlacerType.SIMPLE_BLOCK_PLACER);
        FOLIAGE_PLACER_TYPES = Registry.<FoliagePlacerType<?>>registerSimple(Registry.FOLIAGE_PLACER_TYPE_REGISTRY, () -> FoliagePlacerType.BLOB_FOLIAGE_PLACER);
        TRUNK_PLACER_TYPES = Registry.<TrunkPlacerType<?>>registerSimple(Registry.TRUNK_PLACER_TYPE_REGISTRY, () -> TrunkPlacerType.STRAIGHT_TRUNK_PLACER);
        TREE_DECORATOR_TYPES = Registry.<TreeDecoratorType<?>>registerSimple(Registry.TREE_DECORATOR_TYPE_REGISTRY, () -> TreeDecoratorType.LEAVE_VINE);
        FEATURE_SIZE_TYPES = Registry.<FeatureSizeType<?>>registerSimple(Registry.FEATURE_SIZE_TYPE_REGISTRY, () -> FeatureSizeType.TWO_LAYERS_FEATURE_SIZE);
        PARTICLE_TYPE = Registry.<ParticleType<?>>registerSimple(Registry.PARTICLE_TYPE_REGISTRY, () -> ParticleTypes.BLOCK);
        BIOME_SOURCE = Registry.<Codec<? extends BiomeSource>>registerSimple(Registry.BIOME_SOURCE_REGISTRY, Lifecycle.stable(), () -> BiomeSource.CODEC);
        CHUNK_GENERATOR = Registry.<Codec<? extends ChunkGenerator>>registerSimple(Registry.CHUNK_GENERATOR_REGISTRY, Lifecycle.stable(), () -> ChunkGenerator.CODEC);
        BLOCK_ENTITY_TYPE = Registry.<BlockEntityType<?>>registerSimple(Registry.BLOCK_ENTITY_TYPE_REGISTRY, () -> BlockEntityType.FURNACE);
        MOTIVE = Registry.<Motive>registerDefaulted(Registry.MOTIVE_REGISTRY, "kebab", () -> Motive.KEBAB);
        CUSTOM_STAT = Registry.<ResourceLocation>registerSimple(Registry.CUSTOM_STAT_REGISTRY, () -> Stats.JUMP);
        CHUNK_STATUS = Registry.<ChunkStatus>registerDefaulted(Registry.CHUNK_STATUS_REGISTRY, "empty", () -> ChunkStatus.EMPTY);
        STRUCTURE_FEATURE = Registry.<StructureFeature<?>>registerSimple(Registry.STRUCTURE_FEATURE_REGISTRY, () -> StructureFeature.MINESHAFT);
        STRUCTURE_PIECE = Registry.<StructurePieceType>registerSimple(Registry.STRUCTURE_PIECE_REGISTRY, () -> StructurePieceType.MINE_SHAFT_ROOM);
        RULE_TEST = Registry.<RuleTestType<?>>registerSimple(Registry.RULE_TEST_REGISTRY, () -> RuleTestType.ALWAYS_TRUE_TEST);
        POS_RULE_TEST = Registry.<PosRuleTestType<?>>registerSimple(Registry.POS_RULE_TEST_REGISTRY, () -> PosRuleTestType.ALWAYS_TRUE_TEST);
        STRUCTURE_PROCESSOR = Registry.<StructureProcessorType<?>>registerSimple(Registry.STRUCTURE_PROCESSOR_REGISTRY, () -> StructureProcessorType.BLOCK_IGNORE);
        STRUCTURE_POOL_ELEMENT = Registry.<StructurePoolElementType<?>>registerSimple(Registry.STRUCTURE_POOL_ELEMENT_REGISTRY, () -> StructurePoolElementType.EMPTY);
        MENU = Registry.<MenuType<?>>registerSimple(Registry.MENU_REGISTRY, () -> MenuType.ANVIL);
        RECIPE_TYPE = Registry.<RecipeType<?>>registerSimple(Registry.RECIPE_TYPE_REGISTRY, () -> RecipeType.CRAFTING);
        RECIPE_SERIALIZER = Registry.<RecipeSerializer<?>>registerSimple(Registry.RECIPE_SERIALIZER_REGISTRY, () -> RecipeSerializer.SHAPELESS_RECIPE);
        ATTRIBUTE = Registry.<Attribute>registerSimple(Registry.ATTRIBUTE_REGISTRY, () -> Attributes.LUCK);
        STAT_TYPE = Registry.<StatType<?>>registerSimple(Registry.STAT_TYPE_REGISTRY, () -> Stats.ITEM_USED);
        VILLAGER_TYPE = Registry.<VillagerType>registerDefaulted(Registry.VILLAGER_TYPE_REGISTRY, "plains", () -> VillagerType.PLAINS);
        VILLAGER_PROFESSION = Registry.<VillagerProfession>registerDefaulted(Registry.VILLAGER_PROFESSION_REGISTRY, "none", () -> VillagerProfession.NONE);
        POINT_OF_INTEREST_TYPE = Registry.<PoiType>registerDefaulted(Registry.POINT_OF_INTEREST_TYPE_REGISTRY, "unemployed", () -> PoiType.UNEMPLOYED);
        MEMORY_MODULE_TYPE = Registry.<MemoryModuleType<?>>registerDefaulted(Registry.MEMORY_MODULE_TYPE_REGISTRY, "dummy", () -> MemoryModuleType.DUMMY);
        SENSOR_TYPE = Registry.<SensorType<?>>registerDefaulted(Registry.SENSOR_TYPE_REGISTRY, "dummy", () -> SensorType.DUMMY);
        SCHEDULE = Registry.<Schedule>registerSimple(Registry.SCHEDULE_REGISTRY, () -> Schedule.EMPTY);
        ACTIVITY = Registry.<Activity>registerSimple(Registry.ACTIVITY_REGISTRY, () -> Activity.IDLE);
        LOOT_POOL_ENTRY_TYPE = Registry.<LootPoolEntryType>registerSimple(Registry.LOOT_ENTRY_REGISTRY, () -> LootPoolEntries.EMPTY);
        LOOT_FUNCTION_TYPE = Registry.<LootItemFunctionType>registerSimple(Registry.LOOT_FUNCTION_REGISTRY, () -> LootItemFunctions.SET_COUNT);
        LOOT_CONDITION_TYPE = Registry.<LootItemConditionType>registerSimple(Registry.LOOT_ITEM_REGISTRY, () -> LootItemConditions.INVERTED);
        Registry.LOADERS.forEach((uh, supplier) -> {
            if (supplier.get() == null) {
                Registry.LOGGER.error("Unable to bootstrap registry '{}'", uh);
            }
            return;
        });
        Registry.<WritableRegistry<?>>checkRegistry(Registry.WRITABLE_REGISTRY);
    }
}
