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

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?

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

  • Author

I've switched it to:

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

and now the items invisible?

*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:
	}
}

 

 

  • Author

Also (sorry if i'm being a nuisance) the texture isn't loading and the model in 3rd person is horizontal instead of at a 45 degree angle into my hand. I don't know which rotation does that angling?

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);

  • Author

The thing is that I've changed each axis in the code that I posted and none of those three coralates to that axis. But I'll try it again just to make sure.

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

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.