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

I am trying to load an item's model and .png using a .json file, but the item just loads as a pink and black block.

 

here is my .json code:

 

{

    "parent": "builtin/generated",
    "textures": {
    
        "layer0": "firstmod:items/cheese"
    
    },
    "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]
        
        }
    
    }

}

 

I have also pinned some errors in the debug console that I think may help with this situation. Also, I have a picture of my package viewer if that is useful:

 

 

 

So, how would I be able to render the object as the .png without it looking like a massive pink and blue block? If you need more information on the project (more code, images, etc.), I will be more than happy to provide it.

 

Thank you!

 

 

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

  • Author

I am trying to load an item's model and .png using a .json file, but the item just loads as a pink and black block.

 

here is my .json code:

 

{

    "parent": "builtin/generated",
    "textures": {
    
        "layer0": "firstmod:items/cheese"
    
    },
    "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]
        
        }
    
    }

}

 

I have also pinned some errors in the debug console that I think may help with this situation. Also, I have a picture of my package viewer if that is useful:

 

 

 

So, how would I be able to render the object as the .png without it looking like a massive pink and blue block? If you need more information on the project (more code, images, etc.), I will be more than happy to provide it.

 

Thank you!

 

 

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

  • Author

Show where you register your item and the model.

 

gladly!

 

Here is the code for the class MyItems.java (which is where the registering takes place):

package wes.firstmod.init;


import wes.firstmod.FirstMod;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MyItems
{

public static Item cheese;

/*public static void preInit()
{



}*/

public static void register()
{

	Item cheeseName = cheese.setRegistryName("cheese");

	GameRegistry.register(cheeseName);

}

public static void init()
{

	cheese = new Item().setUnlocalizedName("cheese");

}

public static void registerRender(Item item)
{

	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(FirstMod.MODID + ":" + item.getRegistryName(), "inventory"));

}

public static void registerRenders()
{

	registerRender(cheese);

}

}

 

Also, in the class FirstMod.java, the registries are called (forgot to add this previously, my apologies):

package wes.firstmod;


import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;

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.GameRegistry;
import wes.firstmod.init.MyItems;



@Mod(modid = FirstMod.MODID, version = FirstMod.VERSION)

public class FirstMod
{

public static final String MODID = "firstmod";
public static final String VERSION = "1.0";

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{

	MyRecipes.addRecipes();
	MyItems.init();
	MyItems.register();

}
    
@EventHandler
public void init(FMLInitializationEvent event)
{

	MyRecipes.addRecipes();
	MyItems.registerRenders();

}

@EventHandler
public void postInit(FMLPostInitializationEvent event)
{



}

}

 

Items are registered in preInit()

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

  • Author

Show where you register your item and the model.

 

gladly!

 

Here is the code for the class MyItems.java (which is where the registering takes place):

package wes.firstmod.init;


import wes.firstmod.FirstMod;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MyItems
{

public static Item cheese;

/*public static void preInit()
{



}*/

public static void register()
{

	Item cheeseName = cheese.setRegistryName("cheese");

	GameRegistry.register(cheeseName);

}

public static void init()
{

	cheese = new Item().setUnlocalizedName("cheese");

}

public static void registerRender(Item item)
{

	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(FirstMod.MODID + ":" + item.getRegistryName(), "inventory"));

}

public static void registerRenders()
{

	registerRender(cheese);

}

}

 

Also, in the class FirstMod.java, the registries are called (forgot to add this previously, my apologies):

package wes.firstmod;


import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;

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.GameRegistry;
import wes.firstmod.init.MyItems;



@Mod(modid = FirstMod.MODID, version = FirstMod.VERSION)

public class FirstMod
{

public static final String MODID = "firstmod";
public static final String VERSION = "1.0";

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{

	MyRecipes.addRecipes();
	MyItems.init();
	MyItems.register();

}
    
@EventHandler
public void init(FMLInitializationEvent event)
{

	MyRecipes.addRecipes();
	MyItems.registerRenders();

}

@EventHandler
public void postInit(FMLPostInitializationEvent event)
{



}

}

 

Items are registered in preInit()

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

  • Author

This worked, thank you!

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

  • Author

This worked, thank you!

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

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.