2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-02-11 05:28:39 +01: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
|
2020-06-26 01:38:24 +02:00
|
|
|
index 27b92664cee1c685b5b6b9b385150bb5fdb9fa7a..e4c7f4c100e1b8d4470da954a3b72f9e0ec5b494 100644
|
2020-02-11 05:28:39 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2020-06-26 01:38:24 +02:00
|
|
|
@@ -2748,8 +2748,10 @@ public abstract class EntityLiving extends Entity {
|
|
|
|
} else if (this.aN() && (!this.onGround || d7 > d8)) {
|
|
|
|
this.c((Tag) TagsFluid.LAVA);
|
|
|
|
} else if ((this.onGround || flag && d7 <= d8) && this.jumpTicks == 0) {
|
2020-02-11 05:28:39 +01: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
|
2020-06-26 01:38:24 +02:00
|
|
|
index 50fe69143a6b91f957414ff556a0e60d220ab04f..42df0d74ee24ef9ac15ee19cfd298c5721df0d7d 100644
|
2020-02-11 05:28:39 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityPanda.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityPanda.java
|
2020-06-26 01:38:24 +02:00
|
|
|
@@ -435,7 +435,9 @@ public class EntityPanda extends EntityAnimal {
|
2020-02-11 05:28:39 +01:00
|
|
|
EntityPanda entitypanda = (EntityPanda) iterator.next();
|
|
|
|
|
2020-06-26 01:38:24 +02:00
|
|
|
if (!entitypanda.isBaby() && entitypanda.onGround && !entitypanda.isInWater() && entitypanda.fi()) {
|
2020-02-11 05:28:39 +01: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
|
2020-06-26 01:38:24 +02:00
|
|
|
index 39b8ab223bc708e5ee3dc967e489fdc76d944416..b3ec32b20751fbea2f6df14fc5e9f84682493bfd 100644
|
2020-02-11 05:28:39 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
2020-06-26 01:38:24 +02:00
|
|
|
@@ -736,5 +736,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
2020-02-11 05:28:39 +01: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
|
|
|
|
}
|