mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 22:40:21 +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
|
||||
+++ 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();
|
||||
- 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) {
|
|
@ -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);
|
|
@ -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) {
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<ClientboundPlayerInfoUpdatePacket.Action> actions, ClientboundPlayerInfoUpdatePacket.Entry entry) {
|
||||
+ this.actions = actions;
|
||||
+ this.entries = List.of(entry);
|
||||
+ }
|
||||
+ // 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
|
||||
+ public static ClientboundPlayerInfoUpdatePacket createPlayerInitializing(Collection<ServerPlayer> players, ServerPlayer forPlayer) {
|
||||
+ final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> 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)
|
||||
);
|
||||
}
|
|
@ -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<BlockState> 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());
|
|
@ -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) {
|
|
@ -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
|
||||
+++ 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<RegistryFriendlyByteBuf, ClientboundSystemChatPacket> 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<ClientboundSystemChatPacket> type() {
|
||||
return GamePacketTypes.CLIENTBOUND_SYSTEM_CHAT;
|
|
@ -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) {
|
|
@ -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;
|
|
@ -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();
|
|
@ -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();
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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