Jump to content

Recommended Posts

Posted

I'm trying to make a item in Forge 1.12, but the model is not loading.

My Code:

package com.mrturtle.potionmakers;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;

@Mod(modid = PotionMakers.MODID, version = PotionMakers.VERSION)
public class PotionMakers
{
    public static final String MODID = "mrturtle_potionmakers";
    public static final String VERSION = "0.1";
    
    public static Item basicwand;
    
    @EventHandler
    public void init(FMLPreInitializationEvent event)
    {
        basicwand = new itembasicwand();
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	ForgeRegistries.ITEMS.register(basicwand);
    }
    
    @EventHandler
	public void postInit(FMLPostInitializationEvent event)
	{
		if (event.getSide() == Side.CLIENT)
		{

			ModelLoader.setCustomModelResourceLocation(basicwand, 0, new ModelResourceLocation(basicwand.getRegistryName(), "inventory"));
			
			
		}
	}
    
}

 

Item Code:

 

package com.mrturtle.potionmakers;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class itembasicwand extends Item {
	
	public itembasicwand() {
		setRegistryName("basicwand");
		setUnlocalizedName(PotionMakers.MODID + "_" + "basicwand");
		setCreativeTab(CreativeTabs.TOOLS);
	}
	
}

 

Thanks for any help you can give me.

Posted
3 hours ago, MrBendelScrolls said:

Why do you guys come here and post onto ForgeGradle forum? OPEN YOUR EYES!
This 'problem' was answered like a hundred times already. Couldn't you just use search?

 

 

I added,

public static void registerItems(RegistryEvent.Register<Item> event) {
  event.getRegistry().register(item);
}

but what do i put in registerItems();

Posted

This is my current code I'm getting errors under registerModels(); and registerItems();

package com.mrturtle.potionmakers;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;

@Mod(modid = PotionMakers.MODID, version = PotionMakers.VERSION)
public class PotionMakers
{
    public static final String MODID = "mrturtle_potionmakers";
    public static final String VERSION = "0.1";
    
    public static Item basicwand;
    
    @EventHandler
    public void init(FMLPreInitializationEvent event)
    {
        basicwand = new itembasicwand();
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	registerItems();
    }
    
    @EventHandler
	public void postInit(FMLPostInitializationEvent event)
	{
		if (event.getSide() == Side.CLIENT)
		{

			registerModels();
			
			
		}
	}
    

    public static void registerItems(RegistryEvent.Register<Item> event) {
      event.getRegistry().register(basicwand);
    }
    
    public static void registerModels(ModelRegistryEvent event) {
    	  ModelLoader.setCustomModelResourceLocation(basicwand, 0, new ModelResourceLocation(basicwand.getRegistryName(), "inventory"));
    }
    
}

 

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.