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



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hi, This is my first foray into Forge and i am confident I am making a silly mistake somewhere, any advice would be appreciated. Objective Have a custom mod; mymod Have a custom item with a custom texture; mymod_item Provision resource pack for lang, model and texture assets for mymod_item Run a dedicated Forge server with the mod installed and requiring the resource pack Expected behaviour Player connects to dedicated server and downloads asset pack Player is given custom item /give @p mymod.mymod_item Player inventory to display item with custom texture and to be visible when dropped Actual behavior When running a Forge client from the IDE tasks, the textures load for singleplayer (via local Forge mod deployment) When running a Forge client from the IDE tasks, the textures load for multiplayer games (via asset pack) When running a vanilla client in singleplayer mode, as expected it does not work as it has no concept of my entities. When running a vanilla client in multiplayer mode, the asset pack is downloaded and an invisible item is granted (I have some logging on the item so that i know I "have" it) Noteworth When giving the item to the player on the vanilla client, the name is displayed correctly implying that the lang/en_us.json is being loaded correctly. My asset pack also overrides the minecraft:item/gold_ingot texture with the exact same one used for mymod:mymod_item and this is loaded fine as a replacement. Asset pack tree assets/minecraft/textures/item/gold_ingot.png assets/mymod/textures/item/mymod_item.png assets/mymod/models/item/mymod_item.json assets/mymod/lang/en_us.json pack.mcmeta   Summary I suspect that i am doing something that i am not supposed to but unfortunately its not jumping out to me quite what that may be! One of the pieces i am struggling to understand is what ties the mymod_item class to the resources? In my code i do net set any explicit ResourceLocations for it, should I be? Thanks
    • This is a terrible idea... And inferior to the actual solution (separate game directories) in every way. There is a good reason why Forge does not do this anymore. If you really want to, you can provide your own IModLocator implementation, which allows you to plug into FMLs mod loading process and provide additional mods to load. It is discovered via the standard Java service loader, see the ModDiscoverer class. The config system is irrelevant here, as this happens before mods are even loaded.
    • Post the launcher log.
    • i have installed forge and it is in my minecraft launcher, i have updated to the most recent java but yet when i launch nothing pops up and when i try to launch again it says that the game is running i have gone to control panel and task manager but they both says its not running i would like some help with with please.    
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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