Jump to content

[1.8] Render Item Missing Texture


statphantom

Recommended Posts

hey guys really stuck here, Can't figure out why my texture rendering isn't working. I THINK it is a path issue. I am using the forge eclipse environment.

 

main class:

 

package statslevelmod;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
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 net.minecraftforge.fml.relauncher.Side;

@Mod(modid = Level.MODID, name = Level.MODNAME, version = Level.VERSION)
public class Level {
    public static final String MODID = "statslevelmod";
    public static final String MODNAME = "Level";
    public static final String VERSION = "1.0.1";
    
    public static Item sharpstick;
    
    
    @EventHandler
    public void preInit (FMLPreInitializationEvent event) {
    	
    	System.out.println("Loading " + MODNAME + "!");
    	System.out.println("Version " + VERSION + "!");
    	
    	sharpstick = new SharpStick();
    	
    	MinecraftForge.EVENT_BUS.register(new LevelEventHandler());
    	
    	GameRegistry.addRecipe(new ItemStack(sharpstick),
    	"A ",
    	" A",
    	'A', Items.stick);
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event) {
    	
    	if (event.getSide() == Side.CLIENT) {
    		regTexture(sharpstick);
    	}
    }
    
    @EventHandler
    public void postInt (FMLPostInitializationEvent event) {
    	
    	System.out.println(MODID + " loaded successfuly!");
    }
    
    public static void regTexture(Item item) {
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));    <----- where the error occurs.
    }
}

 

 

My Event Handler Class:

 

package statslevelmod;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class LevelEventHandler {

@SubscribeEvent
public void onPlayerMineEvent(PlayerEvent.BreakSpeed event) {

	if (event.state.getBlock() == Blocks.log) {

		event.newSpeed = -1;

	} else {

		event.newSpeed = -1;
	}
}

@SubscribeEvent
public void onPlayerClickEvent(PlayerInteractEvent event) {
	if (event.action == Action.RIGHT_CLICK_BLOCK) {

		if (event.entityPlayer.getCurrentEquippedItem() == null) {

			if (event.world.getBlockState(event.pos).getBlock() == Blocks.grass && event.face == event.face.UP) {

				if (!event.world.isRemote) {
					event.world.setBlockState(event.pos, Blocks.dirt.getDefaultState());


					Block.spawnAsEntity(event.world, event.pos, new ItemStack(Level.sharpstick));
				}						
			}
		}
	}
}
}

 

 

My Item Class

 

package statslevelmod;

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

public class SharpStick extends Item {

private final String name = "sharpStick";

public SharpStick() {
	super();

	GameRegistry.registerItem(this, name);
	setCreativeTab(CreativeTabs.tabMisc);
	setUnlocalizedName(name);
	setMaxStackSize(64);
}
}

 

 

My Item JSON file:

 

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

 

 

This is a screenshot of my Package Explorer:

http://i.imgur.com/Vnhc4zX.png

 

Any help is greatly appreciated, thanks :)

Link to comment
Share on other sites

Textures must be registered in init, not preInit.

 

This is the case if you're using the vanilla

ItemModelMesher#register

methods (like the OP is), but Forge's

ModelLoader#setCustomModelResourceLocation

and

ModelLoader.setCustomMeshDefinition

methods (which do the same thing as the vanilla methods) need to be called in preInit rather than init.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.