mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-04 01:39:54 +01:00
1718f61bf8
Doesn't compile yet. CraftBukkit Changes: 90d6905b Repackage NMS 69cf961d Repackage patches Spigot Changes: 79d53c28 Repackage NMS
47 lines
2.9 KiB
Diff
47 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
Date: Thu, 28 Sep 2017 17:21:44 -0400
|
|
Subject: [PATCH] Add PlayerJumpEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
index 62fb502adf8cd7095e4826eb72ab39cf0bcc6d55..c096c461a2ffe8efdb02242f319a1612f7c2901d 100644
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
@@ -1166,7 +1166,34 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
boolean flag = d8 > 0.0D;
|
|
|
|
if (this.player.isOnGround() && !packetplayinflying.b() && flag) {
|
|
- this.player.jump();
|
|
+ // 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);
|
|
+ }
|
|
+
|
|
+ com.destroystokyo.paper.event.player.PlayerJumpEvent event = new com.destroystokyo.paper.event.player.PlayerJumpEvent(player, from, to);
|
|
+
|
|
+ if (event.callEvent()) {
|
|
+ this.player.jump();
|
|
+ } 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, new Vec3D(d7, d8, d9));
|