Paper/Spigot-Server-Patches/0408-Entity-Jump-API.patch
Jake Potrebic a98d389d1f
Updated Upstream (CraftBukkit/Spigot) (#5119)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
c3e684ef SPIGOT-3789: Can't Remove Entity Equipment in Same Tick Spawned without using Consumer

Spigot Changes:
89d6047d Rebuild patches
2021-01-27 04:22:32 +00:00

61 Zeilen
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
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 eaac2827d49067f92e22b39fceef8d149fb5001b..4df0fd9883027440b7148a47c855e30730ab8590 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2775,8 +2775,10 @@ public abstract class EntityLiving extends Entity {
} else if (this.aQ() && (!this.onGround || d7 > d8)) {
this.c((Tag) TagsFluid.LAVA);
} else if ((this.onGround || flag && d7 <= d8) && this.jumpTicks == 0) {
+ 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 7de157388922c4d3ff52866d5c0ac20189a9ccf8..b36cc95168c6e6fbf668ebe15c1fa10b54e570d3 100644
--- a/src/main/java/net/minecraft/server/EntityPanda.java
+++ b/src/main/java/net/minecraft/server/EntityPanda.java
@@ -435,7 +435,9 @@ public class EntityPanda extends EntityAnimal {
EntityPanda entitypanda = (EntityPanda) iterator.next();
if (!entitypanda.isBaby() && entitypanda.onGround && !entitypanda.isInWater() && entitypanda.fh()) {
+ 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 2fccc6a8a3dcf96e8ec714c2f7fa2f62af60cb76..b8e29172a17ad7e30134ff8c63815c71ff1d19d1 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -789,5 +789,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
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
}