Restore previous PlayerToggleSneakEvent behaviour (#12815)

Co-authored-by: Bjarne Koll <git@lynxplay.dev>
This commit is contained in:
ookiegajwa
2025-07-20 15:54:27 -06:00
committed by GitHub
parent 617e5a46a1
commit 602ea9f0e1
2 changed files with 5 additions and 5 deletions

View File

@@ -6,7 +6,7 @@ Subject: [PATCH] Optimise collision checking in player move packet handling
Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 08aba415735733f5968fd032ab7ca249cdcf6cde..ee4397711625344622c81424afd11fd6d967efba 100644
index 39a706ae5be3681c32c297c73d57b9bcf56638d4..c8dfd7fdaabc047eec05f1b78c97b551aa0fc586 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -606,6 +606,7 @@ public class ServerGamePacketListenerImpl

View File

@@ -166,15 +166,15 @@
+ // CraftBukkit end
+ // Paper start - PlayerToggleSneakEvent
+ net.minecraft.world.entity.player.Input lastInput = this.player.getLastClientInput();
+ boolean shiftKeyDown = packet.input().shift();
+ if (lastInput.shift() != packet.input().shift()) {
+ // Has sneak changed
+ org.bukkit.event.player.PlayerToggleSneakEvent event = new org.bukkit.event.player.PlayerToggleSneakEvent(this.getCraftPlayer(), packet.input().shift());
+ this.cserver.getPluginManager().callEvent(event);
+
+ // Technically the player input and the flag is desynced, but this is previous behavior.. so should be fine?
+ if (event.isCancelled()) {
+ shiftKeyDown = this.player.isShiftKeyDown();
+ if (!event.isCancelled() && this.player.hasClientLoaded()) {
+ // Only set the shift key status if the shift input has changed and the event has not been cancelled
+ this.player.setShiftKeyDown(packet.input().shift());
+ }
+ }
+ // Paper end - PlayerToggleSneakEvent
@@ -183,7 +183,7 @@
this.player.resetLastActionTime();
- this.player.setShiftKeyDown(packet.input().shift());
- }
+ this.player.setShiftKeyDown(shiftKeyDown); // Paper
+ // this.player.setShiftKeyDown(packet.input().shift()); // Paper - move up and only set if event is not cancelled.
+ }
+ // Paper start - Add option to make parrots stay
+ if (packet.input().shift() && this.player.level().paperConfig().entities.behavior.parrotsAreUnaffectedByPlayerMovement) {