The Bug
When holding a cast fishing rod when switching to spectator mode, the rod remains cast.
Steps to Reproduce
Obtain a fishing rod and cast it.
Switch into spectator mode.
Take note as to whether or not fishing rods remain cast when switching into spectator mode.
Observed Behavior
Fishing rods remain cast when switching into spectator mode.
Expected Behavior
Fishing rods would not remain cast when switching into spectator mode.
Code Analysis
Code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 2
relates to 3
Attachments
Comments 17
The following is based on a decompiled version of Minecraft 1.12 using MCP 9.40pre-1. (By the way, 1.12 should be marked as affected here)
The method net.minecraft.entity.player.EntityPlayerMP.setGameType()
doesn't invoke the method net.minecraft.entity.player.EntityPlayerMP.fishEntity.handleHookRetraction()
which removes the fish hook entity from the player's world and returns the amount of damage which should be applied to the fishing rod after its retraction.
A simple solution to this issue would be to add this specific method invocation to the setGameType()
method.
Suggested fix
public void setGameType(GameType gameType)
{
// ...
if (gameType == GameType.SPECTATOR)
{
this.func_192030_dh();
this.dismountRidingEntity();
if(this.fishEntity != null) {
this.fishEntity.handleHookRetraction();
}
}
else
{
this.setSpectatingEntity(this);
}
// ...
}
if(this.fishEntity != null)
checks if the player has casted a fish hook. Without this If-statement the game would throw a NullPointerException because it obviously can't remove a fishEntity that doesn't exist.
Can confirm for 21w42a.
When going to spectator the rods remain cast, also when left clicking you can still see the swing animation in the wire of the rod.
Also the sound that you have a fish hanging on the rod can still play.
Confirmed.