|
20 | 20 | package net.minecraftforge.registries;
|
21 | 21 |
|
22 | 22 | import net.minecraft.Bootstrap;
|
23 |
| -import net.minecraft.block.Block; |
24 |
| -import net.minecraft.block.entity.BlockEntityType; |
25 |
| -import net.minecraft.container.ContainerType; |
26 |
| -import net.minecraft.enchantment.Enchantment; |
27 |
| -import net.minecraft.entity.EntityType; |
28 |
| -import net.minecraft.entity.ai.brain.Activity; |
29 |
| -import net.minecraft.entity.ai.brain.MemoryModuleType; |
30 |
| -import net.minecraft.entity.ai.brain.Schedule; |
31 |
| -import net.minecraft.entity.ai.brain.sensor.SensorType; |
32 |
| -import net.minecraft.entity.decoration.painting.PaintingMotive; |
33 |
| -import net.minecraft.entity.effect.StatusEffect; |
34 |
| -import net.minecraft.fluid.Fluid; |
35 |
| -import net.minecraft.item.Item; |
36 |
| -import net.minecraft.particle.ParticleType; |
37 |
| -import net.minecraft.potion.Potion; |
38 |
| -import net.minecraft.recipe.RecipeSerializer; |
39 |
| -import net.minecraft.recipe.RecipeType; |
40 |
| -import net.minecraft.sound.SoundEvent; |
41 |
| -import net.minecraft.stat.StatType; |
42 |
| -import net.minecraft.structure.StructurePieceType; |
43 |
| -import net.minecraft.structure.pool.StructurePoolElementType; |
44 |
| -import net.minecraft.structure.processor.StructureProcessorType; |
45 |
| -import net.minecraft.structure.rule.RuleTestType; |
46 | 23 | import net.minecraft.util.Identifier;
|
47 |
| -import net.minecraft.util.registry.Registry; |
48 |
| -import net.minecraft.village.VillagerProfession; |
49 |
| -import net.minecraft.village.VillagerType; |
50 |
| -import net.minecraft.world.biome.Biome; |
51 |
| -import net.minecraft.world.biome.source.BiomeSourceType; |
52 |
| -import net.minecraft.world.chunk.ChunkStatus; |
53 |
| -import net.minecraft.world.dimension.DimensionType; |
54 |
| -import net.minecraft.world.gen.carver.Carver; |
55 |
| -import net.minecraft.world.gen.chunk.ChunkGeneratorType; |
56 |
| -import net.minecraft.world.gen.decorator.Decorator; |
57 |
| -import net.minecraft.world.gen.feature.Feature; |
58 |
| -import net.minecraft.world.gen.feature.StructureFeature; |
59 |
| -import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder; |
60 |
| -import net.minecraft.world.poi.PointOfInterestType; |
61 |
| - |
62 |
| -import net.patchworkmc.impl.registries.RegistryClassMapping; |
63 |
| -import net.patchworkmc.impl.registries.RegistryEventDispatcher; |
64 | 24 |
|
65 | 25 | /**
|
66 | 26 | * A class that exposes static references to all vanilla registries.
|
@@ -101,65 +61,56 @@ public class ForgeRegistries {
|
101 | 61 | public static final IForgeRegistry SURFACE_BUILDERS;
|
102 | 62 | public static final IForgeRegistry PROFESSIONS;
|
103 | 63 |
|
104 |
| - // TODO: Forge Registries, when these are implemented |
| 64 | + // TODO: Forge Registries, unimplemented |
105 | 65 | // public static final IForgeRegistry MOD_DIMENSIONS = wrap(ModDimension.class);
|
106 | 66 | // public static final IForgeRegistry DATA_SERIALIZERS = wrap(DataSerializerEntry.class);
|
107 | 67 |
|
108 | 68 | static {
|
109 | 69 | // Make sure all the registries have been setup first.
|
110 | 70 | Bootstrap.initialize();
|
111 | 71 |
|
112 |
| - BLOCKS = wrap("block", Block.class); |
113 |
| - ITEMS = wrap("item", Item.class); |
114 |
| - ACTIVITIES = wrap("activity", Activity.class); |
115 |
| - BIOMES = wrap("biome", Biome.class); |
116 |
| - BIOME_PROVIDER_TYPES = wrap("biome_source_type", BiomeSourceType.class); |
117 |
| - TILE_ENTITIES = wrap("block_entity_type", BlockEntityType.class); |
118 |
| - WORLD_CARVERS = wrap("carver", Carver.class); |
119 |
| - CHUNK_GENERATOR_TYPES = wrap("chunk_generator_type", ChunkGeneratorType.class); |
120 |
| - CHUNK_STATUS = wrap("chunk_status", ChunkStatus.class); |
121 |
| - wrap("custom_stat", Identifier.class); |
122 |
| - DECORATORS = wrap("decorator", Decorator.class); |
123 |
| - wrap("dimension_type", DimensionType.class); |
124 |
| - ENCHANTMENTS = wrap("enchantment", Enchantment.class); |
125 |
| - ENTITIES = wrap("entity_type", EntityType.class); |
126 |
| - FEATURES = wrap("feature", Feature.class); |
127 |
| - FLUIDS = wrap("fluid", Fluid.class); |
128 |
| - MEMORY_MODULE_TYPES = wrap("memory_module_type", MemoryModuleType.class); |
129 |
| - CONTAINERS = wrap("menu", ContainerType.class); |
130 |
| - POTIONS = wrap("mob_effect", StatusEffect.class); |
131 |
| - PAINTING_TYPES = wrap("motive", PaintingMotive.class); |
132 |
| - PARTICLE_TYPES = wrap("particle_type", ParticleType.class); |
133 |
| - POI_TYPES = wrap("point_of_interest_type", PointOfInterestType.class); |
134 |
| - POTION_TYPES = wrap("potion", Potion.class); |
135 |
| - RECIPE_SERIALIZERS = wrap("recipe_serializer", RecipeSerializer.class); |
136 |
| - wrap("recipe_type", RecipeType.class); |
137 |
| - wrap("rule_test", RuleTestType.class); |
138 |
| - SCHEDULES = wrap("schedule", Schedule.class); |
139 |
| - SENSOR_TYPES = wrap("sensor_type", SensorType.class); |
140 |
| - SOUND_EVENTS = wrap("sound_event", SoundEvent.class); |
141 |
| - STAT_TYPES = wrap("stat_type", StatType.class); |
142 |
| - wrap("structure_feature", StructureFeature.class); |
143 |
| - wrap("structure_piece", StructurePieceType.class); |
144 |
| - wrap("structure_pool_element", StructurePoolElementType.class); |
145 |
| - wrap("structure_processor", StructureProcessorType.class); |
146 |
| - SURFACE_BUILDERS = wrap("surface_builder", SurfaceBuilder.class); |
147 |
| - PROFESSIONS = wrap("villager_profession", VillagerProfession.class); |
148 |
| - wrap("villager_type", VillagerType.class); |
| 72 | + BLOCKS = GameData.wrapVanilla(GameData.BLOCKS); |
| 73 | + ITEMS = GameData.wrapVanilla(GameData.ITEMS); |
| 74 | + ACTIVITIES = GameData.wrapVanilla(GameData.ACTIVITIES); |
| 75 | + BIOMES = GameData.wrapVanilla(GameData.BIOMES); |
| 76 | + BIOME_PROVIDER_TYPES = GameData.wrapVanilla(GameData.BIOME_PROVIDER_TYPES); |
| 77 | + TILE_ENTITIES = GameData.wrapVanilla(GameData.TILEENTITIES); |
| 78 | + WORLD_CARVERS = GameData.wrapVanilla(GameData.WORLD_CARVERS); |
| 79 | + CHUNK_GENERATOR_TYPES = GameData.wrapVanilla(GameData.CHUNK_GENERATOR_TYPES); |
| 80 | + CHUNK_STATUS = GameData.wrapVanilla(GameData.CHUNK_STATUS); |
| 81 | + wrap("custom_stat"); |
| 82 | + DECORATORS = GameData.wrapVanilla(GameData.DECORATORS); |
| 83 | + wrap("dimension_type"); |
| 84 | + ENCHANTMENTS = GameData.wrapVanilla(GameData.ENCHANTMENTS); |
| 85 | + ENTITIES = GameData.wrapVanilla(GameData.ENTITIES); |
| 86 | + FEATURES = GameData.wrapVanilla(GameData.FEATURES); |
| 87 | + FLUIDS = GameData.wrapVanilla(GameData.FLUIDS); |
| 88 | + MEMORY_MODULE_TYPES = GameData.wrapVanilla(GameData.MEMORY_MODULE_TYPES); |
| 89 | + CONTAINERS = GameData.wrapVanilla(GameData.CONTAINERS); |
| 90 | + POTIONS = GameData.wrapVanilla(GameData.POTIONS); |
| 91 | + PAINTING_TYPES = GameData.wrapVanilla(GameData.PAINTING_TYPES); |
| 92 | + PARTICLE_TYPES = GameData.wrapVanilla(GameData.PARTICLE_TYPES); |
| 93 | + POI_TYPES = GameData.wrapVanilla(GameData.POI_TYPES); |
| 94 | + POTION_TYPES = GameData.wrapVanilla(GameData.POTIONTYPES); |
| 95 | + RECIPE_SERIALIZERS = GameData.wrapVanilla(GameData.RECIPE_SERIALIZERS); |
| 96 | + wrap("recipe_type"); |
| 97 | + wrap("rule_test"); |
| 98 | + SCHEDULES = GameData.wrapVanilla(GameData.SCHEDULES); |
| 99 | + SENSOR_TYPES = GameData.wrapVanilla(GameData.SENSOR_TYPES); |
| 100 | + SOUND_EVENTS = GameData.wrapVanilla(GameData.SOUNDEVENTS); |
| 101 | + STAT_TYPES = GameData.wrapVanilla(GameData.STAT_TYPES); |
| 102 | + wrap("structure_feature"); |
| 103 | + wrap("structure_piece"); |
| 104 | + wrap("structure_pool_element"); |
| 105 | + wrap("structure_processor"); |
| 106 | + SURFACE_BUILDERS = GameData.wrapVanilla(GameData.SURFACE_BUILDERS); |
| 107 | + PROFESSIONS = GameData.wrapVanilla(GameData.PROFESSIONS); |
| 108 | + wrap("villager_type"); |
149 | 109 | }
|
150 | 110 |
|
151 | 111 | @SuppressWarnings("unchecked")
|
152 |
| - private static <T> IForgeRegistry wrap(String name, Class superClazz) { |
153 |
| - Identifier identifier = new Identifier("minecraft", name); |
154 |
| - Registry registry = Registry.REGISTRIES.get(identifier); |
155 |
| - |
156 |
| - ForgeRegistry wrapped = new ForgeRegistry(identifier, registry, superClazz); |
157 |
| - |
158 |
| - RegistryClassMapping.register(wrapped); |
159 |
| - RegistryManager.ACTIVE.addRegistry(identifier, wrapped); |
160 |
| - RegistryEventDispatcher.register(wrapped); |
161 |
| - |
162 |
| - return wrapped; |
| 112 | + private static void wrap(String vanillaName) { |
| 113 | + GameData.wrapVanilla(new Identifier(vanillaName)); |
163 | 114 | }
|
164 | 115 |
|
165 | 116 | public static void init() {
|
|
0 commit comments