The Bug:
Pointed dripstone can be destroyed by tridents in adventure mode.
Steps to Reproduce:
Place down some pointed dripstone and obtain a trident.
Switch to adventure mode and shoot the trident at the pointed dripstone.
Take note as to whether or not pointed dripstone can be destroyed by tridents in adventure mode.
Observed Behavior:
Pointed dripstone can be destroyed.
Expected Behavior:
Pointed dripstone would not be able to be destroyed.
Code Analysis:
Code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 2
relates to 3
Attachments
Comments 12
Here's a code analysis along with a potential fix regarding this issue.
Code Analysis:
The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.
net.minecraft.world.level.block.PointedDripstoneBlock.java
public class PointedDripstoneBlock extends Block implements Fallable, SimpleWaterloggedBlock {
...
public void onProjectileHit(Level $l, BlockState $bs, BlockHitResult $bhr, Projectile $p) {
BlockPos blockpos = $bhr.getBlockPos();
if (!$l.isClientSide && $p.mayInteract($l, blockpos) && $p instanceof ThrownTrident && $p.getDeltaMovement().length() > 0.6D) {
$l.destroyBlock(blockpos, true);
}
}
...
If we look at the above class, we can see that no checks are carried out to see what abilities the player possesses when using a thrown trident to destroy pointed dripstone. The only checks that are in place are as follows:
Was the action non-client-side?
Can the pointed dripstone be interacted with? (Is the pointed dripstone outside of spawn protection and within the world border?)
Does the trident have enough velocity to destroy the pointed dripstone?
These checks are evident through the following line of code:
if (!$l.isClientSide && $p.mayInteract($l, blockpos) && $p instanceof ThrownTrident && $p.getDeltaMovement().length() > 0.6D)
!$p.getAbilities().mayBuild
Avoma your potential fix is incorrect. $p is referring to the projectile, which doesn't have getAbilities() you would need to first check if the trident had an owner, then check if that owner is a Player and then get the abilities.
Hmm, yes, you're right, my bad. I've removed the potential fix but have kept the code analysis. Thanks 🙂
Can confirm.