diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 704171826e..6e89ef5ed6 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -324,7 +324,7 @@ boolean flag1 = entity.verticalCollisionBelow; if (entity instanceof LivingEntity) { -@@ -449,19 +599,72 @@ +@@ -449,20 +599,73 @@ d10 = d6 * d6 + d7 * d7 + d8 * d8; boolean flag2 = false; @@ -343,8 +343,8 @@ + this.player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit this.send(ClientboundMoveVehiclePacket.fromEntity(entity)); return; -+ } -+ + } + + // CraftBukkit start - fire PlayerMoveEvent + Player player = this.getCraftPlayer(); + if (!this.hasMoved) { @@ -393,11 +393,12 @@ + this.justTeleported = false; + return; + } - } ++ } + // CraftBukkit end - ++ this.player.serverLevel().getChunkSource().move(this.player); entity.recordMovementThroughBlocks(new Vec3(d0, d1, d2), entity.position()); + Vec3 vec3d = new Vec3(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2); @@ -489,16 +692,17 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (packet.getId() == this.awaitingTeleport) { @@ -1154,10 +1155,12 @@ if (this.player.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel worldserver = this.player.serverLevel(); -@@ -1296,6 +1926,47 @@ - this.player.absRotateTo(f, f1); - } +@@ -1294,8 +1924,49 @@ + if (f1 != this.player.getXRot() || f != this.player.getYRot()) { + this.player.absRotateTo(f, f1); ++ } ++ + // CraftBukkit start + // Raytrace to look for 'rogue armswings' + double d0 = this.player.getX(); @@ -1188,8 +1191,8 @@ + cancelled = event.useItemInHand() == Event.Result.DENY; + } + this.player.gameMode.firedInteract = false; -+ } -+ + } + + if (cancelled) { + this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 + return; @@ -1299,7 +1302,7 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { -@@ -1394,27 +2111,44 @@ +@@ -1394,27 +2111,46 @@ return; } @@ -1338,7 +1341,9 @@ private void performUnsignedChatCommand(String command) { + // CraftBukkit start + String command1 = "/" + command; ++ if (org.spigotmc.SpigotConfig.logCommands) { // Paper - Add missing SpigotConfig logCommands check + ServerGamePacketListenerImpl.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command1); ++ } + + PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command1, new LazyPlayerSet(this.server)); + this.cserver.getPluginManager().callEvent(event); @@ -1351,7 +1356,7 @@ ParseResults parseresults = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) { -@@ -1431,19 +2165,37 @@ +@@ -1431,19 +2167,39 @@ if (!optional.isEmpty()) { this.tryHandleChat(packet.command(), () -> { @@ -1372,7 +1377,9 @@ - ParseResults parseresults = this.parseCommand(packet.command()); + // CraftBukkit start + String command = "/" + packet.command(); ++ if (org.spigotmc.SpigotConfig.logCommands) { // Paper - Add missing SpigotConfig logCommands check + ServerGamePacketListenerImpl.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command); ++ } // Paper - Add missing SpigotConfig logCommands check + PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command, new LazyPlayerSet(this.server)); + this.cserver.getPluginManager().callEvent(event); @@ -1393,7 +1400,7 @@ } catch (SignedMessageChain.DecodeException signedmessagechain_a) { this.handleMessageDecodeFailure(signedmessagechain_a); return; -@@ -1451,10 +2203,10 @@ +@@ -1451,10 +2207,10 @@ CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map); @@ -1406,7 +1413,7 @@ } private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { -@@ -1530,14 +2282,20 @@ +@@ -1530,14 +2286,20 @@ return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack()); } @@ -1432,7 +1439,7 @@ } } -@@ -1549,7 +2307,7 @@ +@@ -1549,7 +2311,7 @@ if (optional.isEmpty()) { ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); @@ -1441,7 +1448,7 @@ } return optional; -@@ -1564,8 +2322,129 @@ +@@ -1564,8 +2326,129 @@ } return false; @@ -1571,7 +1578,7 @@ private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException { SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages); -@@ -1573,15 +2452,44 @@ +@@ -1573,15 +2456,44 @@ } private void broadcastChatMessage(PlayerChatMessage message) { @@ -1622,7 +1629,7 @@ } -@@ -1592,7 +2500,7 @@ +@@ -1592,7 +2504,7 @@ synchronized (this.lastSeenMessages) { if (!this.lastSeenMessages.applyOffset(packet.offset())) { ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); @@ -1631,7 +1638,7 @@ } } -@@ -1601,7 +2509,40 @@ +@@ -1601,7 +2513,40 @@ @Override public void handleAnimate(ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -1672,7 +1679,7 @@ this.player.swing(packet.getHand()); } -@@ -1609,6 +2550,29 @@ +@@ -1609,6 +2554,29 @@ public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (this.player.hasClientLoaded()) { @@ -1702,7 +1709,7 @@ this.player.resetLastActionTime(); Entity entity; PlayerRideableJumping ijumpable; -@@ -1616,6 +2580,11 @@ +@@ -1616,6 +2584,11 @@ switch (packet.getAction()) { case PRESS_SHIFT_KEY: this.player.setShiftKeyDown(true); @@ -1714,7 +1721,7 @@ break; case RELEASE_SHIFT_KEY: this.player.setShiftKeyDown(false); -@@ -1684,13 +2653,19 @@ +@@ -1684,13 +2657,19 @@ } if (i > 4096) { @@ -1735,10 +1742,12 @@ this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params)); this.addPendingMessage(message); } -@@ -1703,6 +2678,18 @@ - return this.connection.getRemoteAddress(); - } +@@ -1701,7 +2680,19 @@ + public SocketAddress getRemoteAddress() { + return this.connection.getRemoteAddress(); ++ } ++ + // Spigot Start + public SocketAddress getRawAddress() + { @@ -1748,13 +1757,12 @@ + } + // Paper end - Unix domain socket support + return this.connection.channel.remoteAddress(); -+ } + } + // Spigot End -+ + public void switchToConfig() { this.waitingForSwitchToConfig = true; - this.removePlayerFromWorld(); -@@ -1718,9 +2705,17 @@ +@@ -1718,9 +2709,17 @@ @Override public void handleInteract(ServerboundInteractPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -1772,7 +1780,7 @@ this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); -@@ -1733,20 +2728,58 @@ +@@ -1733,20 +2732,58 @@ if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) { packet.dispatch(new ServerboundInteractPacket.Handler() { @@ -1835,7 +1843,7 @@ } } -@@ -1755,19 +2788,20 @@ +@@ -1755,19 +2792,20 @@ @Override public void onInteraction(InteractionHand hand) { @@ -1859,7 +1867,7 @@ label23: { if (entity instanceof AbstractArrow) { -@@ -1785,17 +2819,41 @@ +@@ -1785,17 +2823,41 @@ } ServerGamePacketListenerImpl.this.player.attack(entity); @@ -1902,7 +1910,7 @@ } } -@@ -1809,7 +2867,7 @@ +@@ -1809,7 +2871,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1911,7 +1919,7 @@ this.resetPosition(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); } else { -@@ -1817,11 +2875,11 @@ +@@ -1817,11 +2879,11 @@ return; } @@ -1926,7 +1934,7 @@ } } break; -@@ -1833,16 +2891,27 @@ +@@ -1833,16 +2895,27 @@ @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { @@ -1956,7 +1964,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1855,7 +2924,284 @@ +@@ -1855,7 +2928,284 @@ boolean flag = packet.getStateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2242,7 +2250,7 @@ ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1879,6 +3225,14 @@ +@@ -1879,6 +3229,14 @@ @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { @@ -2257,7 +2265,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1900,9 +3254,43 @@ +@@ -1900,9 +3258,43 @@ ServerGamePacketListenerImpl.LOGGER.debug("Player {} tried to place impossible recipe {}", this.player, recipeholder.id().location()); return; } @@ -2302,7 +2310,7 @@ if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display())); } -@@ -1917,6 +3305,7 @@ +@@ -1917,6 +3309,7 @@ @Override public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -2310,7 +2318,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1945,6 +3334,43 @@ +@@ -1945,6 +3338,43 @@ boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize(); @@ -2354,7 +2362,7 @@ if (flag1 && flag2) { this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack); -@@ -1964,7 +3390,19 @@ +@@ -1964,7 +3394,19 @@ @Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { @@ -2375,7 +2383,7 @@ this.filterTextPacket(list).thenAcceptAsync((list1) -> { this.updateSignText(packet, list1); -@@ -1972,6 +3410,7 @@ +@@ -1972,6 +3414,7 @@ } private void updateSignText(ServerboundSignUpdatePacket packet, List signText) { @@ -2383,7 +2391,7 @@ this.player.resetLastActionTime(); ServerLevel worldserver = this.player.serverLevel(); BlockPos blockposition = packet.getPos(); -@@ -1993,15 +3432,33 @@ +@@ -1993,15 +3436,33 @@ @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -2418,7 +2426,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -2012,7 +3469,7 @@ +@@ -2012,7 +3473,7 @@ public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) { @@ -2427,7 +2435,7 @@ } } -@@ -2033,7 +3490,7 @@ +@@ -2033,7 +3494,7 @@ if (!Objects.equals(profilepublickey_a, profilepublickey_a1)) { if (profilepublickey_a != null && profilepublickey_a1.expiresAt().isBefore(profilepublickey_a.expiresAt())) { @@ -2436,7 +2444,7 @@ } else { try { SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator(); -@@ -2045,8 +3502,8 @@ +@@ -2045,8 +3506,8 @@ this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator)); } catch (ProfilePublicKey.ValidationException profilepublickey_b) { @@ -2447,7 +2455,7 @@ } } -@@ -2058,7 +3515,7 @@ +@@ -2058,7 +3519,7 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -2456,7 +2464,7 @@ } } -@@ -2083,8 +3540,10 @@ +@@ -2083,8 +3544,10 @@ }); }