testserver/Spigot-Server-Patches/0414-Entity-Jump-API.patch

61 lines
3.0 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2020-02-11 04:28:39 +00:00
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sat, 8 Feb 2020 23:26:11 -0600
Subject: [PATCH] Entity Jump API
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index fede5e527a6f19243a25567e378ceebf79e118d6..0cce4dabcfc6bd2ad99d59597d4cddd98276bb8d 100644
2020-02-11 04:28:39 +00:00
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2752,8 +2752,10 @@ public abstract class EntityLiving extends Entity {
} else if (this.aP() && (!this.onGround || d7 > d8)) {
2020-06-25 23:38:24 +00:00
this.c((Tag) TagsFluid.LAVA);
} else if ((this.onGround || flag && d7 <= d8) && this.jumpTicks == 0) {
2020-02-11 04:28:39 +00:00
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper
this.jump();
this.jumpTicks = 10;
+ } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop
}
} else {
this.jumpTicks = 0;
diff --git a/src/main/java/net/minecraft/server/EntityPanda.java b/src/main/java/net/minecraft/server/EntityPanda.java
index ed8c0073f0c938c2ee8ed0dad2afda21a115b67d..01cc3d94d3fe1f82c94abdfcc92b0d3bc26f2fea 100644
2020-02-11 04:28:39 +00:00
--- a/src/main/java/net/minecraft/server/EntityPanda.java
+++ b/src/main/java/net/minecraft/server/EntityPanda.java
2020-06-25 23:38:24 +00:00
@@ -435,7 +435,9 @@ public class EntityPanda extends EntityAnimal {
2020-02-11 04:28:39 +00:00
EntityPanda entitypanda = (EntityPanda) iterator.next();
if (!entitypanda.isBaby() && entitypanda.onGround && !entitypanda.isInWater() && entitypanda.fh()) {
2020-02-11 04:28:39 +00:00
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper
entitypanda.jump();
+ } 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 607f0bca1ca454bd60aad82df81702bf15e0ff4a..a42db6ae603da8850a29944b63da5928dd2dd40f 100644
2020-02-11 04:28:39 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -757,5 +757,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
2020-02-11 04:28:39 +00:00
public boolean isHandRaised() {
return getHandle().isHandRaised();
}
+
+ @Override
+ public boolean isJumping() {
+ return getHandle().jumping;
+ }
+
+ @Override
+ public void setJumping(boolean jumping) {
+ getHandle().setJumping(jumping);
+ if (jumping && getHandle() instanceof EntityInsentient) {
+ // this is needed to actually make a mob jump
+ ((EntityInsentient) getHandle()).getControllerJump().jump();
+ }
+ }
+
// Paper end
}