From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sat, 8 Feb 2020 23:26:11 -0600 Subject: [PATCH] Entity Jump API diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index a1c8558db314ea34ad483f7f6f70c1833b57b669..55d8856e5fdeee4d38e49f5d4a252cf61212e5cb 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3262,8 +3262,10 @@ public abstract class LivingEntity extends Entity implements Attackable { } else if (this.isInLava() && (!this.onGround() || d7 > d8)) { this.jumpInLiquid(FluidTags.LAVA); } else if ((this.onGround() || flag && d7 <= d8) && this.noJumpDelay == 0) { + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper this.jumpFromGround(); this.noJumpDelay = 10; + } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop } } else { this.noJumpDelay = 0; diff --git a/src/main/java/net/minecraft/world/entity/animal/Panda.java b/src/main/java/net/minecraft/world/entity/animal/Panda.java index f8a59afbe0f95a06e9ae6972fc664d0a0860c951..7f4ff9658b0eca2034333810fd2b199a3d186e72 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Panda.java +++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java @@ -521,7 +521,9 @@ public class Panda extends Animal { Panda entitypanda = (Panda) iterator.next(); if (!entitypanda.isBaby() && entitypanda.onGround() && !entitypanda.isInWater() && entitypanda.canPerformAction()) { + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper entitypanda.jumpFromGround(); + } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop } } diff --git a/src/main/java/net/minecraft/world/entity/monster/Ravager.java b/src/main/java/net/minecraft/world/entity/monster/Ravager.java index 243397de3b0a843ec95c6b721d7fc654bfc78448..aad1fb5cf231b400dc8c192871aa4429536d53ee 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java +++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java @@ -176,7 +176,9 @@ public class Ravager extends Raider { } if (!flag && this.onGround()) { + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper this.jumpFromGround(); + } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index b19185c16f8fecbefef697017e8dcfd249306fe3..c5784574f584a5588020b16776f01faf6902cbe8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -887,5 +887,19 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public org.bukkit.inventory.EquipmentSlot getHandRaised() { return getHandle().getUsedItemHand() == net.minecraft.world.InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND; } + + @Override + public boolean isJumping() { + return getHandle().jumping; + } + + @Override + public void setJumping(boolean jumping) { + getHandle().setJumping(jumping); + if (jumping && getHandle() instanceof Mob) { + // this is needed to actually make a mob jump + ((Mob) getHandle()).getJumpControl().jump(); + } + } // Paper end }