I am trying to make an entity which works and renders in a similar fashion to a splash potion.
It is defined thus:
https://pastebin.com/edkgrnYW
To render it, I am using the SpriteRenderer class like so:
@EventBusSubscriber(modid = Main.MOD_ID, value = {Dist.CLIENT}, bus = EventBusSubscriber.Bus.MOD)
public class ClientProxy {
@SubscribeEvent
public static void init(FMLClientSetupEvent event) {
RenderingRegistry.registerEntityRenderingHandler(EntityExplosivePotion.class, m -> new SpriteRenderer<>(m, Minecraft.getInstance().getItemRenderer()));
//RenderingRegistry.registerEntityRenderingHandler(EntitySpicyExplosivePotion.class, RenderSpicyExplosivePotion::new);
getItemModelMesher().register(ModItems.EXPLOSIVE_POTION, new ModelResourceLocation("expotions:potion_explosive", "inventory"));
getItemModelMesher().register(ModItems.THROWABLE_EXPLOSIVE_POTION, new ModelResourceLocation("expotions:potion_explosive_throwable", "inventory"));
getItemModelMesher().register(ModItems.SPICY_EXPLOSIVE_POTION, new ModelResourceLocation("expotions:potion_explosive_spicy", "inventory"));
getItemModelMesher().register(ModItems.SPICY_THROWABLE_EXPLOSIVE_POTION, new ModelResourceLocation("expotions:potion_explosive_throwable_spicy", "inventory"));
}
/**
* Convenience function for getting the {@code ItemModelMesher}.
* @return The {@code ItemModelMesher} from {@link RenderItem#getItemModelMesher()} via {@link Minecraft#getItemRenderer()}
*/
public static ItemModelMesher getItemModelMesher() {
return Minecraft.getInstance().getItemRenderer().getItemModelMesher();
}
}
When the entity is spawned it is spawned like so:
EntityExplosivePotion potion = new EntityExplosivePotion(player, world);
potion.setStrength(getStrength(stack));
potion.setSpicy(spicy);
potion.shoot(player, player.rotationPitch, player.rotationYaw, -20.0F, 0.5F, 1.0F);
world.addEntity(potion);
The problem that I am having is that the entity is not rendering. It functions but no model appears when it is spawned and no output appears in the log either.
The event handler for FMLClientSetupEvent is called but the renderer still does not appear to be registered.
Here is a copy of my latest.log: https://pastebin.com/ftE0Ffag