Paper/patches/server/0372-Add-PlayerAttackEntityCooldownResetEvent.patch

29 lines
2.0 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: nossr50 <nossr50@gmail.com>
Date: Thu, 26 Mar 2020 19:44:50 -0700
Subject: [PATCH] Add PlayerAttackEntityCooldownResetEvent
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2023-06-08 00:41:25 +02:00
index 6fbd1209edf59dab9cc8b0f568f2d31846264457..934c5246f43566a7277b77d0e74b38fc94c6836f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2023-06-08 00:41:25 +02:00
@@ -2169,7 +2169,16 @@ public abstract class LivingEntity extends Entity implements Attackable {
2021-06-11 14:02:28 +02:00
EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
if (damagesource.getEntity() instanceof net.minecraft.world.entity.player.Player) {
- ((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetAttackStrengthTicker(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
+ // Paper start - PlayerAttackEntityCooldownResetEvent
+ if (damagesource.getEntity() instanceof ServerPlayer) {
+ ServerPlayer player = (ServerPlayer) damagesource.getEntity();
+ if (new com.destroystokyo.paper.event.player.PlayerAttackEntityCooldownResetEvent(player.getBukkitEntity(), this.getBukkitEntity(), player.getAttackStrengthScale(0F)).callEvent()) {
+ player.resetAttackStrengthTicker();
+ }
+ } else {
+ ((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetAttackStrengthTicker();
+ }
+ // Paper end
}
if (event.isCancelled()) {
return false;