Posted August 16, 20169 yr 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
August 16, 20169 yr 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.
August 16, 20169 yr 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.
August 16, 20169 yr that's why I said you should looks into the reason the stack.equals() returns false
August 16, 20169 yr 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.
August 16, 20169 yr Author As I said, it is very likely that the player can hold the same item with the same stats in both hands
August 16, 20169 yr 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.
August 17, 20169 yr 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"
August 17, 20169 yr 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.
August 17, 20169 yr 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.