From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Mark Vainomaa Date: Sun, 13 Dec 2020 05:32:05 +0200 Subject: [PATCH] Expose LivingEntity hurt direction diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java index a8731cf957da9aad7ed6f5d372500bc34afd32ca..b36492efc3d6338e0099988c1ff31e7211b7d010 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java @@ -182,7 +182,7 @@ public abstract class Player extends LivingEntity { private Optional lastDeathLocation; @Nullable public FishingHook fishing; - protected float hurtDir; + public float hurtDir; // Paper - protected -> public // Paper start public boolean affectsSpawning = true; // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index b0d2038cf2622c8ee7f810026ed735ff954d7ad0..a8aa176b8afd45fada9529d4d0b92000299faf1b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -126,6 +126,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } } + // Paper start + @Override + public void setHurtDirection(float hurtDirection) { + this.getHandle().hurtDir = hurtDirection; + } + // Paper end + @Override public int getSleepTicks() { return this.getHandle().sleepCounter; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 4bdb06c18824c99475ea7a9cc4237b0879e705a8..c74a6df6a9c3c7745daae4c0558948ea4a31d7a6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -910,5 +910,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void playPickupItemAnimation(org.bukkit.entity.Item item, int quantity) { getHandle().take(((CraftItem) item).getHandle(), quantity); } + + @Override + public float getHurtDirection() { + return this.getHandle().getHurtDir(); + } + + @Override + public void setHurtDirection(float hurtDirection) { + throw new UnsupportedOperationException("Cannot set the hurt direction on a non player"); + } // Paper end }