Properly resend entities
This resolves some issues which caused entities to not be resent correctly. Entities that are interacted with need to be resent to the client, so we resend all the entity data to the player whilst making sure not to clear dirty entries from the tracker. This makes sure that values will be correctly updated to other players. This also adds utilities to aid in further preventing entity desyncs. This also also fixes the bug causing cancelling PlayerInteractEvent to cause items to continue to be used despite being cancelled on the server. For example, items being consumed but never finishing, shields being put up, etc. The underlying issue of this is that the client modifies their synced data values, and so we have to (forcibly) resend them in order for the client to reset their using item state. See: https://github.com/PaperMC/Paper/pull/1896 == AT == public net.minecraft.server.level.ChunkMap$TrackedEntity serverEntity
This commit is contained in:
@@ -135,9 +135,9 @@
|
||||
+ // Update any tile entity data for this block
|
||||
+ 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()) {
|
||||
@@ -145,10 +145,10 @@
|
||||
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Paper - Don't resync blocks
|
||||
+ // Update any tile entity data for this block
|
||||
+ capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
|
||||
return;
|
||||
}
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
if (this.isCreative()) {
|
||||
this.destroyAndAck(pos, sequence, "creative destroy");
|
||||
return;
|
||||
@@ -374,7 +374,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,17 +514,62 @@
|
||||
@@ -321,17 +514,63 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,6 +431,7 @@
|
||||
+ }
|
||||
+ // Paper end - extend Player Interact cancellation
|
||||
+ player.getBukkitEntity().updateInventory(); // SPIGOT-2867
|
||||
+ this.player.resyncUsingItem(this.player); // Paper - Properly cancel usable items
|
||||
+ return (event.useItemInHand() != Event.Result.ALLOW) ? InteractionResult.SUCCESS : InteractionResult.PASS;
|
||||
+ } else if (this.gameModeForPlayer == GameType.SPECTATOR) {
|
||||
+ MenuProvider itileinventory = iblockdata.getMenuProvider(world, blockposition);
|
||||
@@ -439,7 +440,7 @@
|
||||
return InteractionResult.CONSUME;
|
||||
} else {
|
||||
return InteractionResult.PASS;
|
||||
@@ -359,7 +597,7 @@
|
||||
@@ -359,7 +598,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,3 +449,15 @@
|
||||
UseOnContext itemactioncontext = new UseOnContext(player, hand, hitResult);
|
||||
|
||||
if (this.isCreative()) {
|
||||
@@ -377,6 +616,11 @@
|
||||
|
||||
return enuminteractionresult;
|
||||
} else {
|
||||
+ // Paper start - Properly cancel usable items; Cancel only if cancelled + if the interact result is different from default response
|
||||
+ if (this.interactResult && this.interactResult != cancelledItem) {
|
||||
+ this.player.resyncUsingItem(this.player);
|
||||
+ }
|
||||
+ // Paper end - Properly cancel usable items
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -192,12 +196,73 @@
|
||||
@@ -192,11 +196,72 @@
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
@@ -59,7 +59,7 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+
|
||||
+// CraftBukkit start
|
||||
+import io.papermc.paper.adventure.ChatProcessor; // Paper
|
||||
+import io.papermc.paper.adventure.PaperAdventure; // Paper
|
||||
@@ -118,10 +118,9 @@
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+import org.bukkit.inventory.SmithingInventory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
|
||||
public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -212,7 +277,9 @@
|
||||
private int tickCount;
|
||||
private int ackBlockChangesUpTo = -1;
|
||||
@@ -339,7 +338,7 @@
|
||||
boolean flag1 = entity.verticalCollisionBelow;
|
||||
|
||||
if (entity instanceof LivingEntity) {
|
||||
@@ -449,20 +607,73 @@
|
||||
@@ -449,19 +607,72 @@
|
||||
d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
boolean flag2 = false;
|
||||
|
||||
@@ -358,8 +357,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) {
|
||||
@@ -408,12 +407,11 @@
|
||||
+ 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 +700,17 @@
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (packet.getId() == this.awaitingTeleport) {
|
||||
@@ -1264,7 +1262,7 @@
|
||||
if (this.player.hasClientLoaded()) {
|
||||
this.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1296,6 +1993,47 @@
|
||||
@@ -1296,6 +1993,48 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
|
||||
@@ -1301,6 +1299,7 @@
|
||||
+ }
|
||||
+
|
||||
+ if (cancelled) {
|
||||
+ this.player.resyncUsingItem(this.player); // Paper - Properly cancel usable items
|
||||
+ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
|
||||
+ return;
|
||||
+ }
|
||||
@@ -1312,7 +1311,7 @@
|
||||
InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult instanceof InteractionResult.Success) {
|
||||
@@ -1321,7 +2059,7 @@
|
||||
@@ -1321,7 +2060,7 @@
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
@@ -1321,7 +1320,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1342,22 +2080,52 @@
|
||||
@@ -1342,22 +2081,52 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectionDetails info) {
|
||||
@@ -1378,7 +1377,7 @@
|
||||
throw new IllegalArgumentException("Expected packet sequence nr >= 0");
|
||||
} else {
|
||||
this.ackBlockChangesUpTo = Math.max(sequence, this.ackBlockChangesUpTo);
|
||||
@@ -1367,7 +2135,17 @@
|
||||
@@ -1367,7 +2136,17 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1396,7 +1395,7 @@
|
||||
if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1376,11 +2154,18 @@
|
||||
@@ -1376,11 +2155,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
@@ -1415,7 +1414,7 @@
|
||||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1394,27 +2179,46 @@
|
||||
@@ -1394,27 +2180,46 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1469,7 +1468,7 @@
|
||||
ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1431,30 +2235,58 @@
|
||||
@@ -1431,30 +2236,58 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(packet.command(), () -> {
|
||||
@@ -1534,7 +1533,7 @@
|
||||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||||
@@ -1530,14 +2362,20 @@
|
||||
@@ -1530,14 +2363,20 @@
|
||||
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
|
||||
}
|
||||
|
||||
@@ -1560,7 +1559,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1549,7 +2387,7 @@
|
||||
@@ -1549,7 +2388,7 @@
|
||||
|
||||
if (optional.isEmpty()) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
||||
@@ -1569,7 +1568,7 @@
|
||||
}
|
||||
|
||||
return optional;
|
||||
@@ -1566,6 +2404,117 @@
|
||||
@@ -1566,6 +2405,117 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1687,7 +1686,7 @@
|
||||
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages);
|
||||
|
||||
@@ -1573,15 +2522,44 @@
|
||||
@@ -1573,15 +2523,44 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage message) {
|
||||
@@ -1738,7 +1737,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1592,7 +2570,7 @@
|
||||
@@ -1592,7 +2571,7 @@
|
||||
synchronized (this.lastSeenMessages) {
|
||||
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
||||
@@ -1747,7 +1746,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1601,7 +2579,40 @@
|
||||
@@ -1601,7 +2580,40 @@
|
||||
@Override
|
||||
public void handleAnimate(ServerboundSwingPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1788,7 +1787,7 @@
|
||||
this.player.swing(packet.getHand());
|
||||
}
|
||||
|
||||
@@ -1609,6 +2620,29 @@
|
||||
@@ -1609,6 +2621,29 @@
|
||||
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.hasClientLoaded()) {
|
||||
@@ -1818,7 +1817,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
PlayerRideableJumping ijumpable;
|
||||
@@ -1616,6 +2650,11 @@
|
||||
@@ -1616,6 +2651,11 @@
|
||||
switch (packet.getAction()) {
|
||||
case PRESS_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(true);
|
||||
@@ -1830,7 +1829,7 @@
|
||||
break;
|
||||
case RELEASE_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(false);
|
||||
@@ -1684,15 +2723,25 @@
|
||||
@@ -1684,15 +2724,25 @@
|
||||
}
|
||||
|
||||
if (i > 4096) {
|
||||
@@ -1857,7 +1856,7 @@
|
||||
}
|
||||
|
||||
public void sendDisguisedChatMessage(Component message, ChatType.Bound params) {
|
||||
@@ -1703,6 +2752,18 @@
|
||||
@@ -1703,6 +2753,18 @@
|
||||
return this.connection.getRemoteAddress();
|
||||
}
|
||||
|
||||
@@ -1876,7 +1875,7 @@
|
||||
public void switchToConfig() {
|
||||
this.waitingForSwitchToConfig = true;
|
||||
this.removePlayerFromWorld();
|
||||
@@ -1718,9 +2779,17 @@
|
||||
@@ -1718,9 +2780,17 @@
|
||||
@Override
|
||||
public void handleInteract(ServerboundInteractPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1894,7 +1893,7 @@
|
||||
|
||||
this.player.resetLastActionTime();
|
||||
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
|
||||
@@ -1731,22 +2800,61 @@
|
||||
@@ -1731,22 +2801,61 @@
|
||||
|
||||
AABB axisalignedbb = entity.getBoundingBox();
|
||||
|
||||
@@ -1918,7 +1917,7 @@
|
||||
+
|
||||
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
||||
+ if ((entity instanceof Bucketable && entity instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ entity.getBukkitEntity().update(ServerGamePacketListenerImpl.this.player);
|
||||
+ entity.resendPossiblyDesyncedEntityData(ServerGamePacketListenerImpl.this.player); // Paper - The entire mob gets deleted, so resend it
|
||||
+ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+
|
||||
@@ -1961,7 +1960,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1755,19 +2863,20 @@
|
||||
@@ -1755,19 +2864,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(InteractionHand hand) {
|
||||
@@ -1985,7 +1984,7 @@
|
||||
label23:
|
||||
{
|
||||
if (entity instanceof AbstractArrow) {
|
||||
@@ -1785,17 +2894,41 @@
|
||||
@@ -1785,17 +2895,41 @@
|
||||
}
|
||||
|
||||
ServerGamePacketListenerImpl.this.player.attack(entity);
|
||||
@@ -2028,7 +2027,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1809,7 +2942,7 @@
|
||||
@@ -1809,7 +2943,7 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
@@ -2037,7 +2036,7 @@
|
||||
this.resetPosition();
|
||||
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
|
||||
} else {
|
||||
@@ -1817,11 +2950,11 @@
|
||||
@@ -1817,11 +2951,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2052,7 +2051,7 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1833,16 +2966,27 @@
|
||||
@@ -1833,16 +2967,27 @@
|
||||
|
||||
@Override
|
||||
public void handleContainerClose(ServerboundContainerClosePacket packet) {
|
||||
@@ -2082,7 +2081,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 +2999,315 @@
|
||||
@@ -1855,7 +3000,315 @@
|
||||
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
@@ -2399,7 +2398,7 @@
|
||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1879,6 +3331,14 @@
|
||||
@@ -1879,6 +3332,14 @@
|
||||
|
||||
@Override
|
||||
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
|
||||
@@ -2414,7 +2413,7 @@
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
this.player.resetLastActionTime();
|
||||
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) {
|
||||
@@ -1900,9 +3360,43 @@
|
||||
@@ -1900,9 +3361,43 @@
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("Player {} tried to place impossible recipe {}", this.player, recipeholder.id().location());
|
||||
return;
|
||||
}
|
||||
@@ -2459,7 +2458,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 +3411,7 @@
|
||||
@@ -1917,6 +3412,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -2467,7 +2466,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1945,7 +3440,44 @@
|
||||
@@ -1945,7 +3441,44 @@
|
||||
|
||||
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
@@ -2512,7 +2511,7 @@
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
|
||||
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemstack);
|
||||
@@ -1964,7 +3496,19 @@
|
||||
@@ -1964,7 +3497,19 @@
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
|
||||
@@ -2533,7 +2532,7 @@
|
||||
|
||||
this.filterTextPacket(list).thenAcceptAsync((list1) -> {
|
||||
this.updateSignText(packet, list1);
|
||||
@@ -1972,6 +3516,7 @@
|
||||
@@ -1972,6 +3517,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
|
||||
@@ -2541,7 +2540,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
BlockPos blockposition = packet.getPos();
|
||||
@@ -1993,15 +3538,33 @@
|
||||
@@ -1993,15 +3539,33 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -2576,7 +2575,7 @@
|
||||
if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) {
|
||||
this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player));
|
||||
}
|
||||
@@ -2012,7 +3575,7 @@
|
||||
@@ -2012,7 +3576,7 @@
|
||||
public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) {
|
||||
@@ -2585,7 +2584,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2033,7 +3596,7 @@
|
||||
@@ -2033,7 +3597,7 @@
|
||||
|
||||
if (!Objects.equals(profilepublickey_a, profilepublickey_a1)) {
|
||||
if (profilepublickey_a != null && profilepublickey_a1.expiresAt().isBefore(profilepublickey_a.expiresAt())) {
|
||||
@@ -2594,7 +2593,7 @@
|
||||
} else {
|
||||
try {
|
||||
SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator();
|
||||
@@ -2045,8 +3608,8 @@
|
||||
@@ -2045,8 +3609,8 @@
|
||||
|
||||
this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator));
|
||||
} catch (ProfilePublicKey.ValidationException profilepublickey_b) {
|
||||
@@ -2605,7 +2604,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2058,7 +3621,7 @@
|
||||
@@ -2058,7 +3622,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
@@ -2614,7 +2613,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2076,15 +3639,18 @@
|
||||
@@ -2076,15 +3640,18 @@
|
||||
|
||||
private void resetPlayerChatState(RemoteChatSession session) {
|
||||
this.chatSession = session;
|
||||
@@ -2636,7 +2635,7 @@
|
||||
|
||||
@Override
|
||||
public void handleClientTickEnd(ServerboundClientTickEndPacket packet) {
|
||||
@@ -2115,4 +3681,17 @@
|
||||
@@ -2115,4 +3682,17 @@
|
||||
|
||||
InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand);
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@
|
||||
+ ((ServerLevel)player.level()).getChunkSource().chunkMap.addEntity(player); // Paper - Fire PlayerJoinEvent when Player is actually ready; track entity now
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ player.refreshEntityData(player); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
|
||||
+ //player.refreshEntityData(player); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn // Paper - THIS IS NOT NEEDED ANYMORE
|
||||
+
|
||||
+ this.sendLevelInfo(player, worldserver1);
|
||||
+
|
||||
@@ -842,7 +842,24 @@
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
@@ -516,15 +924,32 @@
|
||||
@@ -505,26 +913,48 @@
|
||||
}
|
||||
|
||||
public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl networkHandler) {
|
||||
+ // Paper start - collect packets
|
||||
+ this.sendActiveEffects(entity, networkHandler::send);
|
||||
+ }
|
||||
+ public void sendActiveEffects(LivingEntity entity, java.util.function.Consumer<Packet<? super net.minecraft.network.protocol.game.ClientGamePacketListener>> packetConsumer) {
|
||||
+ // Paper end - collect packets
|
||||
Iterator iterator = entity.getActiveEffects().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
|
||||
|
||||
- networkHandler.send(new ClientboundUpdateMobEffectPacket(entity.getId(), mobeffect, false));
|
||||
+ packetConsumer.accept(new ClientboundUpdateMobEffectPacket(entity.getId(), mobeffect, false)); // Paper - collect packets
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendPlayerPermissionLevel(ServerPlayer player) {
|
||||
@@ -877,14 +894,10 @@
|
||||
this.sendAllPlayerInfoIn = 0;
|
||||
}
|
||||
|
||||
@@ -537,9 +962,28 @@
|
||||
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
||||
@@ -541,6 +971,25 @@
|
||||
|
||||
}
|
||||
|
||||
entityplayer.connection.send(packet);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - add a world/entity limited version
|
||||
+ public void broadcastAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) {
|
||||
+ for (int i = 0; i < this.players.size(); ++i) {
|
||||
@@ -899,14 +912,15 @@
|
||||
+ public void broadcastAll(Packet packet, Level world) {
|
||||
+ for (int i = 0; i < world.players().size(); ++i) {
|
||||
+ ((ServerPlayer) world.players().get(i)).connection.send(packet);
|
||||
}
|
||||
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
|
||||
Iterator iterator = this.players.iterator();
|
||||
@@ -554,7 +998,7 @@
|
||||
|
||||
@@ -554,7 +1003,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -915,7 +929,7 @@
|
||||
PlayerTeam scoreboardteam = source.getTeam();
|
||||
|
||||
if (scoreboardteam != null) {
|
||||
@@ -573,7 +1017,7 @@
|
||||
@@ -573,7 +1022,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -924,7 +938,7 @@
|
||||
PlayerTeam scoreboardteam = source.getTeam();
|
||||
|
||||
if (scoreboardteam == null) {
|
||||
@@ -619,7 +1063,7 @@
|
||||
@@ -619,7 +1068,7 @@
|
||||
}
|
||||
|
||||
public void deop(GameProfile profile) {
|
||||
@@ -933,7 +947,7 @@
|
||||
ServerPlayer entityplayer = this.getPlayer(profile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
@@ -629,6 +1073,11 @@
|
||||
@@ -629,6 +1078,11 @@
|
||||
}
|
||||
|
||||
private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
|
||||
@@ -945,7 +959,7 @@
|
||||
if (player.connection != null) {
|
||||
byte b0;
|
||||
|
||||
@@ -643,36 +1092,53 @@
|
||||
@@ -643,36 +1097,53 @@
|
||||
player.connection.send(new ClientboundEntityEventPacket(player, b0));
|
||||
}
|
||||
|
||||
@@ -1012,7 +1026,7 @@
|
||||
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
|
||||
double d4 = x - entityplayer.getX();
|
||||
double d5 = y - entityplayer.getY();
|
||||
@@ -687,10 +1153,12 @@
|
||||
@@ -687,10 +1158,12 @@
|
||||
}
|
||||
|
||||
public void saveAll() {
|
||||
@@ -1025,7 +1039,7 @@
|
||||
}
|
||||
|
||||
public UserWhiteList getWhiteList() {
|
||||
@@ -712,15 +1180,19 @@
|
||||
@@ -712,15 +1185,19 @@
|
||||
public void reloadWhiteList() {}
|
||||
|
||||
public void sendLevelInfo(ServerPlayer player, ServerLevel world) {
|
||||
@@ -1049,7 +1063,7 @@
|
||||
}
|
||||
|
||||
player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F));
|
||||
@@ -729,8 +1201,16 @@
|
||||
@@ -729,8 +1206,16 @@
|
||||
|
||||
public void sendAllPlayerInfo(ServerPlayer player) {
|
||||
player.inventoryMenu.sendAllDataToRemote();
|
||||
@@ -1067,7 +1081,7 @@
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -746,6 +1226,7 @@
|
||||
@@ -746,6 +1231,7 @@
|
||||
}
|
||||
|
||||
public void setUsingWhiteList(boolean whitelistEnabled) {
|
||||
@@ -1075,7 +1089,7 @@
|
||||
this.doWhiteList = whitelistEnabled;
|
||||
}
|
||||
|
||||
@@ -786,11 +1267,35 @@
|
||||
@@ -786,11 +1272,35 @@
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
@@ -1113,7 +1127,7 @@
|
||||
|
||||
public void broadcastSystemMessage(Component message, boolean overlay) {
|
||||
this.broadcastSystemMessage(message, (entityplayer) -> {
|
||||
@@ -819,24 +1324,43 @@
|
||||
@@ -819,24 +1329,43 @@
|
||||
}
|
||||
|
||||
public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) {
|
||||
@@ -1160,7 +1174,7 @@
|
||||
}
|
||||
|
||||
if (flag1 && sender != null) {
|
||||
@@ -845,20 +1369,27 @@
|
||||
@@ -845,20 +1374,27 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1193,7 +1207,7 @@
|
||||
Path path = file2.toPath();
|
||||
|
||||
if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -867,7 +1398,7 @@
|
||||
@@ -867,7 +1403,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatsCounter(this.server, file1);
|
||||
@@ -1202,7 +1216,7 @@
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -875,13 +1406,13 @@
|
||||
@@ -875,13 +1411,13 @@
|
||||
|
||||
public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) {
|
||||
UUID uuid = player.getUUID();
|
||||
@@ -1218,7 +1232,7 @@
|
||||
}
|
||||
|
||||
advancementdataplayer.setPlayer(player);
|
||||
@@ -932,15 +1463,39 @@
|
||||
@@ -932,15 +1468,39 @@
|
||||
}
|
||||
|
||||
public void reloadResources() {
|
||||
|
||||
Reference in New Issue
Block a user