geforkt von Mirrors/Paper
60 Zeilen
3.2 KiB
Diff
60 Zeilen
3.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
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||
|
index b84dab1043c56e2deb58aec8639226f98db165d1..43fbe7d220f61802ae0cb0620ad078c5df7b69bc 100644
|
||
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||
|
@@ -2873,8 +2873,10 @@ public abstract class LivingEntity extends Entity {
|
||
|
} else if (this.isInLava() && (!this.onGround || d7 > d8)) {
|
||
|
this.jumpInLiquid((Tag) FluidTags.LAVA);
|
||
|
} else if ((this.onGround || flag && d7 <= d8) && 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 1621d8748e96c6e1abb33b699a1273bb698f67d2..423bdbe25b6f2261cb5092378b0564a82faeecb4 100644
|
||
|
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||
|
@@ -489,7 +489,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/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||
|
index a01bd035846df0e2e28dc55e2ef2f5f35b83f905..5dac3bf5a117bfbf57798238f0614558deafcd1b 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||
|
@@ -792,5 +792,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
|
||
|
}
|