PaperMC/patches/server-unmapped/0166-LivingEntity-setKiller.patch
2021-06-11 14:02:28 +02:00

48 lines
2.3 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/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 036577b0237e9c8a7ab22ede7477eefa1abecf96..752cd55d8eb9e2e26e7cbfb9ce18b4ba56538002 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -180,7 +180,7 @@ public abstract class EntityLiving extends Entity {
public float aE;
@Nullable
public EntityHuman killer;
- protected int lastDamageByPlayerTime;
+ public int lastDamageByPlayerTime; // Paper - protected -> public
protected boolean killed;
protected int ticksFarFromPlayer;
protected float aJ;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index c654026587bc9bf77b39f59a0c89991ac581da1e..c43c300963bae9bca6ab9c9389dd53e42318715c 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.EntityPlayer;
import net.minecraft.world.EnumHand;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffect;
@@ -344,6 +345,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return getHandle().killer == null ? null : (Player) getHandle().killer.getBukkitEntity();
}
+ // Paper start
+ @Override
+ public void setKiller(Player killer) {
+ EntityPlayer entityPlayer = killer == null ? null : ((CraftPlayer) killer).getHandle();
+ getHandle().killer = entityPlayer;
+ getHandle().lastDamager = entityPlayer;
+ getHandle().lastDamageByPlayerTime = entityPlayer == null ? 0 : 100; // 100 value taken from EntityLiving#damageEntity
+ }
+ // Paper end
+
@Override
public boolean addPotionEffect(PotionEffect effect) {
return addPotionEffect(effect, false);