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.

Changing Item Render Rotation Based on player rotationPitch [UNSOLVED] [1.7.10]

Featured Replies

Posted

Hello everyone.

 

I would like to know how I can change the rotation angle of my custom rendered item depending on the players rotationPitch (up / down angle) I would kind of like to do what the map does, but I can't find the code that allows the map to do this anywhere. So, my question really is; how do I get the players rotationPitch from the item renderer? there is no EntityPlayer parameter in any of the methods in IItemRenderer, and I can't find a way to get the player that is holding the current item from the ItemStack parameters. If I could do either of these two things, I would be fine from there to achieve the rest.

 

Thanks.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

  • Author

Okay, I figured it out. I simply did the following:

public Minecraft mc = Minecraft.getMinecraft(); //Get an instance of minecraft

//Then in renderItem method
        //...Irrelevant code here...
        float pitch = this.mc.thePlayer.rotationPitch;
        GL11.glRotatef(rotationPitch, 1, 0, 0);
        //...Then just the rest of the rendering code here

 

Now obviously there is more to this, like GL11.glPush/PopMatrix(); and model.renderAll() (if using obj) and whatever other rotation values there are, but this is the general idea that I had, get an instance of the player from Minecraft.getMinecraft().

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

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.