Jump to content

[1.12] GameRegistry.register() not working


ShoarmaKarma

Recommended Posts

Hey! I'm new to modding and I'm following Loremaster's starter tutorial on YouTube.
He's modding MC 1.11.2, but I figured that not that much had changed from 1.11.2 to 1.12
Sadly I can't get my GameRegistry.register() to work (It's the only error in the coding) Did something change in there from 1.11.2 to 1.12?

Here is my coding:

 

package init;

import com.shoarmakarma.theuselessmod.Reference;

import items.ItemCraftingbench;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModItems {
	
	public static Item craftingbench;

	public static void init(){
		craftingbench = new ItemCraftingbench();
	}
	
	public static void register(){
		GameRegistry.register(craftingbench); //GameRegistry library works, register error says: The method register(K) from the type GameRegistry is not visible
	}
	
	public static void registerRenders(){
		registerRender(craftingbench);
	}
	
	private static void registerRender(Item item){
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
	}
}

 

Link to comment
Share on other sites

The registry system has been overhauled in 1.12, you need to use registry events. Forge's documentation explains them here. You can see some examples in my mod's init classes.

 

Unlocalised names should not be used for anything except display/translation purposes, use the Item's registry name (IForgeRegistryEntry#getRegistryName) as the default model location (since it's the default model that vanilla loads for every Item).

 

Use ModelLoader.setCustomModelResourceLocation/setCustomMeshDefinition rather than ItemModelMesher#register to register Item models. Do this in ModelRegistryEvent.

 

The tutorial you followed is outdated and poorly written. None of this is new to 1.12; ModelLoader was introduced in 1.8, registry names were introduced in 1.8.9, IForgeRegistryEntry was introduced in 1.9, registry events were introduced towards the end of 1.10.2.

Edited by Choonster
  • Like 2

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.

Link to comment
Share on other sites

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.

×
×
  • Create New...

Important Information

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