PaperMC / PaperMC/Paper

EntityKnockbackByEntityEvent called with wrong entities

Open
#7,168 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Expected behavior

The EntityKnockbackByEntityEvent#hitBy() entity should be called with the entity that did the knockback

Observed/Actual behavior

Instead, if the entity that did the knockback is a projectile or a TNT, the #hitBy entity is a player (shooter of the projectile or the one that lit the TNT) instead of the entity that actually did the knockback

Steps/models to reproduce

Example 1:

  1. Throw a snowball
  2. EntityKnockbackByEntityEvent will be called with #hitBy set to the shooter of the snowball instead of the actual snowball entity

Example 2:

  1. Get a TNT and flint and steel
  2. Prime the TNT
  3. EntityKnockbackByEntityEvent will be called with #hitBy set to the player that primed the TNT instead of the TNT entity

Example 3:

  1. /summon tnt
  2. EntityKnockbackByEntityEvent will not be called because there was no entity that primed the TNT
Plugin and Datapack List

Only a plugin that was printing the #hitBy entity into the console. No datapacks.

Paper version

This server is running Paper version git-Paper-85 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: df8d28a)
You are running the latest version

Other

No response

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 tracing where EntityKnockbackByEntityEvent is created and where hitBy() is assigned for projectile and TNT knockback. Reproduce the snowball and primed-TNT cases, including summoned TNT, then verify that hitBy() is the projectile or TNT entity and that the event is emitted consistently.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.