Jump to content

Custom itemrenderer crash


Thor597

Recommended Posts

So I started up my client to test out this model I made for an item, however I crashed with this error:

 

2012-11-02 23:46:07 [iNFO] [sTDERR] cpw.mods.fml.common.LoaderException: java.lang.reflect.InvocationTargetException
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.transition(LoadController.java:102)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at cpw.mods.fml.common.Loader.loadMods(Loader.java:461)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:141)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.startGame(Minecraft.java:405)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:737)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] Caused by: java.lang.reflect.InvocationTargetException
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:371)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:268)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:124)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:268)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:81)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at cpw.mods.fml.common.Loader.loadMods(Loader.java:460)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	... 4 more
2012-11-02 23:46:07 [iNFO] [sTDERR] Caused by: java.lang.NullPointerException
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at arcticraft.ClientProxy.registerRenderInformation(ClientProxy.java:23)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	at arcticraft.Arcticraft.preInit(Arcticraft.java:211)
2012-11-02 23:46:07 [iNFO] [sTDERR] 	... 30 more

 

ClientProxy stuff:


package arcticraft;                                                             
import arcticraft.entities.*;
import arcticraft.models.*;
import arcticraft.renderers.*;
import net.minecraft.src.*;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.TickRegistry;

public class ClientProxy extends CommonProxy
{
@Override
@SideOnly(Side.CLIENT)
public void registerRenderInformation() 
{  
	MinecraftForgeClient.registerItemRenderer(Arcticraft.staff.shiftedIndex, new AC_ItemRenderStaff());		
}

}

 

ItemRenderer file:


package arcticraft.renderers;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import arcticraft.models.AC_ModelStaff;
import net.minecraft.src.*;
import net.minecraftforge.client.*;

public class AC_ItemRenderStaff implements IItemRenderer
{
private static AC_ModelStaff staffModel = new AC_ModelStaff();

public boolean handleRenderType(ItemStack item, ItemRenderType type) 
{
	if (type == ItemRenderType.EQUIPPED) { return true; }
	return false;
}

public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) 
{
	return false;
}

public void renderItem(ItemRenderType type, ItemStack item, Object... data) 
{
	switch (type)
	{
	case ENTITY: renderTool(-0.5F, 0.5F, -0.5F); break;
	case EQUIPPED: renderTool(0F, 0.4F, 0F); break;
	case INVENTORY: renderTool(1F, 0.65F, 1F); break;
	default: break;
	}
}

private void renderTool(float x, float y, float z) 
{
	Tessellator tesselator = Tessellator.instance;
	GL11.glPushMatrix(); //start
	ForgeHooksClient.bindTexture("/arcticraft/textures/mobs/evilIceMage.png", 0);
	GL11.glTranslatef(x, y, z); //size
	float var10 = 0.0625F;
	staffModel.render((Entity)null, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, var10);
	GL11.glPopMatrix(); //end
}
}

 

Staff code and clientproxy registering in my base file(Arcticraft.java)

 

public static Item staff;

@PreInit
public void preInit(FMLPreInitializationEvent event)
{
	proxy.registerRenderInformation();
        }

@Init
public void Init(FMLInitializationEvent event)
{
this.initItems();
}

public void initItems() 
{
	this.staff = (new AC_ItemStaff(1950).setItemName("staff").setIconCoord(13, 2));
}

 

AC_ItemStaff:


package arcticraft.items;

import arcticraft.entities.AC_EntityStaffBall;
import net.minecraft.src.*;

import net.minecraft.client.Minecraft;

public class AC_ItemStaff extends Item
{
public AC_ItemStaff(int par1)
{
	super(par1);
	this.maxStackSize = 1;
	maxStackSize = 1;	  //1 for durability | 1-64 for consumption	
	setMaxDamage(1000);    //Durability = # + 1
	setTabToDisplayOn(CreativeTabs.tabCombat);
}




public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
	if(entityplayer.capabilities.isCreativeMode)
	{
		world.playSoundAtEntity(entityplayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

		if (!world.isRemote)
		{
			world.spawnEntityInWorld(new AC_EntityStaffBall(world, entityplayer, entityplayer, iconIndex, iconIndex));
		}

		return itemstack;
	}

	if (entityplayer.ridingEntity != null)
	{
		return itemstack;
	}
	else
	{

		world.playSoundAtEntity(entityplayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

		if (!world.isRemote)
		{
			world.spawnEntityInWorld(new AC_EntityStaffBall(world, entityplayer, entityplayer, iconIndex, iconIndex));
		}

		itemstack.damageItem(1, entityplayer); 
		return itemstack;}
}


public String getTextureFile()
{
	return "/arcticraft/textures/ACItems.png";
}
}


 

And thats probably all the code you need to know about. But yeah, I need help on this!

Link to comment
Share on other sites

  • 2 weeks later...

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.