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 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())));
}
}

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.

  • 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.

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.

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.

  • 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>.

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.

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.