PaperMC / PaperMC/Paper

ProjectileHitEvent not called multiple times for entites close to each other

Open
#10,801 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: accepted type: bug version: 1.20.6 version: 1.21 version: 1.21.1
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Expected behavior

When having 2 entities stand right behind each other. cancelling the ProjectileHitEvent would result in the event being called once for the first entity and once for the second entity.

Observed/Actual behavior

the event only gets called once for the closest entity to the shooter however not for the second entity

Steps/models to reproduce

cancel ProjectileHitEvent and print out when the event gets called with the playername. line up 2 players/entities (i would just use 2 players since this issue also relies on how big the hitbox of the entity is) as close as possible behind each other. shoot straight through both entites/players. see that the event only got called once

Plugin and Datapack List

just a test plugin to cancel the event

Paper version

[10:12:21 INFO]: Checking version, please wait...
[10:12:21 INFO]: This server is running Paper version 1.20.6-113-master@23fe116 (2024-05-27T17:40:35Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT)
You are running the latest version

Other

This issue happens because in the logic where the arrow checks if there is an entity to hit in the hit box it only returns the closest entity instead of all entities in that area, resulting in it not trying to hit the next entity if the event is cancelled.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with a test plugin that cancels ProjectileHitEvent, using two aligned entities or players and an arrow. Inspect the arrow's entity hit-box logic, which the report identifies as returning only the closest entity; done means the cancelled event is called for each entity in the projectile's path.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.