Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


TPD
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.