13
0
geforkt von Mirrors/Paper

Don't allow vehicle movement from players while teleporting

Bring the vehicle move packet behavior in line with the
regular player move packet.
Dieser Commit ist enthalten in:
Spottedleaf 2022-03-14 12:35:37 -07:00
Ursprung 2de1053b58
Commit 0d199767d2

Datei anzeigen

@ -217,7 +217,7 @@
this.player.setLastClientInput(packet.input()); this.player.setLastClientInput(packet.input());
} }
@@ -395,27 +488,79 @@ @@ -395,27 +488,84 @@
public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) { public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (ServerGamePacketListenerImpl.containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) { if (ServerGamePacketListenerImpl.containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) {
@ -225,6 +225,11 @@
+ this.disconnect((Component) Component.translatable("multiplayer.disconnect.invalid_vehicle_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_VEHICLE_MOVEMENT); // Paper - kick event cause + this.disconnect((Component) Component.translatable("multiplayer.disconnect.invalid_vehicle_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_VEHICLE_MOVEMENT); // Paper - kick event cause
} else if (!this.updateAwaitingTeleport() && this.player.hasClientLoaded()) { } else if (!this.updateAwaitingTeleport() && this.player.hasClientLoaded()) {
Entity entity = this.player.getRootVehicle(); Entity entity = this.player.getRootVehicle();
+ // Paper start - Don't allow vehicle movement from players while teleporting
+ if (this.awaitingPositionFromClient != null || this.player.isImmobile() || entity.isRemoved()) {
+ return;
+ }
+ // Paper end - Don't allow vehicle movement from players while teleporting
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
ServerLevel worldserver = this.player.serverLevel(); ServerLevel worldserver = this.player.serverLevel();
@ -306,7 +311,7 @@
ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
this.send(ClientboundMoveVehiclePacket.fromEntity(entity)); this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
return; return;
@@ -423,9 +568,9 @@ @@ -423,9 +573,9 @@
boolean flag = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D)); boolean flag = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D));
@ -319,7 +324,7 @@
boolean flag1 = entity.verticalCollisionBelow; boolean flag1 = entity.verticalCollisionBelow;
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
@@ -449,19 +594,72 @@ @@ -449,19 +599,72 @@
d10 = d6 * d6 + d7 * d7 + d8 * d8; d10 = d6 * d6 + d7 * d7 + d8 * d8;
boolean flag2 = false; boolean flag2 = false;
@ -393,7 +398,7 @@
this.player.serverLevel().getChunkSource().move(this.player); this.player.serverLevel().getChunkSource().move(this.player);
entity.recordMovementThroughBlocks(new Vec3(d0, d1, d2), entity.position()); entity.recordMovementThroughBlocks(new Vec3(d0, d1, d2), entity.position());
@@ -489,16 +687,17 @@ @@ -489,16 +692,17 @@
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (packet.getId() == this.awaitingTeleport) { if (packet.getId() == this.awaitingTeleport) {
if (this.awaitingPositionFromClient == null) { if (this.awaitingPositionFromClient == null) {
@ -413,7 +418,7 @@
} }
} }
@@ -528,6 +727,7 @@ @@ -528,6 +732,7 @@
@Override @Override
public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) { public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -421,7 +426,7 @@
this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering());
} }
@@ -545,21 +745,85 @@ @@ -545,21 +750,85 @@
} }
@ -511,7 +516,7 @@
}); });
} }
@@ -568,7 +832,7 @@ @@ -568,7 +837,7 @@
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (!this.server.isCommandBlockEnabled()) { if (!this.server.isCommandBlockEnabled()) {
this.player.sendSystemMessage(Component.translatable("advMode.notEnabled")); this.player.sendSystemMessage(Component.translatable("advMode.notEnabled"));
@ -520,7 +525,7 @@
this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); this.player.sendSystemMessage(Component.translatable("advMode.notAllowed"));
} else { } else {
BaseCommandBlock commandblocklistenerabstract = null; BaseCommandBlock commandblocklistenerabstract = null;
@@ -635,7 +899,7 @@ @@ -635,7 +904,7 @@
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (!this.server.isCommandBlockEnabled()) { if (!this.server.isCommandBlockEnabled()) {
this.player.sendSystemMessage(Component.translatable("advMode.notEnabled")); this.player.sendSystemMessage(Component.translatable("advMode.notEnabled"));
@ -529,7 +534,7 @@
this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); this.player.sendSystemMessage(Component.translatable("advMode.notAllowed"));
} else { } else {
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level()); BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level());
@@ -668,7 +932,7 @@ @@ -668,7 +937,7 @@
ItemStack itemstack = iblockdata.getCloneItemStack(worldserver, blockposition, flag); ItemStack itemstack = iblockdata.getCloneItemStack(worldserver, blockposition, flag);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
@ -538,7 +543,7 @@
ServerGamePacketListenerImpl.addBlockDataToItem(iblockdata, worldserver, blockposition, itemstack); ServerGamePacketListenerImpl.addBlockDataToItem(iblockdata, worldserver, blockposition, itemstack);
} }
@@ -866,6 +1130,13 @@ @@ -866,6 +1135,13 @@
AbstractContainerMenu container = this.player.containerMenu; AbstractContainerMenu container = this.player.containerMenu;
if (container instanceof MerchantMenu containermerchant) { if (container instanceof MerchantMenu containermerchant) {
@ -552,7 +557,7 @@
if (!containermerchant.stillValid(this.player)) { if (!containermerchant.stillValid(this.player)) {
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant); ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
return; return;
@@ -879,6 +1150,51 @@ @@ -879,6 +1155,51 @@
@Override @Override
public void handleEditBook(ServerboundEditBookPacket packet) { public void handleEditBook(ServerboundEditBookPacket packet) {
@ -604,7 +609,7 @@
int i = packet.slot(); int i = packet.slot();
if (Inventory.isHotbarSlot(i) || i == 40) { if (Inventory.isHotbarSlot(i) || i == 40) {
@@ -899,12 +1215,16 @@ @@ -899,12 +1220,16 @@
} }
private void updateBookContents(List<FilteredText> pages, int slotId) { private void updateBookContents(List<FilteredText> pages, int slotId) {
@ -622,7 +627,7 @@
} }
} }
@@ -915,12 +1235,13 @@ @@ -915,12 +1240,13 @@
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK); ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK);
itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT); itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT);
@ -638,7 +643,7 @@
} }
} }
@@ -978,26 +1299,34 @@ @@ -978,26 +1304,34 @@
public void handleMovePlayer(ServerboundMovePlayerPacket packet) { public void handleMovePlayer(ServerboundMovePlayerPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (ServerGamePacketListenerImpl.containsInvalidValues(packet.getX(0.0D), packet.getY(0.0D), packet.getZ(0.0D), packet.getYRot(0.0F), packet.getXRot(0.0F))) { if (ServerGamePacketListenerImpl.containsInvalidValues(packet.getX(0.0D), packet.getY(0.0D), packet.getZ(0.0D), packet.getYRot(0.0F), packet.getXRot(0.0F))) {
@ -678,7 +683,7 @@
double d3 = this.player.getX(); double d3 = this.player.getX();
double d4 = this.player.getY(); double d4 = this.player.getY();
double d5 = this.player.getZ(); double d5 = this.player.getZ();
@@ -1005,7 +1334,16 @@ @@ -1005,7 +1339,16 @@
double d7 = d1 - this.firstGoodY; double d7 = d1 - this.firstGoodY;
double d8 = d2 - this.firstGoodZ; double d8 = d2 - this.firstGoodZ;
double d9 = this.player.getDeltaMovement().lengthSqr(); double d9 = this.player.getDeltaMovement().lengthSqr();
@ -696,7 +701,7 @@
if (this.player.isSleeping()) { if (this.player.isSleeping()) {
if (d10 > 1.0D) { if (d10 > 1.0D) {
@@ -1019,15 +1357,39 @@ @@ -1019,15 +1362,39 @@
++this.receivedMovePacketCount; ++this.receivedMovePacketCount;
int i = this.receivedMovePacketCount - this.knownMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount;
@ -738,7 +743,7 @@
ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8}); 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()); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return; return;
@@ -1037,18 +1399,51 @@ @@ -1037,18 +1404,51 @@
AABB axisalignedbb = this.player.getBoundingBox(); AABB axisalignedbb = this.player.getBoundingBox();
@ -794,7 +799,7 @@
double d11 = d7; double d11 = d7;
d6 = d0 - this.player.getX(); d6 = d0 - this.player.getX();
@@ -1061,15 +1456,81 @@ @@ -1061,15 +1461,81 @@
d10 = d6 * d6 + d7 * d7 + d8 * d8; d10 = d6 * d6 + d7 * d7 + d8 * d8;
boolean flag3 = false; boolean flag3 = false;
@ -878,7 +883,7 @@
this.player.absMoveTo(d0, d1, d2, f, f1); this.player.absMoveTo(d0, d1, d2, f, f1);
boolean flag4 = this.player.isAutoSpinAttack(); boolean flag4 = this.player.isAutoSpinAttack();
@@ -1119,6 +1580,7 @@ @@ -1119,6 +1585,7 @@
this.awaitingTeleportTime = this.tickCount; this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
} }
@ -886,7 +891,7 @@
return true; return true;
} else { } else {
@@ -1147,23 +1609,91 @@ @@ -1147,23 +1614,91 @@
} }
public void teleport(double x, double y, double z, float yaw, float pitch) { public void teleport(double x, double y, double z, float yaw, float pitch) {
@ -981,7 +986,7 @@
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
BlockPos blockposition = packet.getPos(); BlockPos blockposition = packet.getPos();
@@ -1175,14 +1705,46 @@ @@ -1175,14 +1710,46 @@
if (!this.player.isSpectator()) { if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND); ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND);
@ -1030,7 +1035,7 @@
this.player.drop(false); this.player.drop(false);
} }
@@ -1199,6 +1761,12 @@ @@ -1199,6 +1766,12 @@
case START_DESTROY_BLOCK: case START_DESTROY_BLOCK:
case ABORT_DESTROY_BLOCK: case ABORT_DESTROY_BLOCK:
case STOP_DESTROY_BLOCK: case STOP_DESTROY_BLOCK:
@ -1043,7 +1048,7 @@
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level().getMaxY(), packet.getSequence()); this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level().getMaxY(), packet.getSequence());
this.player.connection.ackBlockChangesUpTo(packet.getSequence()); this.player.connection.ackBlockChangesUpTo(packet.getSequence());
return; return;
@@ -1218,9 +1786,31 @@ @@ -1218,9 +1791,31 @@
} }
} }
@ -1075,7 +1080,7 @@
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
this.player.connection.ackBlockChangesUpTo(packet.getSequence()); this.player.connection.ackBlockChangesUpTo(packet.getSequence());
ServerLevel worldserver = this.player.serverLevel(); ServerLevel worldserver = this.player.serverLevel();
@@ -1230,6 +1820,11 @@ @@ -1230,6 +1825,11 @@
if (itemstack.isItemEnabled(worldserver.enabledFeatures())) { if (itemstack.isItemEnabled(worldserver.enabledFeatures())) {
BlockHitResult movingobjectpositionblock = packet.getHitResult(); BlockHitResult movingobjectpositionblock = packet.getHitResult();
Vec3 vec3d = movingobjectpositionblock.getLocation(); Vec3 vec3d = movingobjectpositionblock.getLocation();
@ -1087,7 +1092,7 @@
BlockPos blockposition = movingobjectpositionblock.getBlockPos(); BlockPos blockposition = movingobjectpositionblock.getBlockPos();
if (this.player.canInteractWithBlock(blockposition, 1.0D)) { if (this.player.canInteractWithBlock(blockposition, 1.0D)) {
@@ -1243,7 +1838,8 @@ @@ -1243,7 +1843,8 @@
int i = this.player.level().getMaxY(); int i = this.player.level().getMaxY();
if (blockposition.getY() <= i) { if (blockposition.getY() <= i) {
@ -1097,7 +1102,7 @@
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
if (enuminteractionresult.consumesAction()) { if (enuminteractionresult.consumesAction()) {
@@ -1257,7 +1853,7 @@ @@ -1257,7 +1858,7 @@
} else if (enuminteractionresult instanceof InteractionResult.Success) { } else if (enuminteractionresult instanceof InteractionResult.Success) {
InteractionResult.Success enuminteractionresult_d = (InteractionResult.Success) enuminteractionresult; InteractionResult.Success enuminteractionresult_d = (InteractionResult.Success) enuminteractionresult;
@ -1106,7 +1111,7 @@
this.player.swing(enumhand, true); this.player.swing(enumhand, true);
} }
} }
@@ -1281,6 +1877,8 @@ @@ -1281,6 +1882,8 @@
@Override @Override
public void handleUseItem(ServerboundUseItemPacket packet) { public void handleUseItem(ServerboundUseItemPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1115,10 +1120,12 @@
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
this.ackBlockChangesUpTo(packet.getSequence()); this.ackBlockChangesUpTo(packet.getSequence());
ServerLevel worldserver = this.player.serverLevel(); ServerLevel worldserver = this.player.serverLevel();
@@ -1296,6 +1894,47 @@ @@ -1294,8 +1897,49 @@
this.player.absRotateTo(f, f1);
}
if (f1 != this.player.getXRot() || f != this.player.getYRot()) {
this.player.absRotateTo(f, f1);
+ }
+
+ // CraftBukkit start + // CraftBukkit start
+ // Raytrace to look for 'rogue armswings' + // Raytrace to look for 'rogue armswings'
+ double d0 = this.player.getX(); + double d0 = this.player.getX();
@ -1149,8 +1156,8 @@
+ cancelled = event.useItemInHand() == Event.Result.DENY; + cancelled = event.useItemInHand() == Event.Result.DENY;
+ } + }
+ this.player.gameMode.firedInteract = false; + this.player.gameMode.firedInteract = false;
+ } }
+
+ if (cancelled) { + if (cancelled) {
+ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 + this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
+ return; + return;
@ -1163,7 +1170,7 @@
InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
if (enuminteractionresult instanceof InteractionResult.Success) { if (enuminteractionresult instanceof InteractionResult.Success) {
@@ -1321,7 +1960,7 @@ @@ -1321,7 +1965,7 @@
Entity entity = packet.getEntity(worldserver); Entity entity = packet.getEntity(worldserver);
if (entity != null) { if (entity != null) {
@ -1172,7 +1179,7 @@
return; return;
} }
} }
@@ -1342,17 +1981,46 @@ @@ -1342,17 +1986,46 @@
@Override @Override
public void onDisconnect(DisconnectionDetails info) { public void onDisconnect(DisconnectionDetails info) {
@ -1223,7 +1230,7 @@
this.player.getTextFilter().leave(); this.player.getTextFilter().leave();
} }
@@ -1367,7 +2035,17 @@ @@ -1367,7 +2040,17 @@
@Override @Override
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) { public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1241,7 +1248,7 @@
if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) { if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
this.player.stopUsingItem(); this.player.stopUsingItem();
} }
@@ -1376,11 +2054,18 @@ @@ -1376,11 +2059,18 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
} else { } else {
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@ -1260,7 +1267,7 @@
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages());
if (!optional.isEmpty()) { if (!optional.isEmpty()) {
@@ -1394,27 +2079,44 @@ @@ -1394,27 +2084,44 @@
return; return;
} }
@ -1312,7 +1319,7 @@
ParseResults<CommandSourceStack> parseresults = this.parseCommand(command); ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) { if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
@@ -1431,19 +2133,37 @@ @@ -1431,19 +2138,37 @@
if (!optional.isEmpty()) { if (!optional.isEmpty()) {
this.tryHandleChat(packet.command(), () -> { this.tryHandleChat(packet.command(), () -> {
@ -1354,7 +1361,7 @@
} catch (SignedMessageChain.DecodeException signedmessagechain_a) { } catch (SignedMessageChain.DecodeException signedmessagechain_a) {
this.handleMessageDecodeFailure(signedmessagechain_a); this.handleMessageDecodeFailure(signedmessagechain_a);
return; return;
@@ -1451,10 +2171,10 @@ @@ -1451,10 +2176,10 @@
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map); CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
@ -1367,7 +1374,7 @@
} }
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
@@ -1530,14 +2250,20 @@ @@ -1530,14 +2255,20 @@
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack()); return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
} }
@ -1393,7 +1400,7 @@
} }
} }
@@ -1549,7 +2275,7 @@ @@ -1549,7 +2280,7 @@
if (optional.isEmpty()) { if (optional.isEmpty()) {
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
@ -1402,7 +1409,7 @@
} }
return optional; return optional;
@@ -1566,6 +2292,127 @@ @@ -1566,6 +2297,127 @@
return false; return false;
} }
@ -1530,7 +1537,7 @@
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException { private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException {
SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages); SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages);
@@ -1573,15 +2420,44 @@ @@ -1573,15 +2425,44 @@
} }
private void broadcastChatMessage(PlayerChatMessage message) { private void broadcastChatMessage(PlayerChatMessage message) {
@ -1581,7 +1588,7 @@
} }
@@ -1592,7 +2468,7 @@ @@ -1592,7 +2473,7 @@
synchronized (this.lastSeenMessages) { synchronized (this.lastSeenMessages) {
if (!this.lastSeenMessages.applyOffset(packet.offset())) { if (!this.lastSeenMessages.applyOffset(packet.offset())) {
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
@ -1590,7 +1597,7 @@
} }
} }
@@ -1601,7 +2477,40 @@ @@ -1601,7 +2482,40 @@
@Override @Override
public void handleAnimate(ServerboundSwingPacket packet) { public void handleAnimate(ServerboundSwingPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1631,7 +1638,7 @@
this.player.swing(packet.getHand()); this.player.swing(packet.getHand());
} }
@@ -1609,6 +2518,29 @@ @@ -1609,6 +2523,29 @@
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) { public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
@ -1661,7 +1668,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
Entity entity; Entity entity;
PlayerRideableJumping ijumpable; PlayerRideableJumping ijumpable;
@@ -1616,6 +2548,11 @@ @@ -1616,6 +2553,11 @@
switch (packet.getAction()) { switch (packet.getAction()) {
case PRESS_SHIFT_KEY: case PRESS_SHIFT_KEY:
this.player.setShiftKeyDown(true); this.player.setShiftKeyDown(true);
@ -1673,7 +1680,7 @@
break; break;
case RELEASE_SHIFT_KEY: case RELEASE_SHIFT_KEY:
this.player.setShiftKeyDown(false); this.player.setShiftKeyDown(false);
@@ -1684,13 +2621,19 @@ @@ -1684,13 +2626,19 @@
} }
if (i > 4096) { if (i > 4096) {
@ -1694,7 +1701,7 @@
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params)); 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); this.addPendingMessage(message);
} }
@@ -1703,6 +2646,18 @@ @@ -1703,6 +2651,18 @@
return this.connection.getRemoteAddress(); return this.connection.getRemoteAddress();
} }
@ -1713,7 +1720,7 @@
public void switchToConfig() { public void switchToConfig() {
this.waitingForSwitchToConfig = true; this.waitingForSwitchToConfig = true;
this.removePlayerFromWorld(); this.removePlayerFromWorld();
@@ -1718,9 +2673,17 @@ @@ -1718,9 +2678,17 @@
@Override @Override
public void handleInteract(ServerboundInteractPacket packet) { public void handleInteract(ServerboundInteractPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1731,7 +1738,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
@@ -1733,20 +2696,58 @@ @@ -1733,20 +2701,58 @@
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) { if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
packet.dispatch(new ServerboundInteractPacket.Handler() { packet.dispatch(new ServerboundInteractPacket.Handler() {
@ -1794,7 +1801,7 @@
} }
} }
@@ -1755,19 +2756,20 @@ @@ -1755,19 +2761,20 @@
@Override @Override
public void onInteraction(InteractionHand hand) { public void onInteraction(InteractionHand hand) {
@ -1818,7 +1825,7 @@
label23: label23:
{ {
if (entity instanceof AbstractArrow) { if (entity instanceof AbstractArrow) {
@@ -1785,17 +2787,41 @@ @@ -1785,17 +2792,41 @@
} }
ServerGamePacketListenerImpl.this.player.attack(entity); ServerGamePacketListenerImpl.this.player.attack(entity);
@ -1861,7 +1868,7 @@
} }
} }
@@ -1809,7 +2835,7 @@ @@ -1809,7 +2840,7 @@
case PERFORM_RESPAWN: case PERFORM_RESPAWN:
if (this.player.wonGame) { if (this.player.wonGame) {
this.player.wonGame = false; this.player.wonGame = false;
@ -1870,7 +1877,7 @@
this.resetPosition(); this.resetPosition();
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
} else { } else {
@@ -1817,11 +2843,11 @@ @@ -1817,11 +2848,11 @@
return; return;
} }
@ -1885,7 +1892,7 @@
} }
} }
break; break;
@@ -1833,16 +2859,27 @@ @@ -1833,16 +2864,27 @@
@Override @Override
public void handleContainerClose(ServerboundContainerClosePacket packet) { public void handleContainerClose(ServerboundContainerClosePacket packet) {
@ -1915,7 +1922,7 @@
this.player.containerMenu.sendAllDataToRemote(); this.player.containerMenu.sendAllDataToRemote();
} else if (!this.player.containerMenu.stillValid(this.player)) { } else if (!this.player.containerMenu.stillValid(this.player)) {
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
@@ -1855,7 +2892,284 @@ @@ -1855,7 +2897,284 @@
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId(); boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates(); this.player.containerMenu.suppressRemoteUpdates();
@ -2201,7 +2208,7 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator(); ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
@@ -1879,6 +3193,14 @@ @@ -1879,6 +3198,14 @@
@Override @Override
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
@ -2216,7 +2223,7 @@
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
this.player.resetLastActionTime(); this.player.resetLastActionTime();
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) {
@@ -1900,9 +3222,43 @@ @@ -1900,9 +3227,43 @@
ServerGamePacketListenerImpl.LOGGER.debug("Player {} tried to place impossible recipe {}", this.player, recipeholder.id().location()); ServerGamePacketListenerImpl.LOGGER.debug("Player {} tried to place impossible recipe {}", this.player, recipeholder.id().location());
return; return;
} }
@ -2261,7 +2268,7 @@
if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) {
this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display())); this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
} }
@@ -1917,6 +3273,7 @@ @@ -1917,6 +3278,7 @@
@Override @Override
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -2269,7 +2276,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
if (!this.player.containerMenu.stillValid(this.player)) { if (!this.player.containerMenu.stillValid(this.player)) {
@@ -1945,6 +3302,43 @@ @@ -1945,6 +3307,43 @@
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize(); boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
@ -2313,7 +2320,7 @@
if (flag1 && flag2) { if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack); this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
@@ -1964,7 +3358,19 @@ @@ -1964,7 +3363,19 @@
@Override @Override
public void handleSignUpdate(ServerboundSignUpdatePacket packet) { public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
@ -2334,7 +2341,7 @@
this.filterTextPacket(list).thenAcceptAsync((list1) -> { this.filterTextPacket(list).thenAcceptAsync((list1) -> {
this.updateSignText(packet, list1); this.updateSignText(packet, list1);
@@ -1972,6 +3378,7 @@ @@ -1972,6 +3383,7 @@
} }
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) { private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
@ -2342,7 +2349,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
ServerLevel worldserver = this.player.serverLevel(); ServerLevel worldserver = this.player.serverLevel();
BlockPos blockposition = packet.getPos(); BlockPos blockposition = packet.getPos();
@@ -1993,15 +3400,33 @@ @@ -1993,15 +3405,33 @@
@Override @Override
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -2377,7 +2384,7 @@
if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) { if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) {
this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player));
} }
@@ -2012,7 +3437,7 @@ @@ -2012,7 +3442,7 @@
public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) { public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) { if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) {
@ -2386,7 +2393,7 @@
} }
} }
@@ -2033,7 +3458,7 @@ @@ -2033,7 +3463,7 @@
if (!Objects.equals(profilepublickey_a, profilepublickey_a1)) { if (!Objects.equals(profilepublickey_a, profilepublickey_a1)) {
if (profilepublickey_a != null && profilepublickey_a1.expiresAt().isBefore(profilepublickey_a.expiresAt())) { if (profilepublickey_a != null && profilepublickey_a1.expiresAt().isBefore(profilepublickey_a.expiresAt())) {
@ -2395,7 +2402,7 @@
} else { } else {
try { try {
SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator(); SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator();
@@ -2046,7 +3471,7 @@ @@ -2046,7 +3476,7 @@
this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator)); this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator));
} catch (ProfilePublicKey.ValidationException profilepublickey_b) { } catch (ProfilePublicKey.ValidationException profilepublickey_b) {
ServerGamePacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage()); ServerGamePacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage());
@ -2404,7 +2411,7 @@
} }
} }
@@ -2058,7 +3483,7 @@ @@ -2058,7 +3488,7 @@
if (!this.waitingForSwitchToConfig) { if (!this.waitingForSwitchToConfig) {
throw new IllegalStateException("Client acknowledged config, but none was requested"); throw new IllegalStateException("Client acknowledged config, but none was requested");
} else { } else {
@ -2413,7 +2420,7 @@
} }
} }
@@ -2083,8 +3508,10 @@ @@ -2083,8 +3513,10 @@
}); });
} }