Expose LivingEntity hurt direction

This commit is contained in:
Mark Vainomaa 2020-12-13 05:32:05 +02:00
parent 3f4b9fd365
commit 1cedeb97af
3 changed files with 37 additions and 9 deletions

View File

@ -35,12 +35,20 @@
public final InventoryMenu inventoryMenu; public final InventoryMenu inventoryMenu;
public AbstractContainerMenu containerMenu; public AbstractContainerMenu containerMenu;
protected FoodData foodData = new FoodData(); protected FoodData foodData = new FoodData();
@@ -188,7 +198,18 @@ @@ -181,13 +191,24 @@
private Optional<GlobalPos> lastDeathLocation;
@Nullable
public FishingHook fishing;
- protected float hurtDir;
+ public float hurtDir; // Paper - protected -> public
@Nullable
public Vec3 currentImpulseImpactPos;
@Nullable
public Entity currentExplosionCause; public Entity currentExplosionCause;
private boolean ignoreFallDamageFromCurrentImpulse; private boolean ignoreFallDamageFromCurrentImpulse;
private int currentImpulseContextResetGraceTime; private int currentImpulseContextResetGraceTime;
+ public boolean affectsSpawning = true; // Paper - Affects Spawning API + public boolean affectsSpawning = true; // Paper - Affects Spawning API
+
+ // CraftBukkit start + // CraftBukkit start
+ public boolean fauxSleeping; + public boolean fauxSleeping;
+ public int oldLevel = -1; + public int oldLevel = -1;
@ -50,10 +58,9 @@
+ return (CraftHumanEntity) super.getBukkitEntity(); + return (CraftHumanEntity) super.getBukkitEntity();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
public Player(Level world, BlockPos pos, float yaw, GameProfile gameProfile) { public Player(Level world, BlockPos pos, float yaw, GameProfile gameProfile) {
super(EntityType.PLAYER, world); super(EntityType.PLAYER, world);
this.lastItemInMainHand = ItemStack.EMPTY;
@@ -261,7 +282,7 @@ @@ -261,7 +282,7 @@
this.updateIsUnderwater(); this.updateIsUnderwater();
super.tick(); super.tick();
@ -605,10 +612,12 @@
} }
@Override @Override
@@ -2005,18 +2201,29 @@ @@ -2003,20 +2199,31 @@
@Override
public ImmutableList<Pose> getDismountPoses() {
return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING);
} + }
+
+ // Paper start - PlayerReadyArrowEvent + // Paper start - PlayerReadyArrowEvent
+ protected boolean tryReadyArrow(ItemStack bow, ItemStack itemstack) { + protected boolean tryReadyArrow(ItemStack bow, ItemStack itemstack) {
+ return !(this instanceof ServerPlayer) || + return !(this instanceof ServerPlayer) ||
@ -617,9 +626,9 @@
+ org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(bow), + org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(bow),
+ org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack) + org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)
+ ).callEvent(); + ).callEvent();
+ } }
+ // Paper end - PlayerReadyArrowEvent + // Paper end - PlayerReadyArrowEvent
+
@Override @Override
public ItemStack getProjectile(ItemStack stack) { public ItemStack getProjectile(ItemStack stack) {
if (!(stack.getItem() instanceof ProjectileWeaponItem)) { if (!(stack.getItem() instanceof ProjectileWeaponItem)) {

View File

@ -125,6 +125,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
} }
} }
// Paper start
@Override
public void setHurtDirection(float hurtDirection) {
this.getHandle().hurtDir = hurtDirection;
}
// Paper end
@Override @Override
public int getSleepTicks() { public int getSleepTicks() {
return this.getHandle().sleepCounter; return this.getHandle().sleepCounter;

View File

@ -1024,4 +1024,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
this.getHandle().take(((CraftItem) item).getHandle(), quantity); this.getHandle().take(((CraftItem) item).getHandle(), quantity);
} }
// Paper end - pickup animation API // Paper end - pickup animation API
// Paper start - hurt direction API
@Override
public float getHurtDirection() {
return this.getHandle().getHurtDir();
}
@Override
public void setHurtDirection(final float hurtDirection) {
throw new UnsupportedOperationException("Cannot set the hurt direction on a non player");
}
// Paper end - hurt direction API
} }