Jump to content

customModelResourceLocation not working


Delupara

Recommended Posts

Someone told me to not use ItemModelMesher#register and use ModelLoader#CustomModelLocation instead. Though This made my resources break. They won't show at all.

 

SoulCraft.java

package mod.TGC1.SoulCraft;

import net.minecraftforge.fml.common.Mod; 
import net.minecraftforge.fml.common.Mod.EventHandler; 
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; 
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; 
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import mod.TGC1.SoulCraft.References;
import mod.TGC1.SoulCraft.init.ModItems;
import mod.TGC1.SoulCraft.proxy.ClientProxy;


@Mod(modid = References.MOD_ID , name = References.MOD_NAME, version = References.MOD_VERSION)
public class SoulCraft 
{
@Mod.Instance("SoulCraft")
public static SoulCraft SoulCraft;

@SidedProxy(clientSide="mod.TGC1.SoulCraft.proxy.ClientProxy", serverSide="mod.TGC1.SoulCraft.proxy.ServerProxy")
public static CommonProxy proxy;

@EventHandler
public void preInit(FMLPreInitializationEvent event) 
{
	ModItems.init();
	ModItems.registerItems();
}

@EventHandler
public void init(FMLInitializationEvent event) 
{
	proxy.init();
}

@EventHandler
public static void postInit(FMLPostInitializationEvent event) 
{

}
}

 

ClientProxy.java

package mod.TGC1.SoulCraft.proxy;

import mod.TGC1.SoulCraft.CommonProxy;
import mod.TGC1.SoulCraft.init.ModItems;

public class ClientProxy extends CommonProxy{

@Override
public void init()
{
	ModItems.registerItemRenders();
}
}

 

ModItems.java

package mod.TGC1.SoulCraft.init;

import mod.TGC1.SoulCraft.References;
import mod.TGC1.SoulCraft.Customs.Items.ItemNoteBook;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModItems {

public static Item NoteBook;

public static void init()
{
	NoteBook = new ItemNoteBook();
}

//registers all the Items.
public static void registerItems()
{
	register(NoteBook, "NoteBook");
}

public static void registerItemRenders()
{
	registerRender(NoteBook);
}

public static void register(Item item,String string)
{
	GameRegistry.registerItem(item, string);
}

public static void registerRender(Item item)
{
	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(References.MOD_ID + ":" + item.getRegistryName(), null));
}
}

 

Idk if im implementing the function correctly, also I know my variable naming convention is not right, don't remind me I know.

When they say your code doesn't follow convention but ur edgy so u dont care

d-d-d-dab on them haterz

 

Link to comment
Share on other sites

First of all, do not call ModelLoader from common code (ModItems). It must be in your ClientProxy.

 

ModelLoader must be used in preInit, not init.

 

do you need it in client proxy for convention's sake or it will absolutely not work if I call it from ModItems?

 

Because in both cases it did not work. These are the changes I made.

 

ClientProxy.java

package mod.TGC1.SoulCraft.proxy;

import mod.TGC1.SoulCraft.CommonProxy;
import mod.TGC1.SoulCraft.References;
import mod.TGC1.SoulCraft.init.ModItems;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;

public class ClientProxy extends CommonProxy{

@Override
public void init()
{
	renderAllItems();
}

public void renderAllItems()
{
	renderItem(ModItems.NoteBook);
}

public void renderItem(Item item)
{
	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(References.MOD_ID + ":" + item.getRegistryName(), null));
}
}

 

SoulCraft.java

package mod.TGC1.SoulCraft;

import net.minecraftforge.fml.common.Mod; 
import net.minecraftforge.fml.common.Mod.EventHandler; 
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; 
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; 
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import mod.TGC1.SoulCraft.References;
import mod.TGC1.SoulCraft.init.ModItems;
import mod.TGC1.SoulCraft.proxy.ClientProxy;


@Mod(modid = References.MOD_ID , name = References.MOD_NAME, version = References.MOD_VERSION)
public class SoulCraft 
{
@Mod.Instance("SoulCraft")
public static SoulCraft SoulCraft;

@SidedProxy(clientSide="mod.TGC1.SoulCraft.proxy.ClientProxy", serverSide="mod.TGC1.SoulCraft.proxy.ServerProxy")
public static CommonProxy proxy;

@EventHandler
public void preInit(FMLPreInitializationEvent event) 
{
	ModItems.init();
	ModItems.registerItems();
	proxy.init();
}

@EventHandler
public void init(FMLInitializationEvent event) 
{

}

@EventHandler
public static void postInit(FMLPostInitializationEvent event) 
{

}

 

ModItems.java

package mod.TGC1.SoulCraft.init;

import mod.TGC1.SoulCraft.References;
import mod.TGC1.SoulCraft.Customs.Items.ItemNoteBook;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModItems {

public static Item NoteBook;

public static void init()
{
	NoteBook = new ItemNoteBook();
}

//registers all the Items.
public static void registerItems()
{
	register(NoteBook, "NoteBook");
}

public static void register(Item item,String string)
{
	GameRegistry.registerItem(item, string);
}

}

When they say your code doesn't follow convention but ur edgy so u dont care

d-d-d-dab on them haterz

 

Link to comment
Share on other sites

- Yes, it absolutely must be in your ClientProxy

- Why did you set the variant to "null"?

- getRegistryName already includes your modID, no need to prefix it again.

 

I was trying something before I came here. I'm not sure what variants (aside from blockstates) are and are used for. I thought that the item has no real variants of itself so I did that.

 

And I didn't knew that registryname included modID. thanks alot.

When they say your code doesn't follow convention but ur edgy so u dont care

d-d-d-dab on them haterz

 

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.

Announcements



×
×
  • Create New...

Important Information

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