Paper/Remapped-Spigot-Server-Patches/0166-LivingEntity-setKiller.patch
2021-06-11 13:56:17 +02:00

49 lines
2.4 KiB
Diff

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
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index c1786fcabeaee5732e9197db04268c5c4e164339..d6b4fabd232958ae1fd5405c7129551951cd7765 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -177,7 +177,7 @@ public abstract class LivingEntity extends Entity {
public float flyingSpeed;
@Nullable
public net.minecraft.world.entity.player.Player lastHurtByPlayer;
- protected int lastHurtByPlayerTime;
+ public int lastHurtByPlayerTime; // Paper - protected -> public
protected boolean dead;
protected int noActionTime;
protected float oRun;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index d8cd88d62f9abfc7960c187dd74239f61267ca57..006f4c71bbcda61b55815e7ceab91731ab062da0 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -8,6 +8,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
+import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffect;
@@ -332,6 +333,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return getHandle().lastHurtByPlayer == null ? null : (Player) getHandle().lastHurtByPlayer.getBukkitEntity();
}
+ // Paper start
+ @Override
+ public void setKiller(Player killer) {
+ 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 addPotionEffect(effect, false);