When I run my mod on a server and connect a client, none of the mod-added items show up in the creative inventory. They show up in singleplayer and you can still use the /give command to obtain them... they just don't show up in the creative inventory when using a server. What's more weird is that I don't have this problem when running the mod on a server in the eclipse IDE.
Here's how I'm registering my items:
Main mod file:
@EventHandler
public void init(FMLInitializationEvent event) {
When I run my mod on a server and connect a client, none of the mod-added items show up in the creative inventory. They show up in singleplayer and you can still use the /give command to obtain them... they just don't show up in the creative inventory when using a server. What's more weird is that I don't have this problem when running the mod on a server in the eclipse IDE.
Here's how I'm registering my items:
Main mod file:
@EventHandler
public void init(FMLInitializationEvent event) {
...
proxy.initItem(exampleItem, "exampleItem", "Example Item", CreativeTabs.tabMaterials);
...
}
Common proxy:
public void initItem(Item item, String name, String display, CreativeTabs tab) {
item.setUnlocalizedName(Main.MODID + ":" + name);
item.setRegistryName(name);
GameRegistry.registerItem(item, item.getRegistryName());
LanguageRegistry.addName(item, display);
item.setCreativeTab(tab);
}
Client proxy:
public void initItem(Item item, String name, String display, CreativeTabs tab) {
super.initItem(item, name, display, tab);
if (item instanceof ItemFirearm){
ModelBakery.registerItemVariants(item, new ModelResourceLocation[]{new ModelResourceLocation(Main.MODID + ":" + name, "inventory"), new ModelResourceLocation(Main.MODID + ":" + name + "sighted", "inventory")});
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,
new ModelResourceLocation(Main.MODID + ":" + name, "inventory"));
}
else
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,
new ModelResourceLocation(Main.MODID + ":" + name, "inventory"));
}
Additionally, all my mod-added creative tabs show up when I run the mod on the server, they're just empty
Thanks!
A few things:
- Items should be registered in preInit. I didn't know it even worked to try to register them in init
- You should be using ModelLoader.setCustomModelResourceLocation instead of Minecraft.getMinecraft().getRenderItem()...
- - the ModelLoader method should be called from preInit as well. It takes the same arguments.
- You should not be using LanguageRegistry
- - use the .lang file instead, adding an entry to translate the unlocalized name. See here for instructions.
The calls to ModelLoader only work in PreInit, those to Minecraft.getMinecraft().... only work in Init.
I changed the things you said and it worked. Looks like my constant references to deprecated functions were, in fact, a bad thing...