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 4bac05cb48d81dc9776d90502b6f12285b92122b..2957b3929c1e92af1b1a2636b83b757a0fbc789d 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java @@ -178,7 +178,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 7406094fc58e5df4f5d553bb882c75ba6ef766a9..faaed968a3e771c1db3957e2b42acf6d87a38842 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 6fdf8460dcb396f2c83f1394bc9cfbb3f35cbd48..022741182869348e377746bf2a3792a07155abc5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -936,5 +936,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 }