mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
74 lines
4.0 KiB
Diff
74 lines
4.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/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index 80b60e33e9e39bc62f65bfddf121254d333aecae..1b8f69d2bc595b655de4a2cdffe77c81433648e3 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3281,8 +3281,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
|
|
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
|
|
index 3d947293d33407e5d24f8fba738ab872e1d890b6..27e1ed14f2ae4f7922c7c3bc1ac21156bafcb0ba 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
|
@@ -527,7 +527,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
|
|
entitypanda.jumpFromGround();
|
|
+ } else { this.setJumping(false); } // Paper - 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 344e933311f5cdccb66069d486b111a003639dfe..add3cd866452df727107e94fb2039bddebe909be 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
|
@@ -167,7 +167,9 @@ public class Ravager extends Raider {
|
|
}
|
|
|
|
if (!flag && this.onGround()) {
|
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper
|
|
this.jumpFromGround();
|
|
+ } 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 a3842078a394241a3a9b4c398d13fcdbcb5dbe10..9ba85d099d0e6893dc3489ce0753119348e937b3 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -906,5 +906,19 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|
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
|
|
}
|