mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
net/minecraft/network/protocol/game/
This commit is contained in:
parent
e50b519542
commit
822b963d3f
19 changed files with 153 additions and 164 deletions
|
@ -1,11 +1,11 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
--- a/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
||||||
+++ b/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<BlockEntity, RegistryAccess, CompoundTag> nbtGetter) {
|
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity, BiFunction<BlockEntity, RegistryAccess, CompoundTag> dataGetter) {
|
||||||
RegistryAccess registryAccess = blockEntity.getLevel().registryAccess();
|
RegistryAccess registryAccess = blockEntity.getLevel().registryAccess();
|
||||||
- return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), nbtGetter.apply(blockEntity, registryAccess));
|
- return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), dataGetter.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(), blockEntity.sanitizeSentNbt(dataGetter.apply(blockEntity, registryAccess))); // Paper - Sanitize sent data
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) {
|
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) {
|
|
@ -1,9 +1,9 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
--- a/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
||||||
+++ b/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
+++ b/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
||||||
@@ -36,6 +36,21 @@
|
@@ -35,6 +_,20 @@
|
||||||
this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.decode(buf);
|
this.items = ItemStack.OPTIONAL_LIST_STREAM_CODEC.decode(buffer);
|
||||||
|
this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.decode(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start - Handle large packets disconnecting client
|
+ // Paper start - Handle large packets disconnecting client
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public boolean hasLargePacketFallback() {
|
+ public boolean hasLargePacketFallback() {
|
||||||
|
@ -18,7 +18,6 @@
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Handle large packets disconnecting client
|
+ // Paper end - Handle large packets disconnecting client
|
||||||
+
|
|
||||||
private void write(RegistryFriendlyByteBuf buf) {
|
private void write(RegistryFriendlyByteBuf buffer) {
|
||||||
buf.writeContainerId(this.containerId);
|
buffer.writeContainerId(this.containerId);
|
||||||
buf.writeVarInt(this.stateId);
|
|
|
@ -1,6 +1,6 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
|
--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
|
||||||
+++ b/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) {
|
public ClientboundInitializeBorderPacket(WorldBorder worldBorder) {
|
|
@ -1,19 +1,19 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
|
--- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
|
||||||
+++ b/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 + "]");
|
throw new RuntimeException("Can't read heightmap in packet for [" + x + ", " + z + "]");
|
||||||
} else {
|
} else {
|
||||||
int i = buf.readVarInt();
|
int varInt = buffer.readVarInt();
|
||||||
- if (i > 2097152) {
|
- if (varInt > 2097152) {
|
||||||
+ if (i > 2097152) { // Paper - diff on change - if this changes, update PacketEncoder
|
+ 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.");
|
throw new RuntimeException("Chunk Packet trying to allocate too much memory on read.");
|
||||||
} else {
|
} else {
|
||||||
this.buffer = new byte[i];
|
this.buffer = new byte[varInt];
|
||||||
@@ -154,6 +154,7 @@
|
@@ -154,6 +_,7 @@
|
||||||
CompoundTag compoundTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess());
|
CompoundTag updateTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess());
|
||||||
BlockPos blockPos = blockEntity.getBlockPos();
|
BlockPos blockPos = blockEntity.getBlockPos();
|
||||||
int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ());
|
int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ());
|
||||||
+ blockEntity.sanitizeSentNbt(compoundTag); // Paper - Sanitize sent data
|
+ blockEntity.sanitizeSentNbt(updateTag); // Paper - Sanitize sent data
|
||||||
return new ClientboundLevelChunkPacketData.BlockEntityInfo(i, blockPos.getY(), blockEntity.getType(), compoundTag.isEmpty() ? null : compoundTag);
|
return new ClientboundLevelChunkPacketData.BlockEntityInfo(i, blockPos.getY(), blockEntity.getType(), updateTag.isEmpty() ? null : updateTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java
|
--- a/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java
|
||||||
+++ b/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.actions = EnumSet.of(action);
|
||||||
this.entries = List.of(new ClientboundPlayerInfoUpdatePacket.Entry(player));
|
this.entries = List.of(new ClientboundPlayerInfoUpdatePacket.Entry(player));
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,19 @@
|
||||||
+ this.actions = actions;
|
+ this.actions = actions;
|
||||||
+ this.entries = entries;
|
+ this.entries = entries;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ public ClientboundPlayerInfoUpdatePacket(EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions, ClientboundPlayerInfoUpdatePacket.Entry entry) {
|
+ public ClientboundPlayerInfoUpdatePacket(EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions, ClientboundPlayerInfoUpdatePacket.Entry entry) {
|
||||||
+ this.actions = actions;
|
+ this.actions = actions;
|
||||||
+ this.entries = List.of(entry);
|
+ this.entries = List.of(entry);
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Add Listing API for Player
|
+ // Paper end - Add Listing API for Player
|
||||||
+
|
|
||||||
public static ClientboundPlayerInfoUpdatePacket createPlayerInitializing(Collection<ServerPlayer> players) {
|
|
||||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> enumSet = EnumSet.of(
|
|
||||||
ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER,
|
|
||||||
@@ -53,6 +64,46 @@
|
|
||||||
return new ClientboundPlayerInfoUpdatePacket(enumSet, players);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static ClientboundPlayerInfoUpdatePacket createPlayerInitializing(Collection<ServerPlayer> players) {
|
||||||
|
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> set = EnumSet.of(
|
||||||
|
@@ -52,6 +_,46 @@
|
||||||
|
);
|
||||||
|
return new ClientboundPlayerInfoUpdatePacket(set, players);
|
||||||
|
}
|
||||||
+ // Paper start - Add Listing API for Player
|
+ // Paper start - Add Listing API for Player
|
||||||
+ public static ClientboundPlayerInfoUpdatePacket createPlayerInitializing(Collection<ServerPlayer> players, ServerPlayer forPlayer) {
|
+ public static ClientboundPlayerInfoUpdatePacket createPlayerInitializing(Collection<ServerPlayer> players, ServerPlayer forPlayer) {
|
||||||
+ final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> enumSet = EnumSet.of(
|
+ final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> enumSet = EnumSet.of(
|
||||||
|
@ -63,14 +62,14 @@
|
||||||
+ return new ClientboundPlayerInfoUpdatePacket(enumSet, new ClientboundPlayerInfoUpdatePacket.Entry(playerInfoId, listed));
|
+ return new ClientboundPlayerInfoUpdatePacket(enumSet, new ClientboundPlayerInfoUpdatePacket.Entry(playerInfoId, listed));
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Add Listing API for Player
|
+ // Paper end - Add Listing API for Player
|
||||||
private ClientboundPlayerInfoUpdatePacket(RegistryFriendlyByteBuf buf) {
|
|
||||||
this.actions = buf.readEnumSet(ClientboundPlayerInfoUpdatePacket.Action.class);
|
private ClientboundPlayerInfoUpdatePacket(RegistryFriendlyByteBuf buffer) {
|
||||||
this.entries = buf.readList(buf2 -> {
|
this.actions = buffer.readEnumSet(ClientboundPlayerInfoUpdatePacket.Action.class);
|
||||||
@@ -116,7 +167,15 @@
|
@@ -116,7 +_,15 @@
|
||||||
}),
|
}),
|
||||||
INITIALIZE_CHAT(
|
INITIALIZE_CHAT(
|
||||||
(serialized, buf) -> serialized.chatSession = buf.readNullable(RemoteChatSession.Data::read),
|
(entryBuilder, buffer) -> entryBuilder.chatSession = buffer.readNullable(RemoteChatSession.Data::read),
|
||||||
- (buf, entry) -> buf.writeNullable(entry.chatSession, RemoteChatSession.Data::write)
|
- (buffer, entry) -> buffer.writeNullable(entry.chatSession, RemoteChatSession.Data::write)
|
||||||
+ // Paper start - Prevent causing expired keys from impacting new joins
|
+ // Paper start - Prevent causing expired keys from impacting new joins
|
||||||
+ (buf, entry) -> {
|
+ (buf, entry) -> {
|
||||||
+ RemoteChatSession.Data chatSession = entry.chatSession;
|
+ RemoteChatSession.Data chatSession = entry.chatSession;
|
||||||
|
@ -81,9 +80,9 @@
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Prevent causing expired keys from impacting new joins
|
+ // 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_GAME_MODE(
|
||||||
UPDATE_LISTED((serialized, buf) -> serialized.listed = buf.readBoolean(), (buf, entry) -> buf.writeBoolean(entry.listed())),
|
(entryBuilder, buffer) -> entryBuilder.gameMode = GameType.byId(buffer.readVarInt()),
|
||||||
@@ -157,10 +216,15 @@
|
@@ -160,10 +_,15 @@
|
||||||
@Nullable RemoteChatSession.Data chatSession
|
@Nullable RemoteChatSession.Data chatSession
|
||||||
) {
|
) {
|
||||||
Entry(ServerPlayer player) {
|
Entry(ServerPlayer player) {
|
||||||
|
@ -100,7 +99,7 @@
|
||||||
player.connection.latency(),
|
player.connection.latency(),
|
||||||
player.gameMode.getGameModeForPlayer(),
|
player.gameMode.getGameModeForPlayer(),
|
||||||
player.getTabListDisplayName(),
|
player.getTabListDisplayName(),
|
||||||
@@ -169,6 +233,11 @@
|
@@ -172,6 +_,11 @@
|
||||||
Optionull.map(player.getChatSession(), RemoteChatSession::asData)
|
Optionull.map(player.getChatSession(), RemoteChatSession::asData)
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -1,15 +1,14 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
--- a/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
||||||
+++ b/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
+++ b/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
||||||
@@ -33,11 +33,19 @@
|
@@ -30,10 +_,25 @@
|
||||||
short short0 = (Short) shortiterator.next();
|
|
||||||
|
|
||||||
this.positions[j] = short0;
|
for (short s : positions) {
|
||||||
- this.states[j] = section.getBlockState(SectionPos.sectionRelativeX(short0), SectionPos.sectionRelativeY(short0), SectionPos.sectionRelativeZ(short0));
|
this.positions[i] = s;
|
||||||
+ 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
|
- 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
|
+ // CraftBukkit start - Add constructor
|
||||||
+ public ClientboundSectionBlocksUpdatePacket(SectionPos sectionposition, ShortSet shortset, BlockState[] states) {
|
+ public ClientboundSectionBlocksUpdatePacket(SectionPos sectionposition, ShortSet shortset, BlockState[] states) {
|
||||||
+ this.sectionPos = sectionposition;
|
+ this.sectionPos = sectionposition;
|
||||||
|
@ -17,14 +16,6 @@
|
||||||
+ this.states = states;
|
+ this.states = states;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // 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
|
+ // Paper start - Multi Block Change API
|
||||||
+ public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap<BlockState> blockChanges) {
|
+ public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap<BlockState> blockChanges) {
|
||||||
+ this.sectionPos = sectionPos;
|
+ this.sectionPos = sectionPos;
|
||||||
|
@ -33,6 +24,6 @@
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Multi Block Change API
|
+ // Paper end - Multi Block Change API
|
||||||
+
|
+
|
||||||
private void write(FriendlyByteBuf buf) {
|
|
||||||
buf.writeLong(this.sectionPos.asLong());
|
private ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf buffer) {
|
||||||
buf.writeVarInt(this.positions.length);
|
this.sectionPos = SectionPos.of(buffer.readLong());
|
|
@ -1,6 +1,6 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
|
--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
|
||||||
+++ b/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;
|
private final double newCenterZ;
|
||||||
|
|
||||||
public ClientboundSetBorderCenterPacket(WorldBorder worldBorder) {
|
public ClientboundSetBorderCenterPacket(WorldBorder worldBorder) {
|
||||||
|
@ -12,4 +12,4 @@
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientboundSetBorderCenterPacket(FriendlyByteBuf buf) {
|
private ClientboundSetBorderCenterPacket(FriendlyByteBuf buffer) {
|
|
@ -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<SynchedEntityData.DataValue<?>> 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);
|
||||||
|
}
|
|
@ -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<Pair<EquipmentSlot, ItemStack>> slots;
|
||||||
|
|
||||||
|
public ClientboundSetEquipmentPacket(int entity, List<Pair<EquipmentSlot, ItemStack>> slots) {
|
||||||
|
+ // Paper start - data sanitization
|
||||||
|
+ this(entity, slots, false);
|
||||||
|
+ }
|
||||||
|
+ private boolean sanitize;
|
||||||
|
+ public ClientboundSetEquipmentPacket(int entity, List<Pair<EquipmentSlot, ItemStack>> 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<EquipmentSlot, ItemStack> 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
|
|
@ -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<String> players;
|
||||||
|
private final Optional<ClientboundSetPlayerTeamPacket.Parameters> parameters;
|
||||||
|
|
||||||
|
+ // Paper start - Multiple Entries with Scoreboards
|
||||||
|
+ public static ClientboundSetPlayerTeamPacket createMultiplePlayerPacket(PlayerTeam team, Collection<String> 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<ClientboundSetPlayerTeamPacket.Parameters> parameters, Collection<String> 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);
|
|
@ -1,14 +1,14 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
|
--- a/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
|
||||||
+++ b/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
|
+// mc-dev import
|
||||||
package net.minecraft.network.protocol.game;
|
package net.minecraft.network.protocol.game;
|
||||||
|
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
@@ -12,6 +13,17 @@
|
@@ -16,6 +_,16 @@
|
||||||
|
ClientboundSystemChatPacket::overlay,
|
||||||
public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundSystemChatPacket> STREAM_CODEC = StreamCodec.composite(ComponentSerialization.TRUSTED_STREAM_CODEC, ClientboundSystemChatPacket::content, ByteBufCodecs.BOOL, ClientboundSystemChatPacket::overlay, ClientboundSystemChatPacket::new);
|
ClientboundSystemChatPacket::new
|
||||||
|
);
|
||||||
+ // Spigot start
|
+ // Spigot start
|
||||||
+ public ClientboundSystemChatPacket(net.md_5.bungee.api.chat.BaseComponent[] content, boolean overlay) {
|
+ 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);
|
+ 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);
|
+ this(io.papermc.paper.adventure.PaperAdventure.asVanilla(content), overlay);
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
|
||||||
@Override
|
@Override
|
||||||
public PacketType<ClientboundSystemChatPacket> type() {
|
public PacketType<ClientboundSystemChatPacket> type() {
|
||||||
return GamePacketTypes.CLIENTBOUND_SYSTEM_CHAT;
|
|
|
@ -1,11 +1,11 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java
|
--- a/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java
|
||||||
+++ b/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) {
|
private ServerboundCommandSuggestionPacket(FriendlyByteBuf buffer) {
|
||||||
this.id = buf.readVarInt();
|
this.id = buffer.readVarInt();
|
||||||
- this.command = buf.readUtf(32500);
|
- this.command = buffer.readUtf(32500);
|
||||||
+ this.command = buf.readUtf(2048); // Paper
|
+ this.command = buffer.readUtf(2048); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
private void write(FriendlyByteBuf buf) {
|
private void write(FriendlyByteBuf buffer) {
|
|
@ -1,10 +1,9 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
--- a/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
||||||
+++ b/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
+++ b/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
||||||
@@ -176,4 +176,14 @@
|
@@ -145,6 +_,15 @@
|
||||||
buf.writeEnum(this.hand);
|
buffer.writeEnum(this.hand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+
|
|
||||||
+ // Paper start - PlayerUseUnknownEntityEvent
|
+ // Paper start - PlayerUseUnknownEntityEvent
|
||||||
+ public int getEntityId() {
|
+ public int getEntityId() {
|
||||||
+ return this.entityId;
|
+ return this.entityId;
|
||||||
|
@ -14,4 +13,6 @@
|
||||||
+ return this.action.getType() == ActionType.ATTACK;
|
+ return this.action.getType() == ActionType.ATTACK;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - PlayerUseUnknownEntityEvent
|
+ // Paper end - PlayerUseUnknownEntityEvent
|
||||||
}
|
|
||||||
|
static class InteractionAtLocationAction implements ServerboundInteractPacket.Action {
|
||||||
|
private final InteractionHand hand;
|
|
@ -1,23 +1,23 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java
|
--- a/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java
|
||||||
+++ b/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
|
+// mc-dev import
|
||||||
package net.minecraft.network.protocol.game;
|
package net.minecraft.network.protocol.game;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
@@ -13,6 +14,7 @@
|
@@ -14,6 +_,7 @@
|
||||||
private final BlockHitResult blockHit;
|
private final BlockHitResult blockHit;
|
||||||
private final InteractionHand hand;
|
private final InteractionHand hand;
|
||||||
private final int sequence;
|
private final int sequence;
|
||||||
+ public long timestamp; // Spigot
|
+ public long timestamp; // Spigot
|
||||||
|
|
||||||
public ServerboundUseItemOnPacket(InteractionHand hand, BlockHitResult blockHitResult, int sequence) {
|
public ServerboundUseItemOnPacket(InteractionHand hand, BlockHitResult blockHit, int sequence) {
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
@@ -21,6 +23,7 @@
|
@@ -22,6 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerboundUseItemOnPacket(FriendlyByteBuf buf) {
|
private ServerboundUseItemOnPacket(FriendlyByteBuf buffer) {
|
||||||
+ this.timestamp = System.currentTimeMillis(); // Spigot
|
+ this.timestamp = System.currentTimeMillis(); // Spigot
|
||||||
this.hand = (InteractionHand) buf.readEnum(InteractionHand.class);
|
this.hand = buffer.readEnum(InteractionHand.class);
|
||||||
this.blockHit = buf.readBlockHitResult();
|
this.blockHit = buffer.readBlockHitResult();
|
||||||
this.sequence = buf.readVarInt();
|
this.sequence = buffer.readVarInt();
|
|
@ -1,23 +1,23 @@
|
||||||
--- a/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java
|
--- a/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java
|
||||||
+++ b/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
|
+// mc-dev import
|
||||||
package net.minecraft.network.protocol.game;
|
package net.minecraft.network.protocol.game;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
@@ -13,6 +14,7 @@
|
@@ -14,6 +_,7 @@
|
||||||
private final int sequence;
|
private final int sequence;
|
||||||
private final float yRot;
|
private final float yRot;
|
||||||
private final float xRot;
|
private final float xRot;
|
||||||
+ public long timestamp; // Spigot
|
+ 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;
|
this.hand = hand;
|
||||||
@@ -22,6 +24,7 @@
|
@@ -23,6 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerboundUseItemPacket(FriendlyByteBuf buf) {
|
private ServerboundUseItemPacket(FriendlyByteBuf buffer) {
|
||||||
+ this.timestamp = System.currentTimeMillis(); // Spigot
|
+ this.timestamp = System.currentTimeMillis(); // Spigot
|
||||||
this.hand = (InteractionHand) buf.readEnum(InteractionHand.class);
|
this.hand = buffer.readEnum(InteractionHand.class);
|
||||||
this.sequence = buf.readVarInt();
|
this.sequence = buffer.readVarInt();
|
||||||
this.yRot = buf.readFloat();
|
this.yRot = buffer.readFloat();
|
|
@ -1,6 +1,6 @@
|
||||||
--- a/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
--- a/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
||||||
+++ b/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 {
|
public class VecDeltaCodec {
|
||||||
private static final double TRUNCATION_STEPS = 4096.0;
|
private static final double TRUNCATION_STEPS = 4096.0;
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static double decode(long value) {
|
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
|
+ return value / 4096.0; // Paper - Fix MC-4; diff on change
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<SynchedEntityData.DataValue<?>> 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);
|
|
||||||
}
|
|
|
@ -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<Pair<EquipmentSlot, ItemStack>> slots;
|
|
||||||
|
|
||||||
public ClientboundSetEquipmentPacket(int entityId, List<Pair<EquipmentSlot, ItemStack>> equipmentList) {
|
|
||||||
+ // Paper start - data sanitization
|
|
||||||
+ this(entityId, equipmentList, false);
|
|
||||||
+ }
|
|
||||||
+ private boolean sanitize;
|
|
||||||
+ public ClientboundSetEquipmentPacket(int entityId, List<Pair<EquipmentSlot, ItemStack>> 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<EquipmentSlot, ItemStack> 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
|
|
|
@ -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<String> 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);
|
|
Loading…
Reference in a new issue