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
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2023-07-04 10:22:56 +02:00
|
|
|
index 2a81303109bb3fd34c9cf5ff9cc9d2cb5c331eb8..e5bc7ad4f9c3b02dd8a572750ed833b200fbecd4 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
|
2023-07-04 10:22:56 +02:00
|
|
|
@@ -3255,8 +3255,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2023-06-08 00:12:41 +02:00
|
|
|
} else if (this.isInLava() && (!this.onGround() || d7 > d8)) {
|
2021-11-24 10:01:27 +01:00
|
|
|
this.jumpInLiquid(FluidTags.LAVA);
|
2023-06-08 00:12:41 +02:00
|
|
|
} else if ((this.onGround() || flag && d7 <= d8) && this.noJumpDelay == 0) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper
|
|
|
|
this.jumpFromGround();
|
|
|
|
this.noJumpDelay = 10;
|
|
|
|
+ } else { this.setJumping(false); } // Paper - 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
|
2023-07-04 10:22:56 +02:00
|
|
|
index 278a9842455a222ed9102fc7a95585755dfd5d7b..a190826d87ca5e05c408ef488986a29280b1b3d2 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
|
2023-07-04 10:22:56 +02:00
|
|
|
@@ -524,7 +524,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()) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper
|
|
|
|
entitypanda.jumpFromGround();
|
|
|
|
+ } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2023-07-04 10:22:56 +02:00
|
|
|
index 02f962eed1d85e8c532264f63666d26401d6a8f2..c245acdbaa84cc795e341ed042a0d8d90383f070 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
|
2023-07-04 10:22:56 +02:00
|
|
|
@@ -184,7 +184,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()) {
|
2022-07-20 18:17:42 +02:00
|
|
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper
|
|
|
|
this.jumpFromGround();
|
|
|
|
+ } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2023-08-14 01:32:51 +02:00
|
|
|
index 2913ad431b09a75106115257729960f8ba1637f4..f0457dd3d179dab3e164279f30690058549e530a 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
|
2023-08-14 01:32:51 +02:00
|
|
|
@@ -906,5 +906,19 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
2021-06-11 14:02:28 +02:00
|
|
|
public org.bukkit.inventory.EquipmentSlot getHandRaised() {
|
|
|
|
return getHandle().getUsedItemHand() == net.minecraft.world.InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @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
|
|
|
|
}
|