2019-04-22 21:36:14 +00:00
|
|
|
From 089a524589f6065314534ab6607df461a97426e0 Mon Sep 17 00:00:00 2001
|
2017-09-28 21:38:17 +00:00
|
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
|
|
Date: Thu, 28 Sep 2017 17:21:44 -0400
|
|
|
|
Subject: [PATCH] Add PlayerJumpEvent
|
|
|
|
|
|
|
|
|
2017-09-29 18:58:24 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
2019-04-22 21:36:14 +00:00
|
|
|
index 298012f37c..bfae875ebb 100644
|
2017-09-29 18:58:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
2019-03-20 00:28:15 +00:00
|
|
|
@@ -1483,6 +1483,7 @@ public abstract class EntityHuman extends EntityLiving {
|
2018-07-18 00:08:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-09-29 18:58:24 +00:00
|
|
|
|
2018-07-22 05:27:46 +00:00
|
|
|
+ public void jump() { this.cH(); } // Paper - OBFHELPER
|
|
|
|
public void cH() {
|
|
|
|
super.cH();
|
2018-07-18 00:08:13 +00:00
|
|
|
this.a(StatisticList.JUMP);
|
2017-09-28 22:43:36 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2019-04-22 21:36:14 +00:00
|
|
|
index ac64fcfb31..5fa3268b59 100644
|
2017-09-28 22:43:36 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2019-01-01 03:15:55 +00:00
|
|
|
@@ -58,6 +58,8 @@ import org.bukkit.inventory.CraftingInventory;
|
2018-07-18 00:08:13 +00:00
|
|
|
import org.bukkit.inventory.EquipmentSlot;
|
2017-09-28 22:54:38 +00:00
|
|
|
import org.bukkit.inventory.InventoryView;
|
|
|
|
import org.bukkit.util.NumberConversions;
|
2018-07-18 00:08:13 +00:00
|
|
|
+import com.destroystokyo.paper.event.player.IllegalPacketEvent; // Paper
|
2017-09-28 22:54:38 +00:00
|
|
|
+import com.destroystokyo.paper.event.player.PlayerJumpEvent; // Paper
|
|
|
|
import co.aikar.timings.MinecraftTimings; // Paper
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2019-01-01 03:15:55 +00:00
|
|
|
@@ -872,7 +874,34 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
2017-09-28 21:38:17 +00:00
|
|
|
d8 = d5 - this.p;
|
|
|
|
d9 = d6 - this.q;
|
2018-07-18 00:08:13 +00:00
|
|
|
if (this.player.onGround && !packetplayinflying.b() && d8 > 0.0D) {
|
2018-07-22 05:27:46 +00:00
|
|
|
- this.player.cH();
|
2017-09-28 21:38:17 +00:00
|
|
|
+ // Paper start - Add player jump event
|
|
|
|
+ Player player = this.getPlayer();
|
|
|
|
+ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
|
|
|
|
+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
|
|
|
|
+
|
|
|
|
+ // If the packet contains movement information then we update the To location with the correct XYZ.
|
|
|
|
+ if (packetplayinflying.hasPos) {
|
|
|
|
+ to.setX(packetplayinflying.x);
|
|
|
|
+ to.setY(packetplayinflying.y);
|
|
|
|
+ to.setZ(packetplayinflying.z);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch.
|
|
|
|
+ if (packetplayinflying.hasLook) {
|
|
|
|
+ to.setYaw(packetplayinflying.yaw);
|
|
|
|
+ to.setPitch(packetplayinflying.pitch);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PlayerJumpEvent event = new PlayerJumpEvent(player, from, to);
|
|
|
|
+
|
|
|
|
+ if (event.callEvent()) {
|
2017-09-29 18:58:24 +00:00
|
|
|
+ this.player.jump();
|
2017-09-28 21:38:17 +00:00
|
|
|
+ } else {
|
|
|
|
+ from = event.getFrom();
|
|
|
|
+ this.internalTeleport(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch(), Collections.emptySet());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
this.player.move(EnumMoveType.PLAYER, d7, d8, d9);
|
|
|
|
--
|
2019-03-20 00:28:15 +00:00
|
|
|
2.21.0
|
2017-09-28 21:38:17 +00:00
|
|
|
|