From 33a2d8773916686f7c65e86b95215c9f97787824 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 28 Dec 2023 07:56:30 +1100 Subject: [PATCH] Ensure that PlayerMoveEvent is always fired where applicable Adapted and improved version of Spigot commit eb9e4c0460a8acd55ccd58bd54b0b82473876591 --- .../server/network/PlayerConnection.patch | 231 ++++++++++-------- 1 file changed, 126 insertions(+), 105 deletions(-) diff --git a/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/nms-patches/net/minecraft/server/network/PlayerConnection.patch index de9913f60..bf221cce9 100644 --- a/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/nms-patches/net/minecraft/server/network/PlayerConnection.patch @@ -103,7 +103,7 @@ + private int lastBookTick = MinecraftServer.currentTick; + private int dropCount = 0; + -+ // Get position of last block hit for BlockDamageLevel.STOPPED ++ private boolean hasMoved = false; + private double lastPosX = Double.MAX_VALUE; + private double lastPosY = Double.MAX_VALUE; + private double lastPosZ = Double.MAX_VALUE; @@ -137,12 +137,25 @@ this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling")); } -@@ -392,7 +477,34 @@ +@@ -378,6 +463,13 @@ + + if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { + WorldServer worldserver = this.player.serverLevel(); ++ // CraftBukkit - store current player position ++ double prevX = player.getX(); ++ double prevY = player.getY(); ++ double prevZ = player.getZ(); ++ float prevYaw = player.getYRot(); ++ float prevPitch = player.getXRot(); ++ // CraftBukkit end + double d0 = entity.getX(); + double d1 = entity.getY(); + double d2 = entity.getZ(); +@@ -392,7 +484,33 @@ double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; - if (d10 - d9 > 100.0D && !this.isSingleplayerOwner()) { -+ + // CraftBukkit start - handle custom speeds and skipped ticks + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; + this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); @@ -173,7 +186,7 @@ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); this.send(new PacketPlayOutVehicleMove(entity)); return; -@@ -432,14 +544,72 @@ +@@ -432,14 +550,76 @@ } entity.absMoveTo(d3, d4, d5, f, f1); @@ -189,6 +202,14 @@ + // CraftBukkit start - fire PlayerMoveEvent + Player player = this.getCraftPlayer(); ++ if (!this.hasMoved) { ++ this.lastPosX = prevX; ++ this.lastPosY = prevY; ++ this.lastPosZ = prevZ; ++ this.lastYaw = prevYaw; ++ this.lastPitch = prevPitch; ++ this.hasMoved = true; ++ } + 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. + @@ -197,7 +218,6 @@ + to.setY(packetplayinvehiclemove.getY()); + to.setZ(packetplayinvehiclemove.getZ()); + -+ + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. + to.setYaw(packetplayinvehiclemove.getYRot()); + to.setPitch(packetplayinvehiclemove.getXRot()); @@ -213,32 +233,29 @@ + this.lastYaw = to.getYaw(); + this.lastPitch = to.getPitch(); + -+ // Skip the first time we do this -+ if (from.getX() != Double.MAX_VALUE) { -+ Location oldTo = to.clone(); -+ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); -+ this.cserver.getPluginManager().callEvent(event); ++ Location oldTo = to.clone(); ++ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); ++ this.cserver.getPluginManager().callEvent(event); + -+ // If the event is cancelled we move the player back to their old location. -+ if (event.isCancelled()) { -+ teleport(from); -+ return; -+ } ++ // If the event is cancelled we move the player back to their old location. ++ if (event.isCancelled()) { ++ teleport(from); ++ return; ++ } + -+ // If a Plugin has changed the To destination then we teleport the Player -+ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. -+ // We only do this if the Event was not cancelled. -+ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { -+ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); -+ return; -+ } ++ // If a Plugin has changed the To destination then we teleport the Player ++ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. ++ // We only do this if the Event was not cancelled. ++ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { ++ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); ++ return; ++ } + -+ // Check to see if the Players Location has some how changed during the call of the event. -+ // This can happen due to a plugin teleporting the player instead of using .setTo() -+ if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { -+ this.justTeleported = false; -+ return; -+ } ++ // Check to see if the Players Location has some how changed during the call of the event. ++ // This can happen due to a plugin teleporting the player instead of using .setTo() ++ if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { ++ this.justTeleported = false; ++ return; + } + } + // CraftBukkit end @@ -246,7 +263,7 @@ this.player.serverLevel().getChunkSource().move(this.player); this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2); this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity); -@@ -473,6 +643,7 @@ +@@ -473,6 +653,7 @@ } this.awaitingPositionFromClient = null; @@ -254,7 +271,7 @@ } } -@@ -480,7 +651,7 @@ +@@ -480,7 +661,7 @@ @Override public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.serverLevel()); @@ -263,7 +280,7 @@ RecipeBookServer recipebookserver = this.player.getRecipeBook(); Objects.requireNonNull(recipebookserver); -@@ -490,6 +661,7 @@ +@@ -490,6 +671,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel()); @@ -271,7 +288,7 @@ this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering()); } -@@ -510,6 +682,12 @@ +@@ -510,6 +692,12 @@ @Override public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel()); @@ -284,7 +301,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -519,6 +697,7 @@ +@@ -519,6 +707,7 @@ ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -292,7 +309,7 @@ this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions)); }); } -@@ -766,6 +945,13 @@ +@@ -766,6 +955,13 @@ if (container instanceof ContainerMerchant) { ContainerMerchant containermerchant = (ContainerMerchant) container; @@ -306,7 +323,7 @@ if (!containermerchant.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant); -@@ -780,6 +966,13 @@ +@@ -780,6 +976,13 @@ @Override public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { @@ -320,7 +337,7 @@ int i = packetplayinbedit.getSlot(); if (PlayerInventory.isHotbarSlot(i) || i == 40) { -@@ -788,7 +981,7 @@ +@@ -788,7 +991,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); @@ -329,7 +346,7 @@ Objects.requireNonNull(list); stream.forEach(list::add); -@@ -806,7 +999,7 @@ +@@ -806,7 +1009,7 @@ ItemStack itemstack = this.player.getInventory().getItem(i); if (itemstack.is(Items.WRITABLE_BOOK)) { @@ -338,7 +355,7 @@ } } -@@ -831,16 +1024,16 @@ +@@ -831,16 +1034,16 @@ this.updateBookPages(list, (s) -> { return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s)); @@ -359,7 +376,7 @@ return NBTTagString.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty())); }); -@@ -866,6 +1059,7 @@ +@@ -866,6 +1069,7 @@ } itemstack.addTagElement("pages", nbttaglist); @@ -367,7 +384,7 @@ } @Override -@@ -922,7 +1116,7 @@ +@@ -922,7 +1126,7 @@ } else { WorldServer worldserver = this.player.serverLevel(); @@ -376,16 +393,15 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -932,7 +1126,7 @@ +@@ -932,6 +1136,7 @@ this.awaitingTeleportTime = this.tickCount; this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } -- + this.allowedPlayerTicks = 20; // CraftBukkit + } else { this.awaitingTeleportTime = this.tickCount; - double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX())); -@@ -944,7 +1138,15 @@ +@@ -944,7 +1149,15 @@ if (this.player.isPassenger()) { this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.serverLevel().getChunkSource().move(this.player); @@ -401,7 +417,7 @@ double d3 = this.player.getX(); double d4 = this.player.getY(); double d5 = this.player.getZ(); -@@ -964,15 +1166,33 @@ +@@ -964,15 +1177,33 @@ ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -437,7 +453,7 @@ PlayerConnection.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; -@@ -994,6 +1214,7 @@ +@@ -994,6 +1225,7 @@ boolean flag1 = this.player.verticalCollisionBelow; this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8)); @@ -445,7 +461,7 @@ double d11 = d7; d6 = d0 - this.player.getX(); -@@ -1012,9 +1233,70 @@ +@@ -1012,9 +1244,75 @@ } if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) { @@ -458,6 +474,14 @@ + this.player.absMoveTo(prevX, prevY, prevZ, prevYaw, prevPitch); + + Player player = this.getCraftPlayer(); ++ if (!this.hasMoved) { ++ this.lastPosX = prevX; ++ this.lastPosY = prevY; ++ this.lastPosZ = prevZ; ++ this.lastYaw = prevYaw; ++ this.lastPitch = prevPitch; ++ this.hasMoved = true; ++ } + 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. + @@ -485,39 +509,36 @@ + this.lastYaw = to.getYaw(); + this.lastPitch = to.getPitch(); + -+ // Skip the first time we do this -+ if (from.getX() != Double.MAX_VALUE) { -+ Location oldTo = to.clone(); -+ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); -+ this.cserver.getPluginManager().callEvent(event); ++ Location oldTo = to.clone(); ++ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); ++ this.cserver.getPluginManager().callEvent(event); + -+ // If the event is cancelled we move the player back to their old location. -+ if (event.isCancelled()) { -+ teleport(from); -+ return; -+ } ++ // If the event is cancelled we move the player back to their old location. ++ if (event.isCancelled()) { ++ teleport(from); ++ return; ++ } + -+ // If a Plugin has changed the To destination then we teleport the Player -+ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. -+ // We only do this if the Event was not cancelled. -+ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { -+ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); -+ return; -+ } ++ // If a Plugin has changed the To destination then we teleport the Player ++ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. ++ // We only do this if the Event was not cancelled. ++ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { ++ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); ++ return; ++ } + -+ // Check to see if the Players Location has some how changed during the call of the event. -+ // This can happen due to a plugin teleporting the player instead of using .setTo() -+ if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { -+ this.justTeleported = false; -+ return; -+ } ++ // Check to see if the Players Location has some how changed during the call of the event. ++ // This can happen due to a plugin teleporting the player instead of using .setTo() ++ if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { ++ this.justTeleported = false; ++ return; + } + } + // CraftBukkit end this.player.absMoveTo(d0, d1, d2, f, f1); this.clientIsFloating = d11 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player); this.player.serverLevel().getChunkSource().move(this.player); -@@ -1055,11 +1337,68 @@ +@@ -1055,11 +1353,68 @@ return true; } @@ -587,7 +608,7 @@ double d3 = set.contains(RelativeMovement.X) ? this.player.getX() : 0.0D; double d4 = set.contains(RelativeMovement.Y) ? this.player.getY() : 0.0D; double d5 = set.contains(RelativeMovement.Z) ? this.player.getZ() : 0.0D; -@@ -1071,6 +1410,14 @@ +@@ -1071,6 +1426,14 @@ this.awaitingTeleport = 0; } @@ -602,7 +623,7 @@ this.awaitingTeleportTime = this.tickCount; this.player.absMoveTo(d0, d1, d2, f, f1); this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport)); -@@ -1079,6 +1426,7 @@ +@@ -1079,6 +1442,7 @@ @Override public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel()); @@ -610,7 +631,7 @@ BlockPosition blockposition = packetplayinblockdig.getPos(); this.player.resetLastActionTime(); -@@ -1089,14 +1437,46 @@ +@@ -1089,14 +1453,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); @@ -659,7 +680,7 @@ this.player.drop(false); } -@@ -1134,6 +1514,7 @@ +@@ -1134,6 +1530,7 @@ @Override public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel()); @@ -667,7 +688,7 @@ this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence()); WorldServer worldserver = this.player.serverLevel(); EnumHand enumhand = packetplayinuseitem.getHand(); -@@ -1157,6 +1538,7 @@ +@@ -1157,6 +1554,7 @@ if (blockposition.getY() < i) { if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) { @@ -675,7 +696,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { -@@ -1185,6 +1567,7 @@ +@@ -1185,6 +1583,7 @@ @Override public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel()); @@ -683,7 +704,7 @@ this.ackBlockChangesUpTo(packetplayinblockplace.getSequence()); WorldServer worldserver = this.player.serverLevel(); EnumHand enumhand = packetplayinblockplace.getHand(); -@@ -1192,6 +1575,49 @@ +@@ -1192,6 +1591,49 @@ this.player.resetLastActionTime(); if (!itemstack.isEmpty() && itemstack.isItemEnabled(worldserver.enabledFeatures())) { @@ -733,7 +754,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult.shouldSwing()) { -@@ -1212,7 +1638,7 @@ +@@ -1212,7 +1654,7 @@ Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { @@ -742,7 +763,7 @@ return; } } -@@ -1235,6 +1661,13 @@ +@@ -1235,6 +1677,13 @@ @Override public void onDisconnect(IChatBaseComponent ichatbasecomponent) { @@ -756,7 +777,7 @@ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), ichatbasecomponent.getString()); this.removePlayerFromWorld(); super.onDisconnect(ichatbasecomponent); -@@ -1242,10 +1675,18 @@ +@@ -1242,10 +1691,18 @@ private void removePlayerFromWorld() { this.chatMessageChain.close(); @@ -776,7 +797,7 @@ this.player.getTextFilter().leave(); } -@@ -1260,7 +1701,16 @@ +@@ -1260,7 +1717,16 @@ @Override public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel()); @@ -793,7 +814,7 @@ if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { this.player.stopUsingItem(); } -@@ -1269,18 +1719,25 @@ +@@ -1269,18 +1735,25 @@ this.player.resetLastActionTime(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); @@ -820,7 +841,7 @@ PlayerChatMessage playerchatmessage; try { -@@ -1290,7 +1747,7 @@ +@@ -1290,7 +1763,7 @@ return; } @@ -829,7 +850,7 @@ IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent()); this.chatMessageChain.append(completablefuture, (filteredtext) -> { -@@ -1298,7 +1755,7 @@ +@@ -1298,7 +1771,7 @@ this.broadcastChatMessage(playerchatmessage1); }); @@ -838,7 +859,7 @@ } } -@@ -1313,6 +1770,12 @@ +@@ -1313,6 +1786,12 @@ if (optional.isPresent()) { this.server.submit(() -> { @@ -851,7 +872,7 @@ this.performChatCommand(serverboundchatcommandpacket, (LastSeenMessages) optional.get()); this.detectRateSpam(); }); -@@ -1322,12 +1785,25 @@ +@@ -1322,12 +1801,25 @@ } private void performChatCommand(ServerboundChatCommandPacket serverboundchatcommandpacket, LastSeenMessages lastseenmessages) { @@ -879,7 +900,7 @@ } catch (SignedMessageChain.a signedmessagechain_a) { this.handleMessageDecodeFailure(signedmessagechain_a); return; -@@ -1335,10 +1811,10 @@ +@@ -1335,10 +1827,10 @@ CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map); @@ -892,7 +913,7 @@ } private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) { -@@ -1375,7 +1851,7 @@ +@@ -1375,7 +1867,7 @@ private Optional tryHandleChat(LastSeenMessages.b lastseenmessages_b) { Optional optional = this.unpackAndApplyLastSeen(lastseenmessages_b); @@ -901,7 +922,7 @@ this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false)); return Optional.empty(); } else { -@@ -1409,6 +1885,116 @@ +@@ -1409,6 +1901,116 @@ return false; } @@ -1018,7 +1039,7 @@ private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a { SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages); -@@ -1416,13 +2002,33 @@ +@@ -1416,13 +2018,33 @@ } private void broadcastChatMessage(PlayerChatMessage playerchatmessage) { @@ -1055,7 +1076,7 @@ this.disconnect(IChatBaseComponent.translatable("disconnect.spam")); } -@@ -1444,13 +2050,62 @@ +@@ -1444,13 +2066,62 @@ @Override public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel()); @@ -1118,7 +1139,7 @@ this.player.resetLastActionTime(); Entity entity; IJumpable ijumpable; -@@ -1532,6 +2187,12 @@ +@@ -1532,6 +2203,12 @@ } public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) { @@ -1131,7 +1152,7 @@ this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a.toNetwork(this.player.level().registryAccess()))); this.addPendingMessage(playerchatmessage); } -@@ -1558,6 +2219,7 @@ +@@ -1558,6 +2235,7 @@ @Override public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel()); @@ -1139,7 +1160,7 @@ final WorldServer worldserver = this.player.serverLevel(); final Entity entity = packetplayinuseentity.getTarget(worldserver); -@@ -1572,13 +2234,51 @@ +@@ -1572,13 +2250,51 @@ if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { @@ -1192,7 +1213,7 @@ if (enuminteractionresult.consumesAction()) { CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack1, entity); if (enuminteractionresult.shouldSwing()) { -@@ -1591,23 +2291,29 @@ +@@ -1591,23 +2307,29 @@ @Override public void onInteraction(EnumHand enumhand) { @@ -1225,7 +1246,7 @@ } } else { PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked")); -@@ -1630,14 +2336,14 @@ +@@ -1630,14 +2352,14 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1242,7 +1263,7 @@ if (this.server.isHardcore()) { this.player.setGameMode(EnumGamemode.SPECTATOR); ((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server); -@@ -1653,15 +2359,21 @@ +@@ -1653,15 +2375,21 @@ @Override public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel()); @@ -1266,7 +1287,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1674,7 +2386,284 @@ +@@ -1674,7 +2402,284 @@ boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -1552,7 +1573,7 @@ ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1704,9 +2693,18 @@ +@@ -1704,9 +2709,18 @@ if (!this.player.containerMenu.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); } else { @@ -1573,7 +1594,7 @@ } } } -@@ -1714,6 +2712,7 @@ +@@ -1714,6 +2728,7 @@ @Override public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel()); @@ -1581,7 +1602,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1756,6 +2755,43 @@ +@@ -1756,6 +2771,43 @@ boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1625,7 +1646,7 @@ if (flag1 && flag2) { this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).setByPlayer(itemstack); -@@ -1778,6 +2814,7 @@ +@@ -1778,6 +2830,7 @@ } private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List list) { @@ -1633,7 +1654,7 @@ this.player.resetLastActionTime(); WorldServer worldserver = this.player.serverLevel(); BlockPosition blockposition = packetplayinupdatesign.getPos(); -@@ -1799,7 +2836,17 @@ +@@ -1799,7 +2852,17 @@ @Override public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel()); @@ -1652,7 +1673,7 @@ } @Override -@@ -1858,7 +2905,7 @@ +@@ -1858,7 +2921,7 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else {