13
0
geforkt von Mirrors/Paper

Send block entities after destroy prediction

Minecraft's prediction system does not handle block entities, so if we are manually sending block entities during
block breaking we need to set it after the prediction is finished. This fixes block entities not showing when cancelling the BlockBreakEvent.
Dieser Commit ist enthalten in:
Owen1212055 2022-06-25 19:45:20 -04:00
Ursprung 103a5ea12b
Commit 8a49cbc3a7
2 geänderte Dateien mit 107 neuen und 81 gelöschten Zeilen

Datei anzeigen

@ -39,7 +39,16 @@
public class ServerPlayerGameMode { public class ServerPlayerGameMode {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@@ -53,18 +72,32 @@ @@ -42,6 +61,8 @@
private BlockPos delayedDestroyPos;
private int delayedTickStart;
private int lastSentState;
+ public boolean captureSentBlockEntities = false; // Paper - Send block entities after destroy prediction
+ public boolean capturedBlockEntity = false; // Paper - Send block entities after destroy prediction
public ServerPlayerGameMode(ServerPlayer player) {
this.gameModeForPlayer = GameType.DEFAULT_MODE;
@@ -53,18 +74,32 @@
} }
public boolean changeGameModeForPlayer(GameType gameMode) { public boolean changeGameModeForPlayer(GameType gameMode) {
@ -75,7 +84,7 @@
} }
} }
@@ -92,12 +125,12 @@ @@ -92,12 +127,12 @@
} }
public void tick() { public void tick() {
@ -91,7 +100,7 @@
this.hasDelayedDestroy = false; this.hasDelayedDestroy = false;
} else { } else {
float f = this.incrementDestroyProgress(iblockdata, this.delayedDestroyPos, this.delayedTickStart); float f = this.incrementDestroyProgress(iblockdata, this.delayedDestroyPos, this.delayedTickStart);
@@ -108,7 +141,13 @@ @@ -108,7 +143,13 @@
} }
} }
} else if (this.isDestroyingBlock) { } else if (this.isDestroyingBlock) {
@ -106,7 +115,7 @@
if (iblockdata.isAir()) { if (iblockdata.isAir()) {
this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
this.lastSentState = -1; this.lastSentState = -1;
@@ -137,6 +176,7 @@ @@ -137,6 +178,7 @@
public void handleBlockBreakAction(BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) { public void handleBlockBreakAction(BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) {
if (!this.player.canInteractWithBlock(pos, 1.0D)) { if (!this.player.canInteractWithBlock(pos, 1.0D)) {
@ -114,7 +123,7 @@
this.debugLogging(pos, false, sequence, "too far"); this.debugLogging(pos, false, sequence, "too far");
} else if (pos.getY() > worldHeight) { } else if (pos.getY() > worldHeight) {
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
@@ -146,16 +186,46 @@ @@ -146,16 +188,40 @@
if (action == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) { if (action == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) {
if (!this.level.mayInteract(this.player, pos)) { if (!this.level.mayInteract(this.player, pos)) {
@ -123,28 +132,22 @@
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
this.debugLogging(pos, false, sequence, "may not interact"); this.debugLogging(pos, false, sequence, "may not interact");
+ // Update any tile entity data for this block + // Update any tile entity data for this block
+ BlockEntity tileentity = this.level.getBlockEntity(pos); + capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
+ if (tileentity != null) {
+ this.player.connection.send(tileentity.getUpdatePacket());
+ }
+ // CraftBukkit end + // CraftBukkit end
return; + return;
} + }
+
+ // CraftBukkit start + // CraftBukkit start
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); + PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ // Let the client know the block still exists + // Let the client know the block still exists
+ this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); + this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
+ // Update any tile entity data for this block + // Update any tile entity data for this block
+ BlockEntity tileentity = this.level.getBlockEntity(pos); + capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
+ if (tileentity != null) { return;
+ this.player.connection.send(tileentity.getUpdatePacket()); }
+ }
+ return;
+ }
+ // CraftBukkit end + // CraftBukkit end
+
if (this.isCreative()) { if (this.isCreative()) {
this.destroyAndAck(pos, sequence, "creative destroy"); this.destroyAndAck(pos, sequence, "creative destroy");
return; return;
@ -161,7 +164,7 @@
if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) { if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) {
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
this.debugLogging(pos, false, sequence, "block action restricted"); this.debugLogging(pos, false, sequence, "block action restricted");
@@ -166,7 +236,19 @@ @@ -166,7 +232,19 @@
float f = 1.0F; float f = 1.0F;
iblockdata = this.level.getBlockState(pos); iblockdata = this.level.getBlockState(pos);
@ -182,7 +185,7 @@
EnchantmentHelper.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EquipmentSlot.MAINHAND, Vec3.atCenterOf(pos), iblockdata, (item) -> { EnchantmentHelper.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EquipmentSlot.MAINHAND, Vec3.atCenterOf(pos), iblockdata, (item) -> {
this.player.onEquippedItemBroken(item, EquipmentSlot.MAINHAND); this.player.onEquippedItemBroken(item, EquipmentSlot.MAINHAND);
}); });
@@ -174,6 +256,26 @@ @@ -174,6 +252,26 @@
f = iblockdata.getDestroyProgress(this.player, this.player.level(), pos); f = iblockdata.getDestroyProgress(this.player, this.player.level(), pos);
} }
@ -209,7 +212,7 @@
if (!iblockdata.isAir() && f >= 1.0F) { if (!iblockdata.isAir() && f >= 1.0F) {
this.destroyAndAck(pos, sequence, "insta mine"); this.destroyAndAck(pos, sequence, "insta mine");
} else { } else {
@@ -217,14 +319,18 @@ @@ -217,14 +315,18 @@
this.debugLogging(pos, true, sequence, "stopped destroying"); this.debugLogging(pos, true, sequence, "stopped destroying");
} else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) { } else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) {
this.isDestroyingBlock = false; this.isDestroyingBlock = false;
@ -232,7 +235,7 @@
} }
} }
@@ -242,19 +348,78 @@ @@ -242,19 +344,80 @@
public boolean destroyBlock(BlockPos pos) { public boolean destroyBlock(BlockPos pos) {
BlockState iblockdata = this.level.getBlockState(pos); BlockState iblockdata = this.level.getBlockState(pos);
@ -282,10 +285,12 @@
+ } + }
+ +
+ // Update any tile entity data for this block + // Update any tile entity data for this block
+ if (!captureSentBlockEntities) { // Paper - Send block entities after destroy prediction
+ BlockEntity tileentity = this.level.getBlockEntity(pos); + BlockEntity tileentity = this.level.getBlockEntity(pos);
+ if (tileentity != null) { + if (tileentity != null) {
+ this.player.connection.send(tileentity.getUpdatePacket()); + this.player.connection.send(tileentity.getUpdatePacket());
+ } + }
+ } else {capturedBlockEntity = true;} // Paper - Send block entities after destroy prediction
+ return false; + return false;
+ } + }
+ } + }
@ -313,7 +318,7 @@
BlockState iblockdata1 = block.playerWillDestroy(this.level, pos, iblockdata, this.player); BlockState iblockdata1 = block.playerWillDestroy(this.level, pos, iblockdata, this.player);
boolean flag = this.level.removeBlock(pos, false); boolean flag = this.level.removeBlock(pos, false);
@@ -262,20 +427,46 @@ @@ -262,20 +425,46 @@
block.destroy(this.level, pos, iblockdata1); block.destroy(this.level, pos, iblockdata1);
} }
@ -363,7 +368,7 @@
} }
} }
} }
@@ -321,15 +512,58 @@ @@ -321,15 +510,58 @@
} }
} }
@ -422,7 +427,7 @@
if (itileinventory != null) { if (itileinventory != null) {
player.openMenu(itileinventory); player.openMenu(itileinventory);
return InteractionResult.CONSUME; return InteractionResult.CONSUME;
@@ -359,7 +593,7 @@ @@ -359,7 +591,7 @@
} }
} }

Datei anzeigen

@ -323,7 +323,7 @@
boolean flag1 = entity.verticalCollisionBelow; boolean flag1 = entity.verticalCollisionBelow;
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
@@ -449,19 +599,72 @@ @@ -449,20 +599,73 @@
d10 = d6 * d6 + d7 * d7 + d8 * d8; d10 = d6 * d6 + d7 * d7 + d8 * d8;
boolean flag2 = false; boolean flag2 = false;
@ -342,8 +342,8 @@
+ this.player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + this.player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
this.send(ClientboundMoveVehiclePacket.fromEntity(entity)); this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
return; return;
+ } }
+
+ // CraftBukkit start - fire PlayerMoveEvent + // CraftBukkit start - fire PlayerMoveEvent
+ Player player = this.getCraftPlayer(); + Player player = this.getCraftPlayer();
+ if (!this.hasMoved) { + if (!this.hasMoved) {
@ -392,11 +392,12 @@
+ this.justTeleported = false; + this.justTeleported = false;
+ return; + return;
+ } + }
} + }
+ // CraftBukkit end + // CraftBukkit end
+
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());
Vec3 vec3d = new Vec3(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
@@ -489,16 +692,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) {
@ -1041,7 +1042,7 @@
this.player.drop(false); this.player.drop(false);
} }
@@ -1199,6 +1773,12 @@ @@ -1199,8 +1773,34 @@
case START_DESTROY_BLOCK: case START_DESTROY_BLOCK:
case ABORT_DESTROY_BLOCK: case ABORT_DESTROY_BLOCK:
case STOP_DESTROY_BLOCK: case STOP_DESTROY_BLOCK:
@ -1051,10 +1052,32 @@
+ return; + return;
+ } + }
+ // Paper end - Don't allow digging into unloaded chunks + // Paper end - Don't allow digging into unloaded chunks
+ // Paper start - Send block entities after destroy prediction
+ this.player.gameMode.capturedBlockEntity = false;
+ this.player.gameMode.captureSentBlockEntities = true;
+ // Paper end - Send block entities after destroy prediction
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());
+ // Paper start - Send block entities after destroy prediction
+ this.player.gameMode.captureSentBlockEntities = false;
+ // If a block entity was modified speedup the block change ack to avoid the block entity
+ // being overriden.
+ if (this.player.gameMode.capturedBlockEntity) {
+ // manually tick
+ this.send(new ClientboundBlockChangedAckPacket(this.ackBlockChangesUpTo));
+ this.player.connection.ackBlockChangesUpTo = -1;
+
+ this.player.gameMode.capturedBlockEntity = false;
+ BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
+ if (tileentity != null) {
+ this.player.connection.send(tileentity.getUpdatePacket());
+ }
+ }
+ // Paper end - Send block entities after destroy prediction
return; return;
@@ -1218,9 +1798,31 @@ default:
throw new IllegalArgumentException("Invalid player action");
@@ -1218,9 +1818,31 @@
} }
} }
@ -1086,7 +1109,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 +1832,11 @@ @@ -1230,6 +1852,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();
@ -1098,7 +1121,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 +1850,8 @@ @@ -1243,7 +1870,8 @@
int i = this.player.level().getMaxY(); int i = this.player.level().getMaxY();
if (blockposition.getY() <= i) { if (blockposition.getY() <= i) {
@ -1108,7 +1131,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 +1865,7 @@ @@ -1257,7 +1885,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;
@ -1117,7 +1140,7 @@
this.player.swing(enumhand, true); this.player.swing(enumhand, true);
} }
} }
@@ -1281,6 +1889,8 @@ @@ -1281,6 +1909,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());
@ -1126,12 +1149,10 @@
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();
@@ -1294,8 +1904,49 @@ @@ -1296,6 +1926,47 @@
if (f1 != this.player.getXRot() || f != this.player.getYRot()) {
this.player.absRotateTo(f, f1); 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();
@ -1162,8 +1183,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;
@ -1176,7 +1197,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 +1972,7 @@ @@ -1321,7 +1992,7 @@
Entity entity = packet.getEntity(worldserver); Entity entity = packet.getEntity(worldserver);
if (entity != null) { if (entity != null) {
@ -1185,7 +1206,7 @@
return; return;
} }
} }
@@ -1342,17 +1993,46 @@ @@ -1342,17 +2013,46 @@
@Override @Override
public void onDisconnect(DisconnectionDetails info) { public void onDisconnect(DisconnectionDetails info) {
@ -1236,7 +1257,7 @@
this.player.getTextFilter().leave(); this.player.getTextFilter().leave();
} }
@@ -1367,7 +2047,17 @@ @@ -1367,7 +2067,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());
@ -1254,7 +1275,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 +2066,18 @@ @@ -1376,11 +2086,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());
@ -1273,7 +1294,7 @@
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages());
if (!optional.isEmpty()) { if (!optional.isEmpty()) {
@@ -1394,27 +2091,44 @@ @@ -1394,27 +2111,44 @@
return; return;
} }
@ -1325,7 +1346,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 +2145,37 @@ @@ -1431,19 +2165,37 @@
if (!optional.isEmpty()) { if (!optional.isEmpty()) {
this.tryHandleChat(packet.command(), () -> { this.tryHandleChat(packet.command(), () -> {
@ -1367,7 +1388,7 @@
} catch (SignedMessageChain.DecodeException signedmessagechain_a) { } catch (SignedMessageChain.DecodeException signedmessagechain_a) {
this.handleMessageDecodeFailure(signedmessagechain_a); this.handleMessageDecodeFailure(signedmessagechain_a);
return; return;
@@ -1451,10 +2183,10 @@ @@ -1451,10 +2203,10 @@
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map); CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
@ -1380,7 +1401,7 @@
} }
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
@@ -1530,14 +2262,20 @@ @@ -1530,14 +2282,20 @@
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack()); return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
} }
@ -1406,7 +1427,7 @@
} }
} }
@@ -1549,7 +2287,7 @@ @@ -1549,7 +2307,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());
@ -1415,7 +1436,7 @@
} }
return optional; return optional;
@@ -1566,6 +2304,127 @@ @@ -1566,6 +2324,127 @@
return false; return false;
} }
@ -1543,7 +1564,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 +2432,44 @@ @@ -1573,15 +2452,44 @@
} }
private void broadcastChatMessage(PlayerChatMessage message) { private void broadcastChatMessage(PlayerChatMessage message) {
@ -1594,7 +1615,7 @@
} }
@@ -1592,7 +2480,7 @@ @@ -1592,7 +2500,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());
@ -1603,7 +1624,7 @@
} }
} }
@@ -1601,7 +2489,40 @@ @@ -1601,7 +2509,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());
@ -1644,7 +1665,7 @@
this.player.swing(packet.getHand()); this.player.swing(packet.getHand());
} }
@@ -1609,6 +2530,29 @@ @@ -1609,6 +2550,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()) {
@ -1674,7 +1695,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
Entity entity; Entity entity;
PlayerRideableJumping ijumpable; PlayerRideableJumping ijumpable;
@@ -1616,6 +2560,11 @@ @@ -1616,6 +2580,11 @@
switch (packet.getAction()) { switch (packet.getAction()) {
case PRESS_SHIFT_KEY: case PRESS_SHIFT_KEY:
this.player.setShiftKeyDown(true); this.player.setShiftKeyDown(true);
@ -1686,7 +1707,7 @@
break; break;
case RELEASE_SHIFT_KEY: case RELEASE_SHIFT_KEY:
this.player.setShiftKeyDown(false); this.player.setShiftKeyDown(false);
@@ -1684,13 +2633,19 @@ @@ -1684,13 +2653,19 @@
} }
if (i > 4096) { if (i > 4096) {
@ -1707,7 +1728,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 +2658,18 @@ @@ -1703,6 +2678,18 @@
return this.connection.getRemoteAddress(); return this.connection.getRemoteAddress();
} }
@ -1726,7 +1747,7 @@
public void switchToConfig() { public void switchToConfig() {
this.waitingForSwitchToConfig = true; this.waitingForSwitchToConfig = true;
this.removePlayerFromWorld(); this.removePlayerFromWorld();
@@ -1718,9 +2685,17 @@ @@ -1718,9 +2705,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());
@ -1744,7 +1765,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
@@ -1733,20 +2708,58 @@ @@ -1733,20 +2728,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() {
@ -1807,7 +1828,7 @@
} }
} }
@@ -1755,19 +2768,20 @@ @@ -1755,19 +2788,20 @@
@Override @Override
public void onInteraction(InteractionHand hand) { public void onInteraction(InteractionHand hand) {
@ -1831,7 +1852,7 @@
label23: label23:
{ {
if (entity instanceof AbstractArrow) { if (entity instanceof AbstractArrow) {
@@ -1785,17 +2799,41 @@ @@ -1785,17 +2819,41 @@
} }
ServerGamePacketListenerImpl.this.player.attack(entity); ServerGamePacketListenerImpl.this.player.attack(entity);
@ -1874,7 +1895,7 @@
} }
} }
@@ -1809,7 +2847,7 @@ @@ -1809,7 +2867,7 @@
case PERFORM_RESPAWN: case PERFORM_RESPAWN:
if (this.player.wonGame) { if (this.player.wonGame) {
this.player.wonGame = false; this.player.wonGame = false;
@ -1883,7 +1904,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 +2855,11 @@ @@ -1817,11 +2875,11 @@
return; return;
} }
@ -1898,7 +1919,7 @@
} }
} }
break; break;
@@ -1833,16 +2871,27 @@ @@ -1833,16 +2891,27 @@
@Override @Override
public void handleContainerClose(ServerboundContainerClosePacket packet) { public void handleContainerClose(ServerboundContainerClosePacket packet) {
@ -1928,7 +1949,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 +2904,284 @@ @@ -1855,7 +2924,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();
@ -2214,7 +2235,7 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator(); ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
@@ -1879,6 +3205,14 @@ @@ -1879,6 +3225,14 @@
@Override @Override
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
@ -2229,7 +2250,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 +3234,43 @@ @@ -1900,9 +3254,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;
} }
@ -2274,7 +2295,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 +3285,7 @@ @@ -1917,6 +3305,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());
@ -2282,7 +2303,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 +3314,43 @@ @@ -1945,6 +3334,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();
@ -2326,7 +2347,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 +3370,19 @@ @@ -1964,7 +3390,19 @@
@Override @Override
public void handleSignUpdate(ServerboundSignUpdatePacket packet) { public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
@ -2347,7 +2368,7 @@
this.filterTextPacket(list).thenAcceptAsync((list1) -> { this.filterTextPacket(list).thenAcceptAsync((list1) -> {
this.updateSignText(packet, list1); this.updateSignText(packet, list1);
@@ -1972,6 +3390,7 @@ @@ -1972,6 +3410,7 @@
} }
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) { private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
@ -2355,7 +2376,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 +3412,33 @@ @@ -1993,15 +3432,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());
@ -2390,7 +2411,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 +3449,7 @@ @@ -2012,7 +3469,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()) {
@ -2399,7 +2420,7 @@
} }
} }
@@ -2033,7 +3470,7 @@ @@ -2033,7 +3490,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())) {
@ -2408,7 +2429,7 @@
} else { } else {
try { try {
SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator(); SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator();
@@ -2046,7 +3483,7 @@ @@ -2046,7 +3503,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());
@ -2417,7 +2438,7 @@
} }
} }
@@ -2058,7 +3495,7 @@ @@ -2058,7 +3515,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 {
@ -2426,7 +2447,7 @@
} }
} }
@@ -2083,8 +3520,10 @@ @@ -2083,8 +3540,10 @@
}); });
} }