Minecraft forge doesn't load my item texture in 1.12.2
NickName:DouFut Ask DateTime:2022-06-09T00:11:14

Minecraft forge doesn't load my item texture in 1.12.2

I'm trying to add a texture to an item I have, and it's not loading in Minecraft. Here's my base mod class:

package fr.doufut.test;

import fr.doufut.test.events.RegisteringEvent;
import fr.doufut.test.proxy.CommonProxy;
import fr.doufut.test.utils.Reference;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
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;
@Mod(modid = Reference.MODID, name = Reference.NAME , version = Reference.VERSION)
public class TestMain {

    @Mod.Instance(Reference.MODID)
    public static TestMain instance;

    @SidedProxy(clientSide = Reference.CP, serverSide = Reference.SP)
    public static CommonProxy proxy;

    public TestMain()
    {
        MinecraftForge.EVENT_BUS.register(new RegisteringEvent());
    }

    @Mod.EventHandler
    public void preinit(FMLPreInitializationEvent e)
    {
        proxy.preinit();
    }

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

    @Mod.EventHandler
    public void postinit(FMLPostInitializationEvent e)
    {
        proxy.postinit();
    }
}

My common proxy class:

package fr.doufut.test.proxy;

public class CommonProxy {

    public void preinit()
    {

    }

    public void init()
    {

    }

    public void postinit()
    {

    }
}

My Client Proxy class:

package fr.doufut.test.proxy;

import fr.doufut.test.init.ModItems;
import net.minecraftforge.common.MinecraftForge;

public class ClientProxy extends CommonProxy
{

    @Override
    public void preinit() {
        super.preinit();
        MinecraftForge.EVENT_BUS.register(ModItems.INSTANCE);
    }

    @Override
    public void init() {
        super.init();
    }

    @Override
    public void postinit() {
        super.postinit();
    }
}


Here is the actual ModItem class:

package fr.doufut.test.init;

import com.google.common.collect.Lists;
import fr.doufut.test.items.HDOItems;
import fr.doufut.test.utils.Reference;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.util.List;

public class ModItems {

    public static final ModItems INSTANCE = new ModItems();

    public static Item coca;

    private List<Item> items;

    public void init()
    {
        items = Lists.newArrayList();
        coca = new HDOItems("coca");
    }

    @SubscribeEvent
    public void registerModels(ModelRegistryEvent e)
    {
        for (Item item : items)
        {
            registerModel(item);
        }
    }

    private void registerModel(Item item)
    {
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, item.getUnlocalizedName().substring(5)), "inventory"));
    }

    public List<Item> getItems()
    {
        return items;
    }
}

Here is the HDOItem class file:

package fr.doufut.test.items;

import fr.doufut.test.init.ModItems;
import net.minecraft.item.Item;

public class HDOItems extends Item
{

    public HDOItems(String name)
    {
        setRegistryName(name).setUnlocalizedName(name);

        ModItems.INSTANCE.getItems().add(this);
    }
}

Here is the item's json model file:

{

  "parent": "item/generated",
  "textures": {
    "layer0": "hdo:/items/coca"
  }

}

My folder structure:

Json file: C:\Users\rober\Desktop\forge-1.12.2-14.23.5.2859-mdk\src\main\resources\assets\hdo\models\item\coca.json

PNG file: C:\Users\rober\Desktop\forge-1.12.2-14.23.5.2859-mdk\src\main\resources\assets\hdo\textures\items.json

Copyright Notice:Content Author:「DouFut」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72548974/minecraft-forge-doesnt-load-my-item-texture-in-1-12-2

More about “Minecraft forge doesn't load my item texture in 1.12.2” related questions

Minecraft Forge crash in eclipse

I am new to modding in Forge and I came across an error which I can't solve. I've correctly configured the Run/Debug configs the .toml file is fine and I left the example mod as it was. I get this ...

Show Detail

is there any complete minecraft forge documentation anywhere?

While it doesn't appear that this is a duplicate based on my searches, I'm sure other people have complained about this in many places. I play minecraft and know java pretty well, so I thought it w...

Show Detail

Minecraft Forge not loading resources

My problem is that when I start the game none of my resources are loaded. I use IntelliJ version 2021.2.2 and the 1.12.2 Minecraft Forge MDK version 14.23.5.2855 and I know that IntelliJ is the pro...

Show Detail

Minecraft Forge 1.8 - Loading Block Textures

I have just started learning Java while modding Minecraft. I have watched a tutorial on adding the blocks into the game using the Minecraft Forge API, but I have a problem. There is no longer the ".

Show Detail

Minecraft Forge Gradle with VSCode

I am trying to create a Minecraft Mod using VSCode as this is my main editor for school, but when I try to run the command gradlew genVSCodeRun I get the follwoing output that says successful, but ...

Show Detail

Error trying to start Minecraft Forge by command

I am currently developing a custom Minecraft launcher and I want to start Minecraft forge by command line, but unfortunately I constantly get this error: java.lang.RuntimeException: Patcher expect...

Show Detail

Launch minecraft forge 1.8.9 from the command line

I am rather stumped on how to do this. I have come across a python module to launch minecraft from a command line or wrather generate a command... import minecraft_launcher_lib import subprocess im...

Show Detail

Why is my minecraft forge mod not working?

I am trying to make a custom biome, but it crashes when I try to export the mod and load it in Minecraft. It works fine in eclipse 'run client' mode. Here is the code: package com.dadobug1111.

Show Detail

DS_Store files crashing Minecraft forge

I am trying to make a smimple mod in eclipse on macOS, everything worked fine up until I add the texture .png file to the game, then I get a DS_Store error, I have look at almost every fourm about ...

Show Detail

Minecraft 1.17.1 Forge Snapshot Obfuscation Mappings

I am a beginner in modding Minecraft and would like to modify the latest release of the Forge version of Minecraft (v1.17.1). I know how to setup a gradle project for 1.16.5, and can for the most p...

Show Detail