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

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

 

  • Author

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

 

  • Author

- 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

 

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.