aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java19
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;
}