aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0145-LivingEntity-setKiller.patch
blob: ece70c37de8f60858beb5edfef94835dc71fe1c1 (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: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Mon, 31 Jul 2017 01:49:48 -0500
Subject: [PATCH] LivingEntity#setKiller

== AT ==
public net.minecraft.world.entity.LivingEntity lastHurtByPlayerTime

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 4636e1ebf11025a551d398a6594b1506748a8390..82773a05783b731e2f7bd00c8ec68090d15a7b66 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -390,6 +390,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
         return this.getHandle().lastHurtByPlayer == null ? null : (Player) this.getHandle().lastHurtByPlayer.getBukkitEntity();
     }
 
+    // Paper start
+    @Override
+    public void setKiller(Player killer) {
+        net.minecraft.server.level.ServerPlayer entityPlayer = killer == null ? null : ((CraftPlayer) killer).getHandle();
+        getHandle().lastHurtByPlayer = entityPlayer;
+        getHandle().lastHurtByMob = entityPlayer;
+        getHandle().lastHurtByPlayerTime = entityPlayer == null ? 0 : 100; // 100 value taken from EntityLiving#damageEntity
+    }
+    // Paper end
+
     @Override
     public boolean addPotionEffect(PotionEffect effect) {
         return this.addPotionEffect(effect, false);