Fix DamageSource API

Uses the correct entity in the EntityDamageByEntity event
Returns the correct entity for API's DamageSource#getCausingEntity
This commit is contained in:
Jake Potrebic
2024-03-09 14:13:04 -08:00
parent a87a5e10d9
commit d42ef390ea
12 changed files with 36 additions and 50 deletions

View File

@@ -24,7 +24,7 @@
if (target.isAlive() && !target.isInvulnerable() && target != entityliving1) {
if (entityliving1 == null) {
- target.hurt(this.damageSources().magic(), 6.0F);
+ target.hurt(this.damageSources().magic().customEntityDamager(this), 6.0F); // CraftBukkit
+ target.hurt(this.damageSources().magic().customEventDamager(this), 6.0F); // CraftBukkit // Paper - fix DamageSource API
} else {
if (entityliving1.isAlliedTo((Entity) target)) {
return;

View File

@@ -48,7 +48,7 @@
entityplayer1.resetFallDistance();
entityplayer1.resetCurrentImpulseContext();
- entityplayer1.hurtServer(entityplayer.serverLevel(), this.damageSources().enderPearl(), 5.0F);
+ entityplayer1.hurtServer(entityplayer.serverLevel(), this.damageSources().enderPearl().customEntityDamager(this), 5.0F); // CraftBukkit
+ entityplayer1.hurtServer(entityplayer.serverLevel(), this.damageSources().enderPearl().customEventDamager(this), 5.0F); // CraftBukkit // Paper - fix DamageSource API
}
this.playSound(worldserver, vec3d);

View File

@@ -21,7 +21,7 @@
}
} else {
- flag = entity.hurtServer(worldserver, this.damageSources().magic(), 5.0F);
+ flag = entity.hurtServer(worldserver, this.damageSources().magic().customCausingEntity(this), 5.0F); // Paper - Fire EntityDamageByEntityEvent for unowned wither skulls
+ flag = entity.hurtServer(worldserver, this.damageSources().magic().customEventDamager(this), 5.0F); // Paper - Fire EntityDamageByEntityEvent for unowned wither skulls // Paper - fix DamageSource API
}
if (flag && entity instanceof LivingEntity entityliving) {