mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-03 17:29:56 +01:00
59 lines
3.2 KiB
Diff
59 lines
3.2 KiB
Diff
From cd5b61c4c8aae7b976325746682fa18065e62ba6 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/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index 939061b40f..7a4b14f865 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -58,6 +58,8 @@ import org.bukkit.inventory.CraftingInventory;
|
|
import org.bukkit.inventory.EquipmentSlot;
|
|
import org.bukkit.inventory.InventoryView;
|
|
import org.bukkit.util.NumberConversions;
|
|
+import com.destroystokyo.paper.event.player.IllegalPacketEvent; // Paper
|
|
+import com.destroystokyo.paper.event.player.PlayerJumpEvent; // Paper
|
|
import co.aikar.timings.MinecraftTimings; // Paper
|
|
// CraftBukkit end
|
|
|
|
@@ -912,7 +914,34 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
d8 = d5 - this.p;
|
|
d9 = d6 - this.q;
|
|
if (this.player.onGround && !packetplayinflying.b() && d8 > 0.0D) {
|
|
- 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);
|
|
+ }
|
|
+
|
|
+ PlayerJumpEvent event = new 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));
|
|
--
|
|
2.21.0
|
|
|