Paper/Spigot-Server-Patches/0173-Add-PlayerJumpEvent.patch
Aikar 36f34f01c0
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots
3abebc9f #492: Let Tameable extend Animals rather than Entity
941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent
4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME

CraftBukkit Changes:
933e9094 #664: Add methods to get/set ItemStacks in EquipmentSlots
18722312 #662: Expose ItemStack and hand used in PlayerShearEntityEvent
2020-05-06 06:05:22 -04:00

56 lines
3.2 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/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 046ef418f8e16a8d50846f140d7147a3178ebca2..b0651dcfbfccab63108ece34304700db9af407b6 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
@@ -925,7 +927,34 @@ public class PlayerConnection implements PacketListenerPlayIn {
}
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));