Jump to content

Item model only visible in 3rd person.


Fruitsalid

Recommended Posts

I made a custom item model for a hammer just to test it out and it is only visible in 3rd person. In 1st person it just looks like the item icon I gave it.

Here's the render code:

public class RenderHammer implements IItemRenderer
{

protected ModelHammer hammerModel;

public RenderHammer()
{
	hammerModel = new ModelHammer();
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
	switch(type)
	{
	case EQUIPPED: return true;
	default: return false;
	}
}

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

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
	switch(type)
	{
	case EQUIPPED:
	{
		GL11.glPushMatrix();
		Minecraft.getMinecraft().renderEngine.func_110577_a(new ResourceLocation("/assets/magicelements/textures/models/Hammer.png"));

		GL11.glRotatef(192F, 1.0F, 0.0F, 0.0F);
		GL11.glRotatef(95F, 0.0F, 1.0F, 0.0F);
		GL11.glRotatef(-10F, 0.0F, 0.0F, 1.0F);

		float scale = 1.6F;
		GL11.glScalef(scale, scale, scale);


		this.hammerModel.render((Entity)data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);

		GL11.glPopMatrix();
	}
		default:
	}
}
}

 

Anyone know whats wrong?

Link to comment
Share on other sites

because you're telling it not to render it in 3d

 

	@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
	switch(type)
	{
	case EQUIPPED: return true;
	default: return false;
	}
}

 

include EQUIPPED_FIRST_PERSON in there

Link to comment
Share on other sites

*facepalm* you don't even need to know java to solve that. all you need is common sense. if you seriously can't figure out what you did wrong.. here..

 

 

i said include EQUIPPED_FIRST_PERSON. not to replace EQUIPPED with it. both of them should be there. common sense also dictates that you're going to have to edit this part

 

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
	switch(type)
	{
	case EQUIPPED:
	{
		GL11.glPushMatrix();
		Minecraft.getMinecraft().renderEngine.func_110577_a(new ResourceLocation("/assets/magicelements/textures/models/Hammer.png"));

		GL11.glRotatef(192F, 1.0F, 0.0F, 0.0F);
		GL11.glRotatef(95F, 0.0F, 1.0F, 0.0F);
		GL11.glRotatef(-10F, 0.0F, 0.0F, 1.0F);

		float scale = 1.6F;
		GL11.glScalef(scale, scale, scale);


		this.hammerModel.render((Entity)data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);

		GL11.glPopMatrix();
	}
		default:
	}
}

 

 

Link to comment
Share on other sites

regarding the angle thing, you can figure out which one it is by yourself really. just play around with the GL11.glRotatef(angle, x, y, z) parts until you figure out which axis is which.

 

regarding the texture, make sure the location of the texture that you put is correct and that your texture is actually there. if that doesn't work, maybe try

 

RenderBlocks renderBlocks = (RenderBlocks) data[0];
renderBlocks.minecraftRB.renderEngine.func_110577_a(ResourceLocation);

 

instead of

 

Minecraft.getMinecraft().renderEngine.func_110577_a(ResourceLocation);

Link to comment
Share on other sites

Well, in case you didn't know, once you rotate the object, the axes rotate along with it. So if you rotate the model along the x-axis, you change the y and z axes. I suggest you start out with only one line of glrotate and then add more of them if you need to rotate it again in a different axis

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.