Posted November 5, 20168 yr I recently got back into modding and I've encountered the classic white box entity rendering problem when trying to make an ender-pearl-like item. I've done a lot of googling, and I feel pretty confident in my code, but it still doesn't work for some reason. Here's the relevant code (that is, no other code involves rendering this particular entity) ExampleMod#init @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenderItems(); proxy.registerRenderEntities(); } Yes, I have all of the @SidedProxy stuff and I know it works ClientProxy public class ClientProxy extends CommonProxy{ @Override public void registerRenderItems(){ ItemModelMesher renderer = Minecraft.getMinecraft().getRenderItem().getItemModelMesher(); renderer.register(ModItems.flashPearl, 0, new ModelResourceLocation(ModItems.flashPearl.getRegistryName(), "inventory")); } @Override public void registerRenderEntities(){ RenderingRegistry.registerEntityRenderingHandler(EntityFlashPearl.class, ((rm) -> new RenderSnowball(rm, ModItems.flashPearl, Minecraft.getMinecraft().getRenderItem()))); } }
November 5, 20168 yr RenderingRegistry.registerEntityRenderingHandler(Class<T>, IRenderFactory<? super T>) must be called in preInit, as the doc comment says. Item models should be registered with ModelLoader.setCustomModelResourceLocation / setCustomMeshDefinition in ModelRegistryEvent (if you're registering your Item s using the new registry events, which you should be) or preInit (if you're registering your Item s in preInit). Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
November 5, 20168 yr Author I did something similar to your example on that thread you linked... public class ModItems { public static Item FLASH_PEARL = new ItemFlashPearl().setUnlocalizedName("flash_pearl").setRegistryName("flash_pearl"); @Mod.EventBusSubscriber public static class RegistrationHandler { public static final Set<Item> ITEMS = new HashSet<>(); @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { final IForgeRegistry<Item> registry = event.getRegistry(); registry.registerAll( FLASH_PEARL ); } } ...but the event never seems to be called (and I couldn't find anything else that I needed to add in your example mod) so the game just crashes when it tries to register a renderer for a non-existent item. I don't have much experience with forge events so I apologize for my ignorance here.
November 5, 20168 yr I did something similar to your example on that thread you linked... public class ModItems { public static Item FLASH_PEARL = new ItemFlashPearl().setUnlocalizedName("flash_pearl").setRegistryName("flash_pearl"); @Mod.EventBusSubscriber public static class RegistrationHandler { public static final Set<Item> ITEMS = new HashSet<>(); @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { final IForgeRegistry<Item> registry = event.getRegistry(); registry.registerAll( FLASH_PEARL ); } } ...but the event never seems to be called (and I couldn't find anything else that I needed to add in your example mod) so the game just crashes when it tries to register a renderer for a non-existent item. I don't have much experience with forge events so I apologize for my ignorance here. You also need to register it using MinecraftForge..register() in preInit VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
November 5, 20168 yr You also need to register it using MinecraftForge..register() in preInit No, that is not possible. RegistryEvent is fired before preInit . You need to use the @Mod.EventBusSubscriber annotation to register it. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
November 5, 20168 yr Author So it turns out the CTD I was encountering was actually completely unrelated to the item registering (I changed other code as well so I assumed it was an issue with item registering). The thing from my previous post works fine and fixes the problem. For other modders who come across this, don't use any GameRegistry.register stuff for registering items and just use RegistryEvent.Register<Item>.
November 6, 20168 yr i never had any issues with GameRegistry.register except for the fact that if a block is null and you try to register an Item for the block (ItemBlock) to a block that's null it will crash. That's why I always defnie and register all my blocks first then my items second. Disclaimer: I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.
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.