Jump to content

Recommended Posts

Posted

I'm new to modding and I'm currently in the process of making my first mod, all it does at the moment is add two items.

However, I can't seem to find the reason to why the items won't render (Missing model), I have the Jsons, Pngs, i believe I have everything set up correctly, the items show up in game, and I can't even find an error in the console.

But they don't   have   a model.

 

Minecraft 1.10.2

Forge 1.10.2-12.18.3.2185

Eclipse neon.2

 

Code:

-Download

https://www.dropbox.com/s/8rs0dhk9hzdc8z1/Basic.zip?dl=0

 

-Basic.java

package com.helinos.basic;

import com.helinos.basic.init.ModItems;
import com.helinos.basic.proxy.CommonProxy;

import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
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.MOD_ID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = Reference.ACCEPTED_VERSIONS)
public class Basic {

    @Instance
    public static Basic instance;
    
    @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
    public static CommonProxy proxy;
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        System.out.println("Pre Init");
        
        ModItems.init();
        ModItems.register();
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
        System.out.println("Init");
        proxy.init();
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
        System.out.println("Post Init");        
    }
}

-Reference.java

package com.helinos.basic;

public class Reference {
    
    public static final String MOD_ID = "helinosbasicmod";
    public static final String NAME = "Helinos' Basic Mod";
    public static final String VERSION = "1.0";
    public static final String ACCEPTED_VERSIONS = "[1.10.2]" ;
    
    public static final String CLIENT_PROXY_CLASS = "com.helinos.basic.proxy.ClientProxy";
    public static final String SERVER_PROXY_CLASS = "com.helinos.basic.proxy.ServerProxy";

    public static enum BasicItems
    {
        SMALLDIAMONDCHUNK("smalldiamondchunk", "ItemSmallDiamondChunk"),
        LARGEDIAMONDCHUNK("largediamondchunk", "ItemLargeDiamondChunk");
        
        private String unlocalizedName;
        private String registryName;
        
        BasicItems(String unlocalizedName, String registryName) {
            this.unlocalizedName = unlocalizedName;
            this.registryName = registryName;
        }
        
        public String getUnlocalizedName() {
            return unlocalizedName;
        }
        
        public String getRegistryName() {
            return registryName;
        }
    }
}

-ModItems.java

package com.helinos.basic.init;

import com.helinos.basic.Reference;
import com.helinos.basic.items.ItemLargeDiamondChunk;
import com.helinos.basic.items.ItemSmallDiamondChunk;

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

public class ModItems {
    
    public static Item smalldiamondchunk;
    public static Item largediamondchunk;

    public static void init()
    {
        smalldiamondchunk = new ItemSmallDiamondChunk();
        largediamondchunk = new ItemLargeDiamondChunk();
    }
        
    public static void register()
    {
        GameRegistry.register(smalldiamondchunk);
        GameRegistry.register(largediamondchunk);
    }
        
    public static void registerRenders()
    {
        registerRender(smalldiamondchunk);    
        registerRender(largediamondchunk);
    }
        
    private static void registerRender(Item item)
    {
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }
}

-SmallDiamondChunk.java & Json

  Reveal hidden contents

-Smaller Files

  Reveal hidden contents

Log

  Reveal hidden contents

 

Screenshot:

 OztGfZj.png

ada0f1f9d6d80d80b5561313ab8cb5d9.png

 

 

Posted (edited)

I think the problem is in your moditems file, you forgot to give it the destination to your mod folder
 

new ModelResourceLocation(Reference.MOD_ID+":"+item.getRegistryName(), "inventory")
Edited by Burpingdog1
Posted

ModelLoader.setCustomModelResourceLocation needs to be called in preInit rather than init. Also, resource paths (like your json filenames) should be all lowercase.

 

  On 3/19/2017 at 9:42 PM, Burpingdog1 said:

I think the problem is in your moditems file, you forgot to give it the destination to your mod folder
 

new ModelResourceLocation(Reference.MODID+":"+item.getRegistryName(), "inventory")
Expand  

This is incorrect - Item#getRegistryName() already includes the modid.

 

 

Posted
  On 3/19/2017 at 9:49 PM, Jay Avery said:

ModelLoader.setCustomModelResourceLocation needs to be called in preInit rather than init. Also, resource paths (like your json filenames) should be all lowercase.

Expand  

This worked

If anyone ever references this (which they probably won't) I moved "proxy.init" in basic.java from init to preinit

Posted
  On 3/19/2017 at 9:51 PM, Burpingdog1 said:

oh, whats the difference between using Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register and  ModelLoader.setCustomModelResourceLocation ?

Expand  

The second one works.  The first one is an old, out dated, unreliable method that has been deprecated in favor of the latter.

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

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