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

Hi,

 

I've been following the shadowfacts tutorial up to the point in which the first custom item is registered + rendered with a custom texture. Despite following every single instruction exactly and reviewing my code a thousand times to make sure, I get a missing texture for my custom item every time I load up my mod. I have heard that sometimes intelliJ can cause issues with forge, but none of the fixes I've come across have worked (making changes to build.gradle, refreshing dependencies,etc...). To clarify, I have my texture at the directory "\src\main\resources\assets\lessannoyances\textures\items", and my .json at "\src\main\resources\assets\lessannoyances\models\item", both of which are named 'spaghet', which is also the name of the item - I am 99% sure this is working, since if I rename either of these files I get an error during startup, and changing it back results in zero errors whatsoever.

 

I'm at an absolute loss as to what could be causing this. If anyone has any idea, I would really appreciate it.  

  

My code is follows;

 

Itembase.java

Spoiler

package net.lessannoyances;

import net.minecraft.item.Item;
import net.minecraft.creativetab.CreativeTabs;

public class ItemBase extends Item {

    protected String name;

    public ItemBase(String name){
        this.name = name;
        setUnlocalizedName(name);
        setRegistryName(name);
    }

    public void registerItemModel(){
        main.proxy.registerItemRenderer(this, 0, name);
    }

    @Override
    public ItemBase setCreativeTab(CreativeTabs tab) {
        super.setCreativeTab(tab);
        return this;
    }
}

 

clientproxy.java

Spoiler

package net.lessannoyances;

import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;

public class ClientProxy extends CommonProxy {
    @Override
    public void registerItemRenderer(Item item, int meta, String id){
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(main.modId + ":" + id, "inventory"));
    }
}

 

commonproxy.java

Spoiler

package net.lessannoyances;

import net.minecraft.item.Item;

public class CommonProxy {

    public void registerItemRenderer(Item item, int meta, String id){

    }
}

 

ModItems.java

Spoiler

package net.lessannoyances;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModItems {

    public static ItemBase spaghet;

    public static void init(){
        spaghet = register(new ItemBase("spaghet").setCreativeTab(CreativeTabs.MISC));

    }

    private static <T extends Item> T register(T item) {
        GameRegistry.register(item);

        if (item instanceof ItemBase) {
            ((ItemBase)item).registerItemModel();
        }

        return item;
    }
}

 

main.java;

Spoiler

package net.lessannoyances;

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 = main.modId, name = main.name, version = main.version)
public class main {

    public static final String modId = "lessannoyances";
    public static final String name = "Less Annoyances";
    public static final String version = "1.0.0";

    @SidedProxy(serverSide = "net.lessannoyances.CommonProxy", clientSide = "net.lessannoyances.CommonProxy")
    public static CommonProxy proxy;

    @Mod.Instance(modId)
    public static main instance;

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        System.out.println(name + " is loading!");
        ModItems.init();
    }

    @Mod.EventHandler
    public void init(FMLInitializationEvent event) {

    }

    @Mod.EventHandler
    public void postInit(FMLPostInitializationEvent event) {

    }


}

 

27 minutes ago, Elijah482 said:

ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(main.modId + ":" + id, "inventory"));

You know you can just call item.getRegistryName() right?

ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));

Also means you don't need the id parameter.

28 minutes ago, Elijah482 said:

if (item instanceof ItemBase) {

    ((ItemBase)item).registerItemModel();

}

This is pointless.  All it does is this:

29 minutes ago, Elijah482 said:

main.proxy.registerItemRenderer(this, 0, name);

Which you could have done there in the first place:
 

private static <T extends Item> T register(T item) {
    //other code
    main.proxy.registerItemRenderer(item, 0);
}

Also, you don't need this generic:

private static <T extends Item> T register(T item) {

This:

private static Item register(Item item) {

Works just fine

 

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

I made those changes, but the item still isn't rendering...did you manage to get it rendering?  

  

Could it be an issue with intelliJ? At this point I'm thinking i should just start over with eclipse.

2 hours ago, Elijah482 said:

Could it be an issue with intelliJ?

No.

2 hours ago, Elijah482 said:

did you manage to get it rendering?

Yes:

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L167

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.

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.