geforkt von Mirrors/Paper
76 Zeilen
4.2 KiB
Diff
76 Zeilen
4.2 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
|
|
|
|
== 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 e06aa636bf4e18ca2810e0626f427839cd2bce88..bc51c6d8b39907d89a4f65cd7a8266df1fceab8c 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3283,8 +3283,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 3d947293d33407e5d24f8fba738ab872e1d890b6..48df7de02e0765bfe62ae1b8a4c0029743430221 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 - 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 aba20a4352d8983b01ab5d329187588f68d3e405..aac60e85cd6dba7d87f4a1663c2c62952521d112 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 - 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 dbfeeacbb503aad5897c92c902d16fdbea7b793f..d5135ac97b2d4af7391a58799497c649cfcf8041 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -922,5 +922,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
|
|
}
|