Jump to content

[SOLVED] No textures in inventory


quaiby

Recommended Posts

Forge 1.12.2 2655

I have neither item nor block textures when they are in the inventory. I have model file, texture file in right places. I register both item and its model in the right order. There are no errors in my console. Debugger tells me that both item and model are registered, and that model can see the .PNG texture.

 

Item class:

public class BasicItem extends Item {

    protected String name;

    public BasicItem(String name) {
        this.name = name;
        setUnlocalizedName(MODID + ":" + name);
        setRegistryName(name);
    }
}

 

Item manager class:

@Mod.EventBusSubscriber
public class ItemManager {

    public static Item ingot_copper = new BasicItem("ingot_copper");

    public static List<Item> itemsList = Arrays.asList(
            ingot_copper
    );

    @SubscribeEvent
    public static void registerItems(RegistryEvent.Register<Item> event) {
        IForgeRegistry<Item> r = event.getRegistry();
        itemsList.forEach(r::register);
    }

    public static void registerItemModels() {
        itemsList.forEach(item -> ModelLoader.setCustomModelResourceLocation(
                ingot_copper,
                0,
                new ModelResourceLocation(ingot_copper.getRegistryName(), "inventory")
        ));

    }
}

 

Client proxy class:

@Mod.EventBusSubscriber
public class ClientProxy extends CommonProxy {

    @SubscribeEvent
    public void registerModel(ModelRegistryEvent event) {
        ItemManager.registerItemModels();
    }
}

 

assets/<modid>/models/item/ingot_copper.json:

{
  "parent": "item/generated",
  "textures": {
    "layer0": "<modid>:items/ingot_copper"
  }
}

 

What am I doing wrong?

Edited by quaiby

I'm just very crazy about performance :D

Link to comment
Share on other sites

13 minutes ago, quaiby said:

 @Mod.EventBusSubscriber 
 public class ClientProxy extends CommonProxy { 
     @SubscribeEvent 
     public void registerModel(ModelRegistryEvent event) { 
         ItemManager.registerItemModels(); 
     }
 }

 

Read the documentation

http://mcforge.readthedocs.io/en/latest/events/intro/

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.

Link to comment
Share on other sites

20 minutes ago, diesieben07 said:

You cannot have this method here. You cannot access client-only classes (ModelLoader) from common code (ItemManager).

By putting a plain @EventBusSubscriber on your client proxy you are also making the server try to load it, this will break. Use thevalue attribute of the @EventBusSubscriber annotation to set the correct side.

It works properly on server side.

Edited by quaiby

I'm just very crazy about performance :D

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.