package com.anthonyhilyard.iceberg.registry; import java.util.HashMap; import java.util.Map; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraftforge.client.event.EntityRenderersEvent; public abstract class RendererRegistrar { private static Map, EntityRendererProvider> entityRenderers = new HashMap<>(); protected static void registerRenderer(String name, EntityRendererProvider rendererProvider) { if (AutoRegistry.isEntityTypeRegistered(name)) { // Store this renderer provider. entityRenderers.put(AutoRegistry.getEntityType(name), rendererProvider); } else { throw new RuntimeException("Tried to register a renderer for an unregistered entity type! Make sure you register renderers after entities."); } } @SuppressWarnings({"unchecked", "unused"}) private void onEntityCreation(EntityRenderersEvent.RegisterRenderers event) { for (EntityType entityType : entityRenderers.keySet()) { event.registerEntityRenderer((EntityType)entityType, (EntityRendererProvider)entityRenderers.get(entityType)); } } }