PaperMC/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch
2024-12-14 13:05:27 +01:00

20 lines
1.2 KiB
Diff

--- a/net/minecraft/world/entity/Interaction.java
+++ b/net/minecraft/world/entity/Interaction.java
@@ -130,9 +_,16 @@
@Override
public boolean skipAttackInteraction(Entity entity) {
if (entity instanceof Player player) {
+ // CraftBukkit start
+ DamageSource source = player.damageSources().playerAttack(player);
+ org.bukkit.event.entity.EntityDamageEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNonLivingEntityDamageEvent(this, source, 1.0F, false);
+ if (event.isCancelled()) {
+ return true;
+ }
+ // CraftBukkit end
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
}
return !this.getResponse();