Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancelling ProjectileHitEvent for entity collisions allows arrows to phase through blocks #11478

Open
TonytheMacaroni opened this issue Oct 8, 2024 · 1 comment · May be fixed by #10804
Open
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21.1

Comments

@TonytheMacaroni
Copy link
Contributor

Expected behavior

Cancelling ProjectileHitEvent for entity collisions should not prevent block collisions.

Observed/Actual behavior

Cancelling a ProjectileHitEvent fired for hitting an entity can cause arrows to phase through blocks.

Steps/models to reproduce

Shoot an arrow at an entity on the edge of its bounding box, towards the ground. If positioned correctly, the arrow will phase into a block. If the ground is thin enough, it will continue travelling after phasing into the block. Otherwise, it will be lodged within the ground.
Example image of lining up a shot:
Image

Plugin and Datapack List

Only a test plugin, with the following listener to cancel ProjectileHitEvent:

public class TestListener implements Listener {

    @EventHandler
    public void onHit(ProjectileHitEvent event) {
        if (event.getHitEntity() != null) event.setCancelled(true);
    }

}

Paper version

This server is running Paper version 1.21.1-119-master@7cd4f2c (2024-10-03T15:19:34Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.1-85-c5a1066 (MC: 1.21.1)

Other

This seems to be a result of the logic in AbstractArrow#tick and Projectile#preHitTargetOrDeflectSelf. Arrows first ray trace to determine any block collisions, and then does another ray trace to find hit entities. If an entity that can be hit is found, the hit result is passed to Projectile#preHitTargetOrDeflectSelf. As such, the block collision is never considered, including when the ProjectileHitEvent is cancelled.

@TonytheMacaroni TonytheMacaroni added status: needs triage type: bug Something doesn't work as it was intended to. labels Oct 8, 2024
@notTamion
Copy link
Contributor

should be fixed in #10804 incase you want to test it (would be nice if a team member could slap an build-pr label on that)

@Lulu13022002 Lulu13022002 added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed status: needs triage labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21.1
Projects
Status: ✅ Accepted
Development

Successfully merging a pull request may close this issue.

3 participants