Jump to content

Recommended Posts

Posted (edited)

Hey!

So I recently updated my mod to 1.12.2. Now, I know there is this new efficient way of registering Items and Blocks via the Registry Events, but I'm not too sure how you do that...

This is what I currently have:

	public static void registerItem(Item item)
	{
		item.setCreativeTab(Dinocraft.ITEMS);
		ForgeRegistries.ITEMS.register(item);
		Utils.getLogger().info("Registered item: " + item.getUnlocalizedName().substring(5));
	}
	
	public static void registerRender(Item item) 
	{
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, item.getUnlocalizedName().substring(5)), "inventory"));
		Utils.getLogger().info("Registered render for " + item.getUnlocalizedName().substring(5));
	}

	public static void register() 
	{
		//Food
		registerItem(POTATOSHROOM_PIE);
		registerItem(CHUNKY_FLESH);
		//Material
		registerItem(CHLOROPHYTE_INGOT);
		registerItem(FLOBBER_INGOT);
		registerItem(SHEEPLITE_INGOT);
		registerItem(PEBBLES);
		registerItem(CRACKED_PEBBLES);
		registerItem(LEAF);
		registerItem(BLEVENT_INGOT);
		registerItem(RANIUM);
		registerItem(PEBBELONEUM);
		//?
		registerItem(TUSKERERS_HEART);
		registerItem(TUSKERERS_CHARM);
		
		//WIP
		registerItem(VINE_BALL);
		registerItem(SLINGSHOT);
		registerItem(VINE_BALL_BUNDLE);
		registerItem(POISON_BALL);
		registerItem(POISON_BEATLER);
		registerItem(RAY_BULLET);
		registerItem(RAY_GUN);
	}
	
	public static void registerRenders() 
	{
		//Food
		registerRender(POTATOSHROOM_PIE);
		registerRender(CHUNKY_FLESH);
		//Material
		registerRender(CHLOROPHYTE_INGOT);
		registerRender(FLOBBER_INGOT);
		registerRender(SHEEPLITE_INGOT);
		registerRender(PEBBLES);
		registerRender(CRACKED_PEBBLES);
		registerRender(LEAF);
		registerRender(BLEVENT_INGOT);
		registerRender(RANIUM);
		registerRender(PEBBELONEUM);
		//?
		registerRender(TUSKERERS_HEART);
		registerRender(TUSKERERS_CHARM);
		
		//WIP
		registerRender(VINE_BALL);
		registerRender(SLINGSHOT);
		registerRender(VINE_BALL_BUNDLE);
		registerRender(POISON_BALL);
		registerRender(POISON_BEATLER);
		registerRender(RAY_BULLET);
		registerRender(RAY_GUN);
	}

I mean this works and does the job perfectly fine, but I heard that the recommended way of registering it is by using the registry events.

Any help is welcome.

Thanks!

Edited by Differentiation
Posted

Well, that's wrong, obviously.

 

You want to register with events?

 

Write an event handler.

 

http://mcforge.readthedocs.io/en/latest/concepts/registries/#registering-things

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Yes

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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