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

How do I set an item texture? I have a JSON file and PNG file. I remember the old way of doing it which was this.setTextureName but that doesn't work anymore for 1.8.8 and up. Here is my code

 

 

 

package com.ren3dm.ExpandedFood;

import com.ren3dm.ExpandedFood.Reference;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.LanguageRegistry;


public class Food{

public static Item Bagel;

public static void registerRenders() 
{

	registerRender(Bagel);

}

public static void registerRender(Item item) 
{

	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,  new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));


}

public static void Init() 
{

	Bagel = new ItemFood(3, 0.9f, false).setUnlocalizedName("Bagel").setCreativeTab(CreativeTabs.tabFood).setMaxStackSize(64);

}

public static void register()
{

	GameRegistry.registerItem(Bagel, Bagel.getUnlocalizedName().substring(5));

}

 

package com.ren3dm.ExpandedFood;

import com.ren3dm.ExpandedFood.proxy.ServerP;

import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
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 net.minecraftforge.fml.common.event.FMLServerStartingEvent;

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
public class Main
{

@SidedProxy(clientSide = Reference.MOD_CLIENT_PROXY, serverSide = Reference.MOD_SERVER_PROXY)
public static ServerP proxy;



@EventHandler
public void preInit(FMLPreInitializationEvent event) 
{
	Food.Init();
	Food.register();


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

}
@EventHandler
public void postInit(FMLPostInitializationEvent event) 
{

}

@EventHandler
public void serverLoad(FMLServerStartingEvent event) {

}


}

 

 

My json is in: assets.expandedfood.models.item

 

My PNG is in: assets.expandedfood.textures.items

 

My JSON is named: Bagel.json

 

My PNG is named: Bagel.png

 

The text inside my JSON is:

{
"parent": "item/generated"
"textures": {
	"layer0": "expandedfood:items/Bagel"
},
"display": {
	"thirdperson": {
		"rotation": [-90, 0, 0],
		"translation": [0, 1, -3],
		"scale": [0.55, 0.55, 0.55 ]
	},
	"firstperson": {
		"rotation": [0, -135, 25 ],
		"translation": [0, 4, 2 ],
		"scale": [1.7, 1.7, 1.7]
	}
}
}

The text inside my JSON is:

 

That's your mcmod.info file, which while it contains JSON content is not an item json model.

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/resources/assets/oreflowers/models/item/goldwand.json

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

If you're using item/generated as the parent, you don't need the display block at all.  item/generated takes care of it for you.

 

Also, when you say your texture/model is at "assets.expandedfood.models.item" do you have nested folders or one folder with periods in its name?

 

Because you need the former.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

package com.ren3dm.ExpandedFood;
You probably do not own that domain.

 

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,  new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
This is outdated and broken. You should be using ModelLoader.setCustomModelResourceLocation in preInit in your client proxy. You cannot have client-only code like this in classes that will be loaded on a server. Moreover please don't use the unlocalized name to generate the model location. A much simpler way:
new ModelResourceLocation(item.getRegistryName(), "inventory")

.

 

setUnlocalizedName("Bagel")
Your unlocalized names should include your ModID to avoid conflicts with other mods.

 

GameRegistry.registerItem(Bagel, Bagel.getUnlocalizedName().substring(5));
GameRegistry.registerItem is deprecated, update to the new version. As above, please don't use the unlocalized name to generate the registry name. If you want to only have an identifying string in one place, generate the unlocalized name from the registry name (
setUnlocalizedName(getRegistryName().toString())

), this will also solve the above problem, as the registry name will include your ModID by default.

 

"display": {

"thirdperson": {

"rotation": [-90, 0, 0],

"translation": [0, 1, -3],

"scale": [0.55, 0.55, 0.55 ]

},

"firstperson": {

"rotation": [0, -135, 25 ],

"translation": [0, 4, 2 ],

"scale": [1.7, 1.7, 1.7]

}

}

You do not need all this stuff, it is included in the "item/generated" model already, which you have set as the parent.

 

I am using forge 1.8.8 not he latest 1.11. I tried that and I just get errors when I put it in.

  • Author

If you're using item/generated as the parent, you don't need the display block at all.  item/generated takes care of it for you.

 

Also, when you say your texture/model is at "assets.expandedfood.models.item" do you have nested folders or one folder with periods in its name?

 

Because you need the former.

The folders are nested.

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.