diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java.patch similarity index 75% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java.patch index 4967c17ea2..dad6ace870 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java -@@ -29,7 +29,7 @@ +@@ -29,7 +_,7 @@ - public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity, BiFunction nbtGetter) { + public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity, BiFunction dataGetter) { RegistryAccess registryAccess = blockEntity.getLevel().registryAccess(); -- return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), nbtGetter.apply(blockEntity, registryAccess)); -+ return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), blockEntity.sanitizeSentNbt(nbtGetter.apply(blockEntity, registryAccess))); // Paper - Sanitize sent data +- return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), dataGetter.apply(blockEntity, registryAccess)); ++ return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), blockEntity.sanitizeSentNbt(dataGetter.apply(blockEntity, registryAccess))); // Paper - Sanitize sent data } public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) { diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch similarity index 78% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch index 1a14cb1295..5eb9a5a4eb 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java -@@ -36,6 +36,21 @@ - this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.decode(buf); +@@ -35,6 +_,20 @@ + this.items = ItemStack.OPTIONAL_LIST_STREAM_CODEC.decode(buffer); + this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.decode(buffer); } - + // Paper start - Handle large packets disconnecting client + @Override + public boolean hasLargePacketFallback() { @@ -18,7 +18,6 @@ + return true; + } + // Paper end - Handle large packets disconnecting client -+ - private void write(RegistryFriendlyByteBuf buf) { - buf.writeContainerId(this.containerId); - buf.writeVarInt(this.stateId); + + private void write(RegistryFriendlyByteBuf buffer) { + buffer.writeContainerId(this.containerId); diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch similarity index 97% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch index a1740eccbe..9e7c36741a 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java -@@ -30,8 +30,10 @@ +@@ -31,8 +_,10 @@ } public ClientboundInitializeBorderPacket(WorldBorder worldBorder) { diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch similarity index 54% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch index 26f8a0aa6a..0ffb3dd705 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -52,7 +52,7 @@ +@@ -52,7 +_,7 @@ throw new RuntimeException("Can't read heightmap in packet for [" + x + ", " + z + "]"); } else { - int i = buf.readVarInt(); -- if (i > 2097152) { -+ if (i > 2097152) { // Paper - diff on change - if this changes, update PacketEncoder + int varInt = buffer.readVarInt(); +- if (varInt > 2097152) { ++ if (varInt > 2097152) { // Paper - diff on change - if this changes, update PacketEncoder throw new RuntimeException("Chunk Packet trying to allocate too much memory on read."); } else { - this.buffer = new byte[i]; -@@ -154,6 +154,7 @@ - CompoundTag compoundTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess()); + this.buffer = new byte[varInt]; +@@ -154,6 +_,7 @@ + CompoundTag updateTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess()); BlockPos blockPos = blockEntity.getBlockPos(); int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ()); -+ blockEntity.sanitizeSentNbt(compoundTag); // Paper - Sanitize sent data - return new ClientboundLevelChunkPacketData.BlockEntityInfo(i, blockPos.getY(), blockEntity.getType(), compoundTag.isEmpty() ? null : compoundTag); ++ blockEntity.sanitizeSentNbt(updateTag); // Paper - Sanitize sent data + return new ClientboundLevelChunkPacketData.BlockEntityInfo(i, blockPos.getY(), blockEntity.getType(), updateTag.isEmpty() ? null : updateTag); } } diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch similarity index 84% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch index edb5b971ee..131ab3783d 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java +++ b/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java -@@ -38,7 +38,18 @@ +@@ -38,6 +_,17 @@ this.actions = EnumSet.of(action); this.entries = List.of(new ClientboundPlayerInfoUpdatePacket.Entry(player)); } @@ -9,20 +9,19 @@ + this.actions = actions; + this.entries = entries; + } - ++ + public ClientboundPlayerInfoUpdatePacket(EnumSet actions, ClientboundPlayerInfoUpdatePacket.Entry entry) { + this.actions = actions; + this.entries = List.of(entry); + } + // Paper end - Add Listing API for Player -+ - public static ClientboundPlayerInfoUpdatePacket createPlayerInitializing(Collection players) { - EnumSet enumSet = EnumSet.of( - ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, -@@ -53,6 +64,46 @@ - return new ClientboundPlayerInfoUpdatePacket(enumSet, players); - } + public static ClientboundPlayerInfoUpdatePacket createPlayerInitializing(Collection players) { + EnumSet set = EnumSet.of( +@@ -52,6 +_,46 @@ + ); + return new ClientboundPlayerInfoUpdatePacket(set, players); + } + // Paper start - Add Listing API for Player + public static ClientboundPlayerInfoUpdatePacket createPlayerInitializing(Collection players, ServerPlayer forPlayer) { + final EnumSet enumSet = EnumSet.of( @@ -63,14 +62,14 @@ + return new ClientboundPlayerInfoUpdatePacket(enumSet, new ClientboundPlayerInfoUpdatePacket.Entry(playerInfoId, listed)); + } + // Paper end - Add Listing API for Player - private ClientboundPlayerInfoUpdatePacket(RegistryFriendlyByteBuf buf) { - this.actions = buf.readEnumSet(ClientboundPlayerInfoUpdatePacket.Action.class); - this.entries = buf.readList(buf2 -> { -@@ -116,7 +167,15 @@ + + private ClientboundPlayerInfoUpdatePacket(RegistryFriendlyByteBuf buffer) { + this.actions = buffer.readEnumSet(ClientboundPlayerInfoUpdatePacket.Action.class); +@@ -116,7 +_,15 @@ }), INITIALIZE_CHAT( - (serialized, buf) -> serialized.chatSession = buf.readNullable(RemoteChatSession.Data::read), -- (buf, entry) -> buf.writeNullable(entry.chatSession, RemoteChatSession.Data::write) + (entryBuilder, buffer) -> entryBuilder.chatSession = buffer.readNullable(RemoteChatSession.Data::read), +- (buffer, entry) -> buffer.writeNullable(entry.chatSession, RemoteChatSession.Data::write) + // Paper start - Prevent causing expired keys from impacting new joins + (buf, entry) -> { + RemoteChatSession.Data chatSession = entry.chatSession; @@ -81,9 +80,9 @@ + } + // Paper end - Prevent causing expired keys from impacting new joins ), - UPDATE_GAME_MODE((serialized, buf) -> serialized.gameMode = GameType.byId(buf.readVarInt()), (buf, entry) -> buf.writeVarInt(entry.gameMode().getId())), - UPDATE_LISTED((serialized, buf) -> serialized.listed = buf.readBoolean(), (buf, entry) -> buf.writeBoolean(entry.listed())), -@@ -157,10 +216,15 @@ + UPDATE_GAME_MODE( + (entryBuilder, buffer) -> entryBuilder.gameMode = GameType.byId(buffer.readVarInt()), +@@ -160,10 +_,15 @@ @Nullable RemoteChatSession.Data chatSession ) { Entry(ServerPlayer player) { @@ -100,7 +99,7 @@ player.connection.latency(), player.gameMode.getGameModeForPlayer(), player.getTabListDisplayName(), -@@ -169,6 +233,11 @@ +@@ -172,6 +_,11 @@ Optionull.map(player.getChatSession(), RemoteChatSession::asData) ); } diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch similarity index 52% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch index 372b4afd93..550a6f4c4b 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch @@ -1,15 +1,14 @@ --- a/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java +++ b/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java -@@ -33,11 +33,19 @@ - short short0 = (Short) shortiterator.next(); +@@ -30,10 +_,25 @@ - this.positions[j] = short0; -- this.states[j] = section.getBlockState(SectionPos.sectionRelativeX(short0), SectionPos.sectionRelativeY(short0), SectionPos.sectionRelativeZ(short0)); -+ this.states[j] = (section != null) ? section.getBlockState(SectionPos.sectionRelativeX(short0), SectionPos.sectionRelativeY(short0), SectionPos.sectionRelativeZ(short0)) : net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified + for (short s : positions) { + this.positions[i] = s; +- this.states[i] = section.getBlockState(SectionPos.sectionRelativeX(s), SectionPos.sectionRelativeY(s), SectionPos.sectionRelativeZ(s)); ++ this.states[i] = (section != null) ? section.getBlockState(SectionPos.sectionRelativeX(s), SectionPos.sectionRelativeY(s), SectionPos.sectionRelativeZ(s)) : net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified + i++; } - } - + // CraftBukkit start - Add constructor + public ClientboundSectionBlocksUpdatePacket(SectionPos sectionposition, ShortSet shortset, BlockState[] states) { + this.sectionPos = sectionposition; @@ -17,14 +16,6 @@ + this.states = states; + } + // CraftBukkit end -+ - private ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf buf) { - this.sectionPos = SectionPos.of(buf.readLong()); - int i = buf.readVarInt(); -@@ -54,6 +62,14 @@ - - } - + // Paper start - Multi Block Change API + public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap blockChanges) { + this.sectionPos = sectionPos; @@ -33,6 +24,6 @@ + } + // Paper end - Multi Block Change API + - private void write(FriendlyByteBuf buf) { - buf.writeLong(this.sectionPos.asLong()); - buf.writeVarInt(this.positions.length); + + private ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf buffer) { + this.sectionPos = SectionPos.of(buffer.readLong()); diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch similarity index 96% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch index 139eaa42d9..f228535ae7 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java -@@ -13,8 +13,10 @@ +@@ -14,8 +_,10 @@ private final double newCenterZ; public ClientboundSetBorderCenterPacket(WorldBorder worldBorder) { @@ -12,4 +12,4 @@ + // CraftBukkit end } - private ClientboundSetBorderCenterPacket(FriendlyByteBuf buf) { + private ClientboundSetBorderCenterPacket(FriendlyByteBuf buffer) { diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch new file mode 100644 index 0000000000..cb3ea7540d --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java +@@ -19,9 +_,11 @@ + } + + private static void pack(List> dataValues, RegistryFriendlyByteBuf buffer) { ++ try (io.papermc.paper.util.DataSanitizationUtil.DataSanitizer ignored = io.papermc.paper.util.DataSanitizationUtil.start(true)) { // Paper - data sanitization + for (SynchedEntityData.DataValue dataValue : dataValues) { + dataValue.write(buffer); + } ++ } // Paper - data sanitization + + buffer.writeByte(255); + } diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch new file mode 100644 index 0000000000..f02259d4dc --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java +@@ -19,6 +_,13 @@ + private final List> slots; + + public ClientboundSetEquipmentPacket(int entity, List> slots) { ++ // Paper start - data sanitization ++ this(entity, slots, false); ++ } ++ private boolean sanitize; ++ public ClientboundSetEquipmentPacket(int entity, List> slots, boolean sanitize) { ++ this.sanitize = sanitize; ++ // Paper end - data sanitization + this.entity = entity; + this.slots = slots; + } +@@ -40,6 +_,7 @@ + buffer.writeVarInt(this.entity); + int size = this.slots.size(); + ++ try (io.papermc.paper.util.DataSanitizationUtil.DataSanitizer ignored = io.papermc.paper.util.DataSanitizationUtil.start(this.sanitize)) { // Paper - data sanitization + for (int i = 0; i < size; i++) { + Pair pair = this.slots.get(i); + EquipmentSlot equipmentSlot = pair.getFirst(); +@@ -48,6 +_,7 @@ + buffer.writeByte(flag ? ordinal | -128 : ordinal); + ItemStack.OPTIONAL_STREAM_CODEC.encode(buffer, pair.getSecond()); + } ++ } // Paper - data sanitization + } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch new file mode 100644 index 0000000000..8e6ebe5e67 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java +@@ -30,6 +_,11 @@ + private final Collection players; + private final Optional parameters; + ++ // Paper start - Multiple Entries with Scoreboards ++ public static ClientboundSetPlayerTeamPacket createMultiplePlayerPacket(PlayerTeam team, Collection players, ClientboundSetPlayerTeamPacket.Action operation) { ++ return new ClientboundSetPlayerTeamPacket(team.getName(), operation == ClientboundSetPlayerTeamPacket.Action.ADD ? 3 : 4, Optional.empty(), players); ++ } ++ // Paper end - Multiple Entries with Scoreboards + private ClientboundSetPlayerTeamPacket(String name, int method, Optional parameters, Collection players) { + this.name = name; + this.method = method; +@@ -198,7 +_,7 @@ + ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.displayName); + buffer.writeByte(this.options); + buffer.writeUtf(this.nametagVisibility); +- buffer.writeUtf(this.collisionRule); ++ buffer.writeUtf(!io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? "never" : this.collisionRule); // Paper - Configurable player collision + buffer.writeEnum(this.color); + ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.playerPrefix); + ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.playerSuffix); diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch similarity index 68% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch index 64187dddbd..5d012097a1 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java -@@ -1,3 +1,4 @@ +@@ -1,3 +_,4 @@ +// mc-dev import package net.minecraft.network.protocol.game; import net.minecraft.network.RegistryFriendlyByteBuf; -@@ -12,6 +13,17 @@ - - public static final StreamCodec STREAM_CODEC = StreamCodec.composite(ComponentSerialization.TRUSTED_STREAM_CODEC, ClientboundSystemChatPacket::content, ByteBufCodecs.BOOL, ClientboundSystemChatPacket::overlay, ClientboundSystemChatPacket::new); - +@@ -16,6 +_,16 @@ + ClientboundSystemChatPacket::overlay, + ClientboundSystemChatPacket::new + ); + // Spigot start + public ClientboundSystemChatPacket(net.md_5.bungee.api.chat.BaseComponent[] content, boolean overlay) { + this(org.bukkit.craftbukkit.util.CraftChatMessage.fromJSON(net.md_5.bungee.chat.ComponentSerializer.toString(content)), overlay); @@ -19,7 +19,6 @@ + this(io.papermc.paper.adventure.PaperAdventure.asVanilla(content), overlay); + } + // Paper end -+ + @Override public PacketType type() { - return GamePacketTypes.CLIENTBOUND_SYSTEM_CHAT; diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java.patch similarity index 52% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java.patch index 1771a837ae..3161af3164 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java -@@ -19,7 +19,7 @@ +@@ -19,7 +_,7 @@ - private ServerboundCommandSuggestionPacket(FriendlyByteBuf buf) { - this.id = buf.readVarInt(); -- this.command = buf.readUtf(32500); -+ this.command = buf.readUtf(2048); // Paper + private ServerboundCommandSuggestionPacket(FriendlyByteBuf buffer) { + this.id = buffer.readVarInt(); +- this.command = buffer.readUtf(32500); ++ this.command = buffer.readUtf(2048); // Paper } - private void write(FriendlyByteBuf buf) { + private void write(FriendlyByteBuf buffer) { diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch similarity index 68% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch index a4d170433a..d7bf58f0ce 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch @@ -1,10 +1,9 @@ --- a/net/minecraft/network/protocol/game/ServerboundInteractPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundInteractPacket.java -@@ -176,4 +176,14 @@ - buf.writeEnum(this.hand); +@@ -145,6 +_,15 @@ + buffer.writeEnum(this.hand); } } -+ + // Paper start - PlayerUseUnknownEntityEvent + public int getEntityId() { + return this.entityId; @@ -14,4 +13,6 @@ + return this.action.getType() == ActionType.ATTACK; + } + // Paper end - PlayerUseUnknownEntityEvent - } + + static class InteractionAtLocationAction implements ServerboundInteractPacket.Action { + private final InteractionHand hand; diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch similarity index 63% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch index 1e2cc2dc52..f650a0dbfb 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java -@@ -1,3 +1,4 @@ +@@ -1,3 +_,4 @@ +// mc-dev import package net.minecraft.network.protocol.game; import net.minecraft.network.FriendlyByteBuf; -@@ -13,6 +14,7 @@ +@@ -14,6 +_,7 @@ private final BlockHitResult blockHit; private final InteractionHand hand; private final int sequence; + public long timestamp; // Spigot - public ServerboundUseItemOnPacket(InteractionHand hand, BlockHitResult blockHitResult, int sequence) { + public ServerboundUseItemOnPacket(InteractionHand hand, BlockHitResult blockHit, int sequence) { this.hand = hand; -@@ -21,6 +23,7 @@ +@@ -22,6 +_,7 @@ } - private ServerboundUseItemOnPacket(FriendlyByteBuf buf) { + private ServerboundUseItemOnPacket(FriendlyByteBuf buffer) { + this.timestamp = System.currentTimeMillis(); // Spigot - this.hand = (InteractionHand) buf.readEnum(InteractionHand.class); - this.blockHit = buf.readBlockHitResult(); - this.sequence = buf.readVarInt(); + this.hand = buffer.readEnum(InteractionHand.class); + this.blockHit = buffer.readBlockHitResult(); + this.sequence = buffer.readVarInt(); diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch similarity index 64% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch index 45ba3ec19d..460014a7e7 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java -@@ -1,3 +1,4 @@ +@@ -1,3 +_,4 @@ +// mc-dev import package net.minecraft.network.protocol.game; import net.minecraft.network.FriendlyByteBuf; -@@ -13,6 +14,7 @@ +@@ -14,6 +_,7 @@ private final int sequence; private final float yRot; private final float xRot; + public long timestamp; // Spigot - public ServerboundUseItemPacket(InteractionHand hand, int sequence, float yaw, float pitch) { + public ServerboundUseItemPacket(InteractionHand hand, int sequence, float yRot, float xRot) { this.hand = hand; -@@ -22,6 +24,7 @@ +@@ -23,6 +_,7 @@ } - private ServerboundUseItemPacket(FriendlyByteBuf buf) { + private ServerboundUseItemPacket(FriendlyByteBuf buffer) { + this.timestamp = System.currentTimeMillis(); // Spigot - this.hand = (InteractionHand) buf.readEnum(InteractionHand.class); - this.sequence = buf.readVarInt(); - this.yRot = buf.readFloat(); + this.hand = buffer.readEnum(InteractionHand.class); + this.sequence = buffer.readVarInt(); + this.yRot = buffer.readFloat(); diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/VecDeltaCodec.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/VecDeltaCodec.java.patch similarity index 92% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/game/VecDeltaCodec.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/game/VecDeltaCodec.java.patch index ca1a2126c9..2f0544231c 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/VecDeltaCodec.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/VecDeltaCodec.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/VecDeltaCodec.java +++ b/net/minecraft/network/protocol/game/VecDeltaCodec.java -@@ -5,16 +5,16 @@ +@@ -5,16 +_,16 @@ public class VecDeltaCodec { private static final double TRUNCATION_STEPS = 4096.0; @@ -15,7 +15,7 @@ @VisibleForTesting static double decode(long value) { -- return (double)value / 4096.0; +- return value / 4096.0; + return value / 4096.0; // Paper - Fix MC-4; diff on change } diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch b/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch deleted file mode 100644 index 6a8d6c8ce8..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java -+++ b/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java -@@ -19,9 +19,11 @@ - } - - private static void pack(List> trackedValues, RegistryFriendlyByteBuf buf) { -+ try (var ignored = io.papermc.paper.util.DataSanitizationUtil.start(true)) { // Paper - data sanitization - for (SynchedEntityData.DataValue dataValue : trackedValues) { - dataValue.write(buf); - } -+ } // Paper - data sanitization - - buf.writeByte(255); - } diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch b/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch deleted file mode 100644 index e13e6cd647..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java -+++ b/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java -@@ -19,6 +19,13 @@ - private final List> slots; - - public ClientboundSetEquipmentPacket(int entityId, List> equipmentList) { -+ // Paper start - data sanitization -+ this(entityId, equipmentList, false); -+ } -+ private boolean sanitize; -+ public ClientboundSetEquipmentPacket(int entityId, List> equipmentList, boolean sanitize) { -+ this.sanitize = sanitize; -+ // Paper end - data sanitization - this.entity = entityId; - this.slots = equipmentList; - } -@@ -40,6 +47,7 @@ - buf.writeVarInt(this.entity); - int i = this.slots.size(); - -+ try (var ignored = io.papermc.paper.util.DataSanitizationUtil.start(this.sanitize)) { // Paper - data sanitization - for (int j = 0; j < i; j++) { - Pair pair = this.slots.get(j); - EquipmentSlot equipmentSlot = pair.getFirst(); -@@ -48,6 +56,7 @@ - buf.writeByte(bl ? k | -128 : k); - ItemStack.OPTIONAL_STREAM_CODEC.encode(buf, pair.getSecond()); - } -+ } // Paper - data sanitization - } - - @Override diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch b/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch deleted file mode 100644 index 1d4da793e7..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java -+++ b/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java -@@ -58,6 +58,11 @@ - ); - } - -+ // Paper start - Multiple Entries with Scoreboards -+ public static ClientboundSetPlayerTeamPacket createMultiplePlayerPacket(PlayerTeam team, Collection players, ClientboundSetPlayerTeamPacket.Action operation) { -+ return new ClientboundSetPlayerTeamPacket(team.getName(), operation == ClientboundSetPlayerTeamPacket.Action.ADD ? 3 : 4, Optional.empty(), players); -+ } -+ // Paper end - Multiple Entries with Scoreboards - private ClientboundSetPlayerTeamPacket(RegistryFriendlyByteBuf buf) { - this.name = buf.readUtf(); - this.method = buf.readByte(); -@@ -200,7 +205,7 @@ - ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buf, this.displayName); - buf.writeByte(this.options); - buf.writeUtf(this.nametagVisibility); -- buf.writeUtf(this.collisionRule); -+ buf.writeUtf(!io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? "never" : this.collisionRule); // Paper - Configurable player collision - buf.writeEnum(this.color); - ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buf, this.playerPrefix); - ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buf, this.playerSuffix);