2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 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
|
|
|
|
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-06-11 06:29:15 +00:00
|
|
|
index 8c39dc4f05becea92f3ec86c4103be4e34f2b835..156acc9e1f3bb9d7663009530220a3958a1ff94d 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-04-18 09:02:48 +00:00
|
|
|
@@ -1168,7 +1168,34 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2020-06-25 13:11:48 +00:00
|
|
|
boolean flag = d8 > 0.0D;
|
2019-12-11 23:43:22 +00:00
|
|
|
|
2020-06-25 13:11:48 +00:00
|
|
|
if (this.player.isOnGround() && !packetplayinflying.b() && flag) {
|
2019-04-27 23:23:53 +00:00
|
|
|
- this.player.jump();
|
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);
|
|
|
|
+ }
|
|
|
|
+
|
2020-12-08 07:51:55 +00:00
|
|
|
+ com.destroystokyo.paper.event.player.PlayerJumpEvent event = new com.destroystokyo.paper.event.player.PlayerJumpEvent(player, from, to);
|
2017-09-28 21:38:17 +00:00
|
|
|
+
|
|
|
|
+ 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
|
|
|
|
}
|
|
|
|
|
2019-04-27 23:23:53 +00:00
|
|
|
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
|