2021-06-11 14:02:28 +02:00
|
|
|
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
|
|
|
|
|
2024-01-23 18:01:39 +01:00
|
|
|
== AT ==
|
|
|
|
public net.minecraft.world.entity.LivingEntity jumping
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2024-04-28 03:00:01 +02:00
|
|
|
index d88b13be2d72cc40c5ca846a55eece1d9ca5fd37..c2934dc1d87bd8211714ab8af8ddfc32695b7953 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2024-04-28 03:00:01 +02:00
|
|
|
@@ -3401,8 +3401,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2023-09-22 04:31:59 +02:00
|
|
|
} else if (this.isInLava() && (!this.onGround() || d3 > d4)) {
|
2021-11-24 10:01:27 +01:00
|
|
|
this.jumpInLiquid(FluidTags.LAVA);
|
2023-09-22 04:31:59 +02:00
|
|
|
} else if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) {
|
2024-01-21 12:53:04 +01:00
|
|
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
|
2021-06-11 14:02:28 +02:00
|
|
|
this.jumpFromGround();
|
|
|
|
this.noJumpDelay = 10;
|
2024-01-21 12:53:04 +01:00
|
|
|
+ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
} 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
|
2024-04-24 08:05:14 +02:00
|
|
|
index 4a1b25bb8a3d342400cb657781e9eab68decd479..fb4c7220c4edad54813036d62db7e3eefeda92a3 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
2024-04-24 08:05:14 +02:00
|
|
|
@@ -536,7 +536,9 @@ public class Panda extends Animal {
|
2021-06-11 14:02:28 +02:00
|
|
|
Panda entitypanda = (Panda) iterator.next();
|
|
|
|
|
2023-06-08 00:12:41 +02:00
|
|
|
if (!entitypanda.isBaby() && entitypanda.onGround() && !entitypanda.isInWater() && entitypanda.canPerformAction()) {
|
2024-01-21 12:53:04 +01:00
|
|
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
|
2021-06-11 14:02:28 +02:00
|
|
|
entitypanda.jumpFromGround();
|
2024-01-21 12:53:04 +01:00
|
|
|
+ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-20 18:17:42 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Ravager.java b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
2024-04-24 08:05:14 +02:00
|
|
|
index 1264fb03d2dcab088fc4a7c2788c9f9df53cba5d..cec801ba14bed8b043b2375f1bf9e7811a63e995 100644
|
2022-07-20 18:17:42 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
2024-04-24 08:05:14 +02:00
|
|
|
@@ -159,7 +159,9 @@ public class Ravager extends Raider {
|
2022-07-20 18:17:42 +02:00
|
|
|
}
|
|
|
|
|
2023-06-08 00:12:41 +02:00
|
|
|
if (!flag && this.onGround()) {
|
2024-01-21 12:53:04 +01:00
|
|
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
|
2022-07-20 18:17:42 +02:00
|
|
|
this.jumpFromGround();
|
2024-01-21 12:53:04 +01:00
|
|
|
+ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
|
2022-07-20 18:17:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
2024-04-24 08:05:14 +02:00
|
|
|
index b2172a8c70ab77ba7c98b6b2b27595765d7eba11..539280a0265a4746ebc9ede6667df3699dfb8125 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
2024-04-24 08:05:14 +02:00
|
|
|
@@ -961,4 +961,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
2024-04-06 21:53:39 +02:00
|
|
|
return org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(this.getHandle().getUsedItemHand());
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2024-04-06 21:53:39 +02:00
|
|
|
// Paper end - active item API
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
2024-04-06 21:53:39 +02:00
|
|
|
+ // Paper start - entity jump API
|
2021-06-11 14:02:28 +02:00
|
|
|
+ @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();
|
|
|
|
+ }
|
|
|
|
+ }
|
2024-04-06 21:53:39 +02:00
|
|
|
+ // Paper end - entity jump API
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|