-
Bug
-
Resolution: Unresolved
-
None
-
1.16.5, 21w14a, 21w15a, 21w16a, 21w17a, 21w18a, 21w19a, 21w20a, 1.17 Pre-release 4, 1.17 Pre-release 5, 1.17 Release Candidate 1, 1.17, 1.17.1 Pre-release 1, 1.17.1 Pre-release 2, 1.17.1 Pre-release 3, 1.17.1 Release Candidate 1, 1.17.1, 21w37a, 1.18.1, 22w05a, 22w06a, 1.18.2, 1.19, 1.19.1, 1.19.2, 22w43a, 1.19.3, 1.19.4, 1.20.1, 24w20a, 1.21, 1.21.3
-
Community Consensus
-
Player
The Bug:
You can use tridents enchanted with riptide while riding entities and in some cases, this can damage the entity you're riding.
Steps to Reproduce:
- Set the weather to "rain" and give yourself a trident enchanted with riptide by using the command provided below.
/give @s minecraft:trident[minecraft:enchantments={levels:{"minecraft:riptide":3}}]
- Ride any entity and attempt to throw the riptide trident.
- Take note as to whether or not you can use tridents enchanted with riptide while riding entities.
Observed Behavior:
You can use riptide tridents.
Expected Behavior:
You would not be able to use riptide tridents.
Code Analysis:
Code analysis by Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.19.2 using MCP-Reborn.
public class TridentItem extends Item implements Vanishable { ... public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand interactionHand) { ItemStack itemstack = player.getItemInHand(interactionHand); if (itemstack.getDamageValue() >= itemstack.getMaxDamage() - 1) { return InteractionResultHolder.fail(itemstack); } else if (EnchantmentHelper.getRiptide(itemstack) > 0 && !player.isInWaterOrRain()) { return InteractionResultHolder.fail(itemstack); } else { player.startUsingItem(interactionHand); return InteractionResultHolder.consume(itemstack); } } ...
If we look at the above class, we can see that there are two checks that are carried out before allowing the player to use a trident enchanted with riptide. One of these is to check if the player is actually holding a trident enchanted with riptide and the other is to check if they are in water or rain. The game doesn't check if the player is currently riding an entity before allowing them to throw a trident enchanted with riptide in the rain, therefore resulting in this problem occurring.
Fix:
Simply altering the appropriate existing "if" statement within this piece of code to check if the player is a passenger before allowing them to throw a trident enchanted with riptide in the rain, will resolve this problem. We can achieve this through the use of the isPassenger() boolean.
else if (EnchantmentHelper.getRiptide(itemstack) > 0 && !player.isInWaterOrRain())
else if (EnchantmentHelper.getRiptide(itemstack) > 0 && !player.isInWaterOrRain() || player.isPassenger())
- is duplicated by
-
MC-230308 Trident Bug
- Resolved