The Bug:
Chorus flowers can be destroyed by projectiles in adventure mode.
Steps to Reproduce:
Place down a chorus flower and obtain a bow and some arrows.
Switch to adventure mode and shoot the arrow at the chorus flower.
Take note as to whether or not chorus flowers can be destroyed by projectiles in adventure mode.
Observed Behavior:
Chorus flowers can be destroyed.
Expected Behavior:
Chorus flowers would not be able to be destroyed.
Code Analysis:
Code analysis by @unknown can be found in this comment.
Linked issues
relates to 3
Attachments
Comments 10
Can also confirm in 21w37a. This ticket relates to MC-225365 and MC-223322. Here are some additional details regarding this issue.
The Bug:
Chorus flowers can be broken with projectiles in adventure mode.
Steps to Reproduce:
Place down a chorus flower and obtain a projectile.
Switch into adventure mode and shoot the projectile at the chorus flower.
→ ❌ Notice how chorus flowers can be broken with projectiles in adventure mode.
Expected Behavior:
The expected behavior would be that chorus flowers cannot be broken with projectiles in adventure mode.
I can confirm this behavior in 1.18.1.
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.ChorusFlowerBlock.java
public class ChorusFlowerBlock extends Block {
...
public void onProjectileHit(Level $l, BlockState $bs, BlockHitResult $bhr, Projectile $p) {
BlockPos blockpos = $bhr.getBlockPos();
if (!$l.isClientSide && $p.mayInteract($l, blockpos) && $p.getType().is(EntityTypeTags.IMPACT_PROJECTILES)) {
$l.destroyBlock(blockpos, true, $p);
}
}
...
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 projectiles to destroy chorus flowers. The only checks that are in place are as follows:
Was the action non-client-side?
Can the chorus flower be interacted with? (Is the chorus flower outside of spawn protection and within the world border?)
Is the projectile a part of the
IMPACT_PROJECTILES
entity tag?
These checks are evident through the following line of code:
if (!$l.isClientSide && $p.mayInteract($l, blockpos) && $p.getType().is(EntityTypeTags.IMPACT_PROJECTILES))
Potential Fix:
Simply adding a line of code that checks what abilities the player possesses before a projectile can destroy a chorus flower, should resolve this problem. The following line of code could be used in order to fix this:
!$p.getAbilities().mayBuild
Can confirm.