mojira.dev
MC-211561

Fishing line appears in opposite hand when switching slots

The bug

The line of the fishing rod moves to the opposite hand when switching away from a cast fishing rod.

Steps to reproduce

  • Cast a fishing rod

  • Switch to another slot that is not a fishing rod
    → ❌ Notice how the fishing rod line appears in the offhand as if the rod was cast from the offhand.

Code analysis & fix

Code analysis and fix by @unknown can be found in this comment.

Linked issues

Attachments

Comments 10

[media]

Can confirm in 1.16.5. Here are some steps to reproduce this issue:

Steps to Reproduce:

  • Cast a fishing rod.

  • Switch to another hotbar slot whilst the rod is cast.
    → ❌  Notice how the fishing line appears in the offhand for a split second.

Can't confirm for 21w11a because of MC-219849

Unblocked in 21w14a.

Code Analysis:

The following is based on a decompiled version of Minecraft 1.20.1 using MCP-Reborn.

net.minecraft.client.renderer.entity.FishingHookRenderer.java // Original

public class FishingHookRenderer extends EntityRenderer<FishingHook> {
   ...
   int i = player.getMainArm() == HumanoidArm.RIGHT ? 1 : -1; 
   ItemStack itemstack = player.getMainHandItem(); 
   if (!itemstack.is(Items.FISHING_ROD)) { 
      i = -i; 
   }
   ...
}

We can take a look at this specific part of code in the decompiled version of Minecraft 1.20.1, as we can see, if a fishing rod is NOT present in the player's main arm, as a default it will be the right hand. Then it will automatically move the fishing line towards the player's offhand, without it even checking for a fishing rod in the offhand.

Fix:

To fix this, we can easily add a condition to the current "if" statement in the code above, checking if the player has a fishing rod in the offhand. Therefore, whenever you swap out of the fishing rod, it'll persist on the default side of the mainhand.

net.minecraft.client.renderer.entity.FishingHookRenderer.java // Updated

public class FishingHookRenderer extends EntityRenderer<FishingHook> {
   ...
   int i = player.getMainArm() == HumanoidArm.RIGHT ? 1 : -1;
   ItemStack itemstack = player.getMainHandItem();
   if (!itemstack.is(Items.FISHING_ROD) && player.getOffhandItem().is(Items.FISHING_ROD)) {
      i = -i;
   }
   ...
}

@unknown, 1.20.1 has already been marked as affected!

Can confirm in 1.20.5rc2.

Can confirm in 1.20.5rc2.

Can confirm in 24w21b.

Lentern

(Unassigned)

Confirmed

Rendering

animation, fishing-line, fishing_rod, item, off-hand, off-hand-animation, rendering

1.16.4, 20w51a, 21w03a, 1.16.5, 21w05b, ..., 24w21b, 1.21, 1.21.1, 24w35a, 24w39a

Retrieved