Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

Edited by sanman00

My mod: Explosive Potions for 1.10.2

Going to guess that the entity in question doesn't extend LivingEntity, in which case see 

 or one of the other several threads I found by Googling "forge 1.14 entity renderer".

 

And yeah, ditch that itemModelMesher code like yesterday :)  It's utterly unnecessary.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.