Cleanup damage source a bit (#12106)

This commit is contained in:
Lulu13022002
2025-02-16 20:14:00 +01:00
committed by GitHub
parent 608f004a2c
commit 7bee99714a
31 changed files with 135 additions and 215 deletions

View File

@@ -5,7 +5,7 @@
public boolean skipAttackInteraction(Entity entity) {
if (entity instanceof Player player) {
+ // CraftBukkit start
+ DamageSource source = player.damageSources().playerAttack(player);
+ DamageSource source = player.damageSources().generic().eventEntityDamager(entity);
+ org.bukkit.event.entity.EntityDamageEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNonLivingEntityDamageEvent(this, source, 1.0F, false);
+ if (event.isCancelled()) {
+ return true;
@@ -14,7 +14,7 @@
this.attack = new Interaction.PlayerAction(player.getUUID(), this.level().getGameTime());
if (player instanceof ServerPlayer serverPlayer) {
- CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, player.damageSources().generic(), 1.0F, 1.0F, false);
+ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, player.damageSources().generic(), 1.0F, (float) event.getFinalDamage(), false); // CraftBukkit // Paper - use correct source and fix taken/dealt param order
+ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, source, 1.0F, (float) event.getFinalDamage(), false); // CraftBukkit // Paper - use correct source and fix taken/dealt param order
}
return !this.getResponse();