aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0319-Entity-Jump-API.patch
blob: 9d3bf218cf88fcdea85071e3d534153d828a0b01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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

== AT ==
public net.minecraft.world.entity.LivingEntity jumping

diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 94492da51fe2a6343ab3c41d26ca2a195e14bc62..9d924c48dedf9a61f555bf7c9d658e925169ccd2 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3405,8 +3405,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
             } else if (this.isInLava() && (!this.onGround() || d3 > d4)) {
                 this.jumpInLiquid(FluidTags.LAVA);
             } else if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) {
+                if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
                 this.jumpFromGround();
                 this.noJumpDelay = 10;
+                } else { this.setJumping(false); } // Paper - Entity Jump API; 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 228cfb77e12ed5979e422dc5dbb5e8dcf363b509..8df42121aa22ec9f95a1b8627b64b0ff71e36314 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
@@ -541,7 +541,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 - Entity Jump API
                 entitypanda.jumpFromGround();
+                } else { this.setJumping(false); } // Paper - Entity Jump API; 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 4d91bc4b90a208fec789325dbcec8cc56d1a2a8b..aa4111eef22546f8aa630228c51ef5761c9b373b 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
@@ -160,7 +160,9 @@ public class Ravager extends Raider {
                 }
 
                 if (!flag && this.onGround()) {
+                    if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
                     this.jumpFromGround();
+                    } else { this.setJumping(false); } // Paper - Entity Jump API; 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 9a159f0c7489d2924dabe3fd250d844899ae5761..94f2b0fa94ebc2572c33623fa5883dd7ed56c55a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -963,4 +963,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
         return org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(this.getHandle().getUsedItemHand());
     }
     // Paper end - active item API
+
+    // Paper start - entity jump API
+    @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 - entity jump API
 }