aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0341-Add-PlayerAttackEntityCooldownResetEvent.patch
blob: 620e81e21006a9d1da1b0bb667cbf7a5991ded50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
index 4fb99e3ee14d2e7fe2720e25af1c890004b0c250..25a2085ed68d393afbb658b63a1cd39af98f39fa 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2352,7 +2352,17 @@ public abstract class LivingEntity extends Entity implements Attackable {
             }
 
             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
+                //((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
+                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 - PlayerAttackEntityCooldownResetEvent
             }
 
             // Resistance