2018-01-16 04:13:17 +01:00
|
|
|
From 309f155e98051c570eac0d5115ed058577b6341d Mon Sep 17 00:00:00 2001
|
2017-09-28 23:38:17 +02:00
|
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
|
|
Date: Thu, 28 Sep 2017 17:21:44 -0400
|
|
|
|
Subject: [PATCH] Add PlayerJumpEvent
|
|
|
|
|
|
|
|
|
2017-09-29 20:58:24 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
2018-01-16 04:13:17 +01:00
|
|
|
index deb0f4a9c..579996d1e 100644
|
2017-09-29 20:58:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
|
|
@@ -1399,6 +1399,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
|
|
|
|
|
|
public void b(List<IRecipe> list) {}
|
|
|
|
|
|
|
|
+ public void jump() { this.cu(); } // Paper - OBFHELPER
|
|
|
|
public void cu() {
|
|
|
|
super.cu();
|
|
|
|
this.b(StatisticList.w);
|
2017-09-29 00:43:36 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2018-01-16 04:13:17 +01:00
|
|
|
index 9c8828ebd..cc58a4a93 100644
|
2017-09-29 00:43:36 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2017-09-29 00:54:38 +02:00
|
|
|
@@ -57,6 +57,7 @@ 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
|
|
|
|
|
|
|
|
@@ -584,7 +585,34 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
2017-09-28 23:38:17 +02:00
|
|
|
d8 = d5 - this.p;
|
|
|
|
d9 = d6 - this.q;
|
|
|
|
if (this.player.onGround && !packetplayinflying.a() && d8 > 0.0D) {
|
|
|
|
- this.player.cu();
|
|
|
|
+ // 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 20:58:24 +02:00
|
|
|
+ this.player.jump();
|
2017-09-28 23:38:17 +02: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);
|
|
|
|
--
|
2018-01-16 04:13:17 +01:00
|
|
|
2.15.1
|
2017-09-28 23:38:17 +02:00
|
|
|
|