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.

[1.10.2] Animated model not updating in first person. (possibly bug)

Featured Replies

Posted

Hi,

When I edit the NBT-tag of my item there is a little "up-and down"-animation in first person (same animation as switching slots). I wanted to prevent this animation by overriding Item::shouldCauseReequipAnimation to compare the items and ignore the particular NBT-change that I made. The problem is that now my animated models (OBJModels that I re-bake in ItemOverrideList::handleItemState) don't update anymore... This was already reported as bug here: https://github.com/MinecraftForge/MinecraftForge/issues/2672, but was marked as fixed by LexManos so I'm looking for a different way to prevent the "NBT-animation"...

 

It would also work if I had a better way to get the Hand in ItemOverrideList::handleItemState. Currently I'm doing this:

EnumHand hand = null;
if (stack.equals(entity.getHeldItemMainhand())) {
     hand = EnumHand.MAIN_HAND;
} else if (stack.equals(entity.getHeldItemOffhand())) {
     hand = EnumHand.OFF_HAND;
}

 

But 'stack' equals neither of the items in the hands of the player if I override shouldCauseReequipAnimation

I don't have an answer but maybe if you look into what is different between the stacks after you override

Item::shouldCauseReequipAnimation()

using debugging you may figure out a way to fix it.

I believe it's either in the way

stack.equals(otherStack)

or

entity.getHeldItemMainhand()

/

entity.getHeldItemOffhand()

operate.

  • Author

In my mod it is very likely that you hold items with the same stats (also same NBT data) in both hands, so there will often be no differences.

  • Author

it returns false because equals in ItemStack just checks the instance

Oh I thought that ItemStack overrides Object.equals()

Then why don't you use isItemStackEqual() if you want strict equals or just compare the items because the same items are of the same instance.

  • Author

As I said, it is very likely that the player can hold the same item with the same stats in both hands

You need to use ItemStack.areStackEqual

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Tried that but it is very likely that everything besides the instance can be the same for both stacks

The problem is that I change the NBTtag on the server. When the client updates, does it create a new instance of the item if it is not the same as on the server? The item that will be returned in HandleItemState is stored in ItemRenderer (itemStackMainHand and itemStackOffHand fields) These fields are updating in ItemRenderer::updateEquippedItem every tick. But since I override shouldCauseReequipAnimation, this is prevented. This might cause it to desync when renderFireInFirstPerson is called, because it's no longer the actual ItemStack held by the player. 

 

Edit: There's even a comment in renderItemInFirstPerson, that says "//Forge: Data watcher can desync"

Tried that but it is very likely that everything besides the instance can be the same for both stacks

 

That's why you use ItemStack.areStacksEqual.  Because it gives no shits about instances.

 

However, it DOES check NBT tags, which if those are different it's going to say the items are different. You're going to have to replicatethe functionality to check what you want it to check and ignore what you want it to ignore.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

As I said, it is very likely, that the NBT tags are also the same. Even if they are not, it won't work because ItemRenderer#itemStackMainHand and ItemRenderer#itemStackOffHand are not updated since I need to override the shouldCauseReequipAnimation to prevent the animation after an NBT-edit

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.