mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
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.
This commit is contained in:
parent
103a5ea12b
commit
8a49cbc3a7
2 changed files with 107 additions and 81 deletions
|
@ -39,7 +39,16 @@
|
|||
public class ServerPlayerGameMode {
|
||||
|
||||
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) {
|
||||
|
@ -75,7 +84,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -92,12 +125,12 @@
|
||||
@@ -92,12 +127,12 @@
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
|
@ -91,7 +100,7 @@
|
|||
this.hasDelayedDestroy = false;
|
||||
} else {
|
||||
float f = this.incrementDestroyProgress(iblockdata, this.delayedDestroyPos, this.delayedTickStart);
|
||||
@@ -108,7 +141,13 @@
|
||||
@@ -108,7 +143,13 @@
|
||||
}
|
||||
}
|
||||
} else if (this.isDestroyingBlock) {
|
||||
|
@ -106,7 +115,7 @@
|
|||
if (iblockdata.isAir()) {
|
||||
this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -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) {
|
||||
if (!this.player.canInteractWithBlock(pos, 1.0D)) {
|
||||
|
@ -114,7 +123,7 @@
|
|||
this.debugLogging(pos, false, sequence, "too far");
|
||||
} else if (pos.getY() > worldHeight) {
|
||||
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 (!this.level.mayInteract(this.player, pos)) {
|
||||
|
@ -123,28 +132,22 @@
|
|||
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
|
||||
this.debugLogging(pos, false, sequence, "may not interact");
|
||||
+ // Update any tile entity data for this block
|
||||
+ BlockEntity tileentity = this.level.getBlockEntity(pos);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.connection.send(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
|
||||
+ // CraftBukkit end
|
||||
return;
|
||||
}
|
||||
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
||||
+ // Update any tile entity data for this block
|
||||
+ BlockEntity tileentity = this.level.getBlockEntity(pos);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.connection.send(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
|
||||
return;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
if (this.isCreative()) {
|
||||
this.destroyAndAck(pos, sequence, "creative destroy");
|
||||
return;
|
||||
|
@ -161,7 +164,7 @@
|
|||
if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) {
|
||||
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
|
||||
this.debugLogging(pos, false, sequence, "block action restricted");
|
||||
@@ -166,7 +236,19 @@
|
||||
@@ -166,7 +232,19 @@
|
||||
float f = 1.0F;
|
||||
|
||||
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) -> {
|
||||
this.player.onEquippedItemBroken(item, EquipmentSlot.MAINHAND);
|
||||
});
|
||||
@@ -174,6 +256,26 @@
|
||||
@@ -174,6 +252,26 @@
|
||||
f = iblockdata.getDestroyProgress(this.player, this.player.level(), pos);
|
||||
}
|
||||
|
||||
|
@ -209,7 +212,7 @@
|
|||
if (!iblockdata.isAir() && f >= 1.0F) {
|
||||
this.destroyAndAck(pos, sequence, "insta mine");
|
||||
} else {
|
||||
@@ -217,14 +319,18 @@
|
||||
@@ -217,14 +315,18 @@
|
||||
this.debugLogging(pos, true, sequence, "stopped destroying");
|
||||
} else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) {
|
||||
this.isDestroyingBlock = false;
|
||||
|
@ -232,7 +235,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -242,19 +348,78 @@
|
||||
@@ -242,19 +344,80 @@
|
||||
|
||||
public boolean destroyBlock(BlockPos pos) {
|
||||
BlockState iblockdata = this.level.getBlockState(pos);
|
||||
|
@ -282,10 +285,12 @@
|
|||
+ }
|
||||
+
|
||||
+ // Update any tile entity data for this block
|
||||
+ if (!captureSentBlockEntities) { // Paper - Send block entities after destroy prediction
|
||||
+ BlockEntity tileentity = this.level.getBlockEntity(pos);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.connection.send(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ } else {capturedBlockEntity = true;} // Paper - Send block entities after destroy prediction
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
|
@ -313,7 +318,7 @@
|
|||
BlockState iblockdata1 = block.playerWillDestroy(this.level, pos, iblockdata, this.player);
|
||||
boolean flag = this.level.removeBlock(pos, false);
|
||||
|
||||
@@ -262,20 +427,46 @@
|
||||
@@ -262,20 +425,46 @@
|
||||
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) {
|
||||
player.openMenu(itileinventory);
|
||||
return InteractionResult.CONSUME;
|
||||
@@ -359,7 +593,7 @@
|
||||
@@ -359,7 +591,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -323,7 +323,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;
|
||||
|
||||
|
@ -342,8 +342,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) {
|
||||
|
@ -392,11 +392,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) {
|
||||
|
@ -1041,7 +1042,7 @@
|
|||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1199,6 +1773,12 @@
|
||||
@@ -1199,8 +1773,34 @@
|
||||
case START_DESTROY_BLOCK:
|
||||
case ABORT_DESTROY_BLOCK:
|
||||
case STOP_DESTROY_BLOCK:
|
||||
|
@ -1051,10 +1052,32 @@
|
|||
+ return;
|
||||
+ }
|
||||
+ // 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.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;
|
||||
@@ -1218,9 +1798,31 @@
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid player action");
|
||||
@@ -1218,9 +1818,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1086,7 +1109,7 @@
|
|||
if (this.player.hasClientLoaded()) {
|
||||
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1230,6 +1832,11 @@
|
||||
@@ -1230,6 +1852,11 @@
|
||||
if (itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
||||
BlockHitResult movingobjectpositionblock = packet.getHitResult();
|
||||
Vec3 vec3d = movingobjectpositionblock.getLocation();
|
||||
|
@ -1098,7 +1121,7 @@
|
|||
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
||||
|
||||
if (this.player.canInteractWithBlock(blockposition, 1.0D)) {
|
||||
@@ -1243,7 +1850,8 @@
|
||||
@@ -1243,7 +1870,8 @@
|
||||
int i = this.player.level().getMaxY();
|
||||
|
||||
if (blockposition.getY() <= i) {
|
||||
|
@ -1108,7 +1131,7 @@
|
|||
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1257,7 +1865,7 @@
|
||||
@@ -1257,7 +1885,7 @@
|
||||
} else if (enuminteractionresult instanceof InteractionResult.Success) {
|
||||
InteractionResult.Success enuminteractionresult_d = (InteractionResult.Success) enuminteractionresult;
|
||||
|
||||
|
@ -1117,7 +1140,7 @@
|
|||
this.player.swing(enumhand, true);
|
||||
}
|
||||
}
|
||||
@@ -1281,6 +1889,8 @@
|
||||
@@ -1281,6 +1909,8 @@
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1126,12 +1149,10 @@
|
|||
if (this.player.hasClientLoaded()) {
|
||||
this.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1294,8 +1904,49 @@
|
||||
|
||||
if (f1 != this.player.getXRot() || f != this.player.getYRot()) {
|
||||
@@ -1296,6 +1926,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ // Raytrace to look for 'rogue armswings'
|
||||
+ double d0 = this.player.getX();
|
||||
|
@ -1162,8 +1183,8 @@
|
|||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ }
|
||||
+ this.player.gameMode.firedInteract = false;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ if (cancelled) {
|
||||
+ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
|
||||
+ return;
|
||||
|
@ -1176,7 +1197,7 @@
|
|||
InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult instanceof InteractionResult.Success) {
|
||||
@@ -1321,7 +1972,7 @@
|
||||
@@ -1321,7 +1992,7 @@
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
|
@ -1185,7 +1206,7 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
@@ -1342,17 +1993,46 @@
|
||||
@@ -1342,17 +2013,46 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectionDetails info) {
|
||||
|
@ -1236,7 +1257,7 @@
|
|||
this.player.getTextFilter().leave();
|
||||
}
|
||||
|
||||
@@ -1367,7 +2047,17 @@
|
||||
@@ -1367,7 +2067,17 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1254,7 +1275,7 @@
|
|||
if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1376,11 +2066,18 @@
|
||||
@@ -1376,11 +2086,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
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());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1394,27 +2091,44 @@
|
||||
@@ -1394,27 +2111,44 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1325,7 +1346,7 @@
|
|||
ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1431,19 +2145,37 @@
|
||||
@@ -1431,19 +2165,37 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(packet.command(), () -> {
|
||||
|
@ -1367,7 +1388,7 @@
|
|||
} catch (SignedMessageChain.DecodeException signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1451,10 +2183,10 @@
|
||||
@@ -1451,10 +2203,10 @@
|
||||
|
||||
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
|
||||
|
||||
|
@ -1380,7 +1401,7 @@
|
|||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||||
@@ -1530,14 +2262,20 @@
|
||||
@@ -1530,14 +2282,20 @@
|
||||
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()) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
||||
|
@ -1415,7 +1436,7 @@
|
|||
}
|
||||
|
||||
return optional;
|
||||
@@ -1566,6 +2304,127 @@
|
||||
@@ -1566,6 +2324,127 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1543,7 +1564,7 @@
|
|||
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages);
|
||||
|
||||
@@ -1573,15 +2432,44 @@
|
||||
@@ -1573,15 +2452,44 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage message) {
|
||||
|
@ -1594,7 +1615,7 @@
|
|||
|
||||
}
|
||||
|
||||
@@ -1592,7 +2480,7 @@
|
||||
@@ -1592,7 +2500,7 @@
|
||||
synchronized (this.lastSeenMessages) {
|
||||
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
|
||||
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
|
||||
public void handleAnimate(ServerboundSwingPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1644,7 +1665,7 @@
|
|||
this.player.swing(packet.getHand());
|
||||
}
|
||||
|
||||
@@ -1609,6 +2530,29 @@
|
||||
@@ -1609,6 +2550,29 @@
|
||||
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.hasClientLoaded()) {
|
||||
|
@ -1674,7 +1695,7 @@
|
|||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
PlayerRideableJumping ijumpable;
|
||||
@@ -1616,6 +2560,11 @@
|
||||
@@ -1616,6 +2580,11 @@
|
||||
switch (packet.getAction()) {
|
||||
case PRESS_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(true);
|
||||
|
@ -1686,7 +1707,7 @@
|
|||
break;
|
||||
case RELEASE_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(false);
|
||||
@@ -1684,13 +2633,19 @@
|
||||
@@ -1684,13 +2653,19 @@
|
||||
}
|
||||
|
||||
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.addPendingMessage(message);
|
||||
}
|
||||
@@ -1703,6 +2658,18 @@
|
||||
@@ -1703,6 +2678,18 @@
|
||||
return this.connection.getRemoteAddress();
|
||||
}
|
||||
|
||||
|
@ -1726,7 +1747,7 @@
|
|||
public void switchToConfig() {
|
||||
this.waitingForSwitchToConfig = true;
|
||||
this.removePlayerFromWorld();
|
||||
@@ -1718,9 +2685,17 @@
|
||||
@@ -1718,9 +2705,17 @@
|
||||
@Override
|
||||
public void handleInteract(ServerboundInteractPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1744,7 +1765,7 @@
|
|||
|
||||
this.player.resetLastActionTime();
|
||||
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
|
||||
@@ -1733,20 +2708,58 @@
|
||||
@@ -1733,20 +2728,58 @@
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
||||
|
@ -1807,7 +1828,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1755,19 +2768,20 @@
|
||||
@@ -1755,19 +2788,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(InteractionHand hand) {
|
||||
|
@ -1831,7 +1852,7 @@
|
|||
label23:
|
||||
{
|
||||
if (entity instanceof AbstractArrow) {
|
||||
@@ -1785,17 +2799,41 @@
|
||||
@@ -1785,17 +2819,41 @@
|
||||
}
|
||||
|
||||
ServerGamePacketListenerImpl.this.player.attack(entity);
|
||||
|
@ -1874,7 +1895,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1809,7 +2847,7 @@
|
||||
@@ -1809,7 +2867,7 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
|
@ -1883,7 +1904,7 @@
|
|||
this.resetPosition();
|
||||
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
|
||||
} else {
|
||||
@@ -1817,11 +2855,11 @@
|
||||
@@ -1817,11 +2875,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1898,7 +1919,7 @@
|
|||
}
|
||||
}
|
||||
break;
|
||||
@@ -1833,16 +2871,27 @@
|
||||
@@ -1833,16 +2891,27 @@
|
||||
|
||||
@Override
|
||||
public void handleContainerClose(ServerboundContainerClosePacket packet) {
|
||||
|
@ -1928,7 +1949,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 +2904,284 @@
|
||||
@@ -1855,7 +2924,284 @@
|
||||
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
|
@ -2214,7 +2235,7 @@
|
|||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1879,6 +3205,14 @@
|
||||
@@ -1879,6 +3225,14 @@
|
||||
|
||||
@Override
|
||||
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
|
||||
|
@ -2229,7 +2250,7 @@
|
|||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
this.player.resetLastActionTime();
|
||||
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());
|
||||
return;
|
||||
}
|
||||
|
@ -2274,7 +2295,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 +3285,7 @@
|
||||
@@ -1917,6 +3305,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -2282,7 +2303,7 @@
|
|||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1945,6 +3314,43 @@
|
||||
@@ -1945,6 +3334,43 @@
|
||||
|
||||
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
|
@ -2326,7 +2347,7 @@
|
|||
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
|
||||
@@ -1964,7 +3370,19 @@
|
||||
@@ -1964,7 +3390,19 @@
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
|
||||
|
@ -2347,7 +2368,7 @@
|
|||
|
||||
this.filterTextPacket(list).thenAcceptAsync((list1) -> {
|
||||
this.updateSignText(packet, list1);
|
||||
@@ -1972,6 +3390,7 @@
|
||||
@@ -1972,6 +3410,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
|
||||
|
@ -2355,7 +2376,7 @@
|
|||
this.player.resetLastActionTime();
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
BlockPos blockposition = packet.getPos();
|
||||
@@ -1993,15 +3412,33 @@
|
||||
@@ -1993,15 +3432,33 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -2390,7 +2411,7 @@
|
|||
if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) {
|
||||
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) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
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 (profilepublickey_a != null && profilepublickey_a1.expiresAt().isBefore(profilepublickey_a.expiresAt())) {
|
||||
|
@ -2408,7 +2429,7 @@
|
|||
} else {
|
||||
try {
|
||||
SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator();
|
||||
@@ -2046,7 +3483,7 @@
|
||||
@@ -2046,7 +3503,7 @@
|
||||
this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator));
|
||||
} catch (ProfilePublicKey.ValidationException profilepublickey_b) {
|
||||
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) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
|
@ -2426,7 +2447,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -2083,8 +3520,10 @@
|
||||
@@ -2083,8 +3540,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue