mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
e035fd7034
Upstream has released updates that appear 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: cc9aa21a SPIGOT-6399, SPIGOT-7344: Clarify collidable behavior for player entities f23325b6 Add API for per-world simulation distances 26e1774e Add API for per-world view distances 0b541e60 Add PlayerLoginEvent#getRealAddress 5f027d2d PR-949: Add Vector#fromJOML() overloads for read-only vector types CraftBukkit Changes: bcf56171a PR-1321: Clean up some stuff which got missed during previous PRs 7f833a2d1 SPIGOT-7462: Players no longer drop XP after dying near a Sculk Catalyst 752aac669 Implement APIs for per world view and simulation distances 57d7ef433 Preserve empty enchantment tags for glow effect 465ec3fb4 Remove connected check on setScoreboard f90ce621e Use one PermissibleBase for all command blocks 5876cca44 SPIGOT-7550: Fix creation of Arrow instances f03fc3aa3 SPIGOT-7549: ServerTickManager#setTickRate incorrect Precondition 9d7f49b01 SPIGOT-7548: Fix wrong spawn location for experience orb and dropped item Spigot Changes: ed9ba9a4 Drop no longer required patch ignoring -o option 86b5dd6a SPIGOT-7546: Fix hardcoded check for outdated client message aa7cde7a Remove obsolete APIs for per world view and simulation distances 6dff577e Remove obsolete patch preserving empty `ench` tags a3bf95b8 Remove obsolete PlayerLoginEvent#getRealAddress 1b02f5d6 Remove obsolete connected check on setScoreboard patch acf717eb Remove obsolete command block PermissibleBase patch 053fa2a9 Remove redundant patch dealing with null tile entities
109 lines
8.9 KiB
Diff
109 lines
8.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Moulberry <james.jenour@protonmail.com>
|
|
Date: Wed, 26 Jul 2023 20:13:31 +0800
|
|
Subject: [PATCH] Implement PlayerFailMoveEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index ccd6b734534a9f2b4205ee857ac650b26be74d5e..e58a86e70767707e144f45e9160f1b266ae07145 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1317,8 +1317,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
double d0 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX(this.player.getX())); final double toX = d0; // Paper - OBFHELPER
|
|
double d1 = ServerGamePacketListenerImpl.clampVertical(packet.getY(this.player.getY())); final double toY = d1;
|
|
double d2 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ(this.player.getZ())); final double toZ = d2; // Paper - OBFHELPER
|
|
- float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot()));
|
|
- float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot()));
|
|
+ float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot())); final float toYaw = f; // Paper - OBFHELPER
|
|
+ float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot())); final float toPitch = f1; // Paper - OBFHELPER
|
|
|
|
if (this.player.isPassenger()) {
|
|
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
|
@@ -1385,8 +1385,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
}
|
|
// Paper start - Prevent moving into unloaded chunks
|
|
if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) {
|
|
- this.internalTeleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot(), Collections.emptySet());
|
|
- return;
|
|
+ // Paper start - Add fail move event
|
|
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_INTO_UNLOADED_CHUNK,
|
|
+ toX, toY, toZ, toYaw, toPitch, false);
|
|
+ if (!event.isAllowed()) {
|
|
+ this.internalTeleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot(), Collections.emptySet());
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
// Paper end
|
|
|
|
@@ -1395,9 +1401,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
|
|
if (d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
|
|
// CraftBukkit end
|
|
- ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
|
|
- this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
|
- return;
|
|
+ // Paper start - Add fail move event
|
|
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY,
|
|
+ toX, toY, toZ, toYaw, toPitch, true);
|
|
+ if (!event.isAllowed()) {
|
|
+ if (event.getLogWarning())
|
|
+ ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
|
|
+ this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
}
|
|
}
|
|
@@ -1463,8 +1476,15 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
boolean flag2 = false;
|
|
|
|
if (!this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot
|
|
+ // Paper start - Add fail move event
|
|
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_WRONGLY,
|
|
+ toX, toY, toZ, toYaw, toPitch, true);
|
|
+ if (!event.isAllowed()) {
|
|
flag2 = true; // Paper - diff on change, this should be moved wrongly
|
|
+ if (event.getLogWarning())
|
|
ServerGamePacketListenerImpl.LOGGER.warn("{} moved wrongly!", this.player.getName().getString());
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
// Paper start - optimise out extra getCubes
|
|
@@ -1477,6 +1497,15 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
if (didCollide || !axisalignedbb.equals(newBox)) {
|
|
// note: only call after setLocation, or else getBoundingBox is wrong
|
|
teleportBack = this.hasNewCollision(worldserver, this.player, axisalignedbb, newBox);
|
|
+ // Paper start - Add fail move event
|
|
+ if (teleportBack) {
|
|
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK,
|
|
+ toX, toY, toZ, toYaw, toPitch, false);
|
|
+ if (event.isAllowed()) {
|
|
+ teleportBack = false;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
} // else: no collision at all detected, why do we care?
|
|
}
|
|
if (!this.player.noPhysics && !this.player.isSleeping() && teleportBack) { // Paper end - optimise out extra getCubes
|
|
@@ -1565,6 +1594,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
}
|
|
}
|
|
|
|
+ // Paper start - Add fail move event
|
|
+ private io.papermc.paper.event.player.PlayerFailMoveEvent fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason failReason,
|
|
+ double toX, double toY, double toZ, float toYaw, float toPitch, boolean logWarning) {
|
|
+ Player player = this.getCraftPlayer();
|
|
+ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch);
|
|
+ Location to = new Location(player.getWorld(), toX, toY, toZ, toYaw, toPitch);
|
|
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = new io.papermc.paper.event.player.PlayerFailMoveEvent(player, failReason,
|
|
+ false, logWarning, from, to);
|
|
+ event.callEvent();
|
|
+ return event;
|
|
+ }
|
|
+ // Paper end
|
|
// Paper start - optimise out extra getCubes
|
|
private boolean hasNewCollision(final ServerLevel world, final Entity entity, final AABB oldBox, final AABB newBox) {
|
|
final List<AABB> collisionsBB = new java.util.ArrayList<>();
|