Bow Infinity Fix (Forge/Fabric)

Bow Infinity Fix (Forge/Fabric)

6M Downloads

Animation glitch in 1.21.1 with shield in offhard

Advaera opened this issue ยท 1 comments

commented

In MC 1.21.1, Fabric 0.16.7, and Bow Infinity Fix 3.1.0:
When there is a shield in the offhand then the animation does not display knocking an arrow in the bow. Instead the animation shows the player holding a shield and an empty bow and the player loses a lot of screen real estate to aim the bow due to the shield. This appears to be a bug that should be replaced by the normal aiming animation.

If there's any additional information I can provide to help isolate the cause please let me know!

Thanks!

commented

I spent a long time poking at this. I can confirm that I'm seeing what you're seeing. This stems from the way I changed the mod in 1.21 to utilize the new data-driven enchantments mechanic that Mojang introduced. Now to ask if any enchantments are on the bow or crossbow that would reduce the amount of ammo used to 0, I need to ask the server -- I can't also ask the client. Before, I could ask the server and the client together if the bow or crossbow has Infinity on it, and that kept everything in sync (assuming what was in your main or off hand wasn't desynced between the two). Since I can only ask the server under the new system, the client thinks the Bow didn't work, and moves on to trying your off-hand. Eventually, the server will tell the client that the bow did in fact work, and it should be using that. If you have nothing in your off-hand, this works as expected. However if you have anything in your off-hand, then that gets potentially used before the client and server sync back up (or, they don't sync back up because the client thinks it should be using the shield, until you let go, when they then realize what item they really should've been using the whole time). The shield just makes it very obvious, but it also works if you have any block in your off-hand. It gets placed if you have an Infinity bow and no arrows in your inventory. Add one arrow, and you see the behavior change. So good find!

Unfortunately, it looks like the client-server desync is a tough nut to crack, and I'm having a hard time coming up with a good fix for it. I do have a "fix" where it properly shows the bow drawing animation rather than the shield blocking animation, but it still doesn't fully fix the underlying bug; the things in your off-hand still have a chance to be used before you start drawing your bow if you don't have an arrow in your inventory. I guess that's probably better than what we had before, but it still bugs me that I don't have a complete fix. Gonna sleep on it (and hopefully not take as long to get back to this as I did to get to this in the first place ๐Ÿ˜…) and see if anything fresh comes to mind. Otherwise, I'll just take what we've got for now as an improvement and publish it.

Thanks for reporting!