diff options
author | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-09-20 20:17:15 -0700 |
---|---|---|
committer | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-09-20 20:17:15 -0700 |
commit | 72daae76ae205f2b4797101ce77696c56d867078 (patch) | |
tree | 79040f3f503f0854b269c74bcd2acc006ca574dd /src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java | |
parent | 3d17eb42809b793e3684d089a3d2bbfd748422cf (diff) | |
download | Iceberg-72daae76ae205f2b4797101ce77696c56d867078.tar.gz Iceberg-72daae76ae205f2b4797101ce77696c56d867078.tar.bz2 Iceberg-72daae76ae205f2b4797101ce77696c56d867078.zip |
Added renderer support for auto registry system.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java')
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java b/src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java index dd7da65..c42a8d0 100644 --- a/src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java +++ b/src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java @@ -14,7 +14,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.client.registry.IRenderFactory; -import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.IForgeRegistry; @@ -32,6 +31,8 @@ public abstract class AutoRegistry private static Map<EntityType<?>, Supplier<AttributeModifierMap.MutableAttribute>> entityAttributes = new HashMap<>(); + private static Map<String, EntityType<? extends Entity>> registeredEntityTypes = new HashMap<>(); + public static void init(String ModID) { MODID = ModID; @@ -60,6 +61,17 @@ public abstract class AutoRegistry } } + public static boolean isEntityTypeRegistered(String name) + { + return registeredEntityTypes.containsKey(name); + } + + @SuppressWarnings("unchecked") + public static <T extends Entity> EntityType<T> getEntityType(String name) + { + return (EntityType<T>) registeredEntityTypes.getOrDefault(name, null); + } + @SuppressWarnings("unchecked") private final <T extends IForgeRegistryEntry<T>> void registerAllOfType(Class<IForgeRegistryEntry<?>> type, RegistryEvent.Register<T> event) { @@ -111,8 +123,8 @@ public abstract class AutoRegistry ResourceLocation resourceLocation = new ResourceLocation(MODID, name); EntityType<T> entityType = (EntityType<T>) builder.build(name).setRegistryName(resourceLocation); - // Register the rendering handler. - RenderingRegistry.registerEntityRenderingHandler(entityType, renderFactory); + // Add this entity type to the registered hashmap. + registeredEntityTypes.put(name, entityType); // Store mob attributes if provided. These will be added in the attribute creation event below. if (attributes != null) @@ -120,7 +132,6 @@ public abstract class AutoRegistry entityAttributes.put(entityType, attributes); } - return entityType; } |