Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke
2025-04-12 17:26:44 +02:00
parent 0767902699
commit f00727c57e
2092 changed files with 50551 additions and 48729 deletions

View File

@@ -36,7 +36,7 @@
}
public static <T> IntFunction<T> limitValue(IntFunction<T> function, int limit) {
@@ -527,7 +_,7 @@
@@ -539,7 +_,7 @@
try {
NbtIo.writeAnyTag(nbt, new ByteBufOutputStream(buffer));

View File

@@ -0,0 +1,33 @@
--- a/net/minecraft/network/HashedStack.java
+++ b/net/minecraft/network/HashedStack.java
@@ -17,7 +_,7 @@
}
@Override
- public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator) {
+ public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator, final boolean simplifyMatching) { // Paper - add flag to simplify remote matching logic
return stack.isEmpty();
}
};
@@ -27,7 +_,7 @@
hashedStack -> hashedStack instanceof HashedStack.ActualItem actualItem ? Optional.of(actualItem) : Optional.empty()
);
- boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator);
+ boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator, final boolean simplifyMatching); // Paper - add flag to simplify remote matching logic
static HashedStack create(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator) {
return (HashedStack)(stack.isEmpty()
@@ -47,10 +_,10 @@
);
@Override
- public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator) {
+ public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator, final boolean simplifyMatching) { // Paper - add flag to simplify remote matching logic
return this.count == stack.getCount()
&& this.item.equals(stack.getItemHolder())
- && this.components.matches(stack.getComponentsPatch(), hashGenerator);
+ && (simplifyMatching || this.components.matches(stack.getComponentsPatch(), hashGenerator)); // Paper - add flag to simplify remote matching logic
}
}
}

View File

@@ -9,7 +9,7 @@
- Component decorate(@Nullable ServerPlayer player, Component message);
+ ChatDecorator PLAIN = (player, message) -> java.util.concurrent.CompletableFuture.completedFuture(message); // Paper - adventure; support async chat decoration events
+
+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - adventure; support chat decoration events (callers should use the overload with CommandSourceStack)
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - adventure; support chat decoration events (callers should use the overload with CommandSourceStack)
+ java.util.concurrent.CompletableFuture<Component> decorate(@Nullable ServerPlayer player, Component message); // Paper - adventure; support async chat decoration events
+
+ // Paper start - adventure; support async chat decoration events

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/network/chat/ComponentSerialization.java
+++ b/net/minecraft/network/chat/ComponentSerialization.java
@@ -37,9 +_,31 @@
@@ -35,9 +_,31 @@
public class ComponentSerialization {
public static final Codec<Component> CODEC = Codec.recursive("Component", ComponentSerialization::createCodec);
@@ -34,7 +34,7 @@
public static final StreamCodec<RegistryFriendlyByteBuf, Optional<Component>> TRUSTED_OPTIONAL_STREAM_CODEC = TRUSTED_STREAM_CODEC.apply(
ByteBufCodecs::optional
);
@@ -102,7 +_,25 @@
@@ -94,7 +_,25 @@
return ExtraCodecs.orCompressed(mapCodec2, mapCodec1);
}
@@ -60,7 +60,7 @@
ComponentContents.Type<?>[] types = new ComponentContents.Type[]{
PlainTextContents.TYPE, TranslatableContents.TYPE, KeybindContents.TYPE, ScoreContents.TYPE, SelectorContents.TYPE, NbtContents.TYPE
};
@@ -115,6 +_,34 @@
@@ -107,6 +_,34 @@
)
.apply(instance, MutableComponent::new)
);

View File

@@ -4,7 +4,7 @@
}
}
+ @io.papermc.paper.annotation.DoNotUse // Paper - validate separators - right now this method is only used for separator evaluation. Error on build if this changes to re-evaluate.
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - validate separators - right now this method is only used for separator evaluation. Error on build if this changes to re-evaluate.
public static Optional<MutableComponent> updateForEntity(
@Nullable CommandSourceStack commandSourceStack, Optional<Component> optionalComponent, @Nullable Entity entity, int recursionDepth
) throws CommandSyntaxException {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/network/chat/PlayerChatMessage.java
+++ b/net/minecraft/network/chat/PlayerChatMessage.java
@@ -17,6 +_,43 @@
@@ -18,6 +_,43 @@
public record PlayerChatMessage(
SignedMessageLink link, @Nullable MessageSignature signature, SignedMessageBody signedBody, @Nullable Component unsignedContent, FilterMask filterMask
) {
@@ -44,7 +44,7 @@
public static final MapCodec<PlayerChatMessage> MAP_CODEC = RecordCodecBuilder.mapCodec(
instance -> instance.group(
SignedMessageLink.CODEC.fieldOf("link").forGetter(PlayerChatMessage::link),
@@ -47,7 +_,14 @@
@@ -48,7 +_,14 @@
}
public PlayerChatMessage withUnsignedContent(Component message) {

View File

@@ -1,20 +1,20 @@
--- a/net/minecraft/network/chat/contents/NbtContents.java
+++ b/net/minecraft/network/chat/contents/NbtContents.java
@@ -115,7 +_,7 @@
}).map(Tag::getAsString);
@@ -119,7 +_,7 @@
if (this.interpreting) {
RegistryOps<Tag> registryOps = nbtPathPattern.registryAccess().createSerializationContext(NbtOps.INSTANCE);
Component component = DataFixUtils.orElse(
- ComponentUtils.updateForEntity(nbtPathPattern, this.separator, entity, recursionDepth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR
+ ComponentUtils.updateSeparatorForEntity(nbtPathPattern, this.separator, entity, recursionDepth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR // Paper - validate separator
);
return stream.flatMap(text -> {
return stream.flatMap(tag -> {
try {
@@ -127,7 +_,7 @@
}
@@ -132,7 +_,7 @@
}).reduce((mutableComponent, component1) -> mutableComponent.append(component).append(component1)).orElseGet(Component::empty);
} else {
Stream<String> stream1 = stream.map(NbtContents::asString);
- return ComponentUtils.updateForEntity(nbtPathPattern, this.separator, entity, recursionDepth)
+ return ComponentUtils.updateSeparatorForEntity(nbtPathPattern, this.separator, entity, recursionDepth) // Paper - validate separator
.map(
mutableComponent -> stream.map(Component::literal)
mutableComponent -> stream1.map(Component::literal)
.reduce((mutableComponent1, otherMutableComponent) -> mutableComponent1.append(mutableComponent).append(otherMutableComponent))

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/network/codec/ByteBufCodecs.java
+++ b/net/minecraft/network/codec/ByteBufCodecs.java
@@ -378,6 +_,48 @@
@@ -389,6 +_,48 @@
};
}

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
@@ -35,6 +_,20 @@
this.items = ItemStack.OPTIONAL_LIST_STREAM_CODEC.decode(buffer);
this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.decode(buffer);
}
@@ -22,6 +_,21 @@
ClientboundContainerSetContentPacket::new
);
+ // Paper start - Handle large packets disconnecting client
+ @Override
+ public boolean hasLargePacketFallback() {
@@ -18,6 +18,7 @@
+ return true;
+ }
+ // Paper end - Handle large packets disconnecting client
private void write(RegistryFriendlyByteBuf buffer) {
buffer.writeContainerId(this.containerId);
+
@Override
public PacketType<ClientboundContainerSetContentPacket> type() {
return GamePacketTypes.CLIENTBOUND_CONTAINER_SET_CONTENT;

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
+++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
@@ -52,7 +_,7 @@
throw new RuntimeException("Can't read heightmap in packet for [" + x + ", " + z + "]");
@@ -50,7 +_,7 @@
public ClientboundLevelChunkPacketData(RegistryFriendlyByteBuf buffer, int x, int z) {
this.heightmaps = HEIGHTMAPS_STREAM_CODEC.decode(buffer);
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 {
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[varInt];
@@ -154,6 +_,7 @@
this.buffer = new byte[varInt];
@@ -151,6 +_,7 @@
CompoundTag updateTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess());
BlockPos blockPos = blockEntity.getBlockPos();
int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ());

View File

@@ -97,7 +97,7 @@
- true,
+ listed, // Paper - Add Listing API for Player
player.connection.latency(),
player.gameMode.getGameModeForPlayer(),
player.gameMode(),
player.getTabListDisplayName(),
@@ -172,6 +_,11 @@
Optionull.map(player.getChatSession(), RemoteChatSession::asData)

View File

@@ -4,7 +4,7 @@
}
private static void pack(List<SynchedEntityData.DataValue<?>> dataValues, RegistryFriendlyByteBuf buffer) {
+ try (io.papermc.paper.util.ItemObfuscationSession ignored = io.papermc.paper.util.ItemObfuscationSession.start(io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level)) { // Paper - data sanitization
+ try (io.papermc.paper.util.sanitizer.ItemObfuscationSession ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.start(io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level)) { // Paper - data sanitization
for (SynchedEntityData.DataValue<?> dataValue : dataValues) {
dataValue.write(buffer);
}

View File

@@ -18,7 +18,7 @@
buffer.writeVarInt(this.entity);
int size = this.slots.size();
+ try (final io.papermc.paper.util.ItemObfuscationSession ignored = io.papermc.paper.util.ItemObfuscationSession.start(this.sanitize ? io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level : io.papermc.paper.util.ItemObfuscationSession.ObfuscationLevel.NONE)) { // Paper - data sanitization
+ try (final io.papermc.paper.util.sanitizer.ItemObfuscationSession ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.start(this.sanitize ? io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level : io.papermc.paper.util.sanitizer.ItemObfuscationSession.ObfuscationLevel.NONE)) { // Paper - data sanitization
for (int i = 0; i < size; i++) {
Pair<EquipmentSlot, ItemStack> pair = this.slots.get(i);
EquipmentSlot equipmentSlot = pair.getFirst();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
@@ -30,6 +_,11 @@
@@ -31,6 +_,11 @@
private final Collection<String> players;
private final Optional<ClientboundSetPlayerTeamPacket.Parameters> parameters;
@@ -12,12 +12,12 @@
private ClientboundSetPlayerTeamPacket(String name, int method, Optional<ClientboundSetPlayerTeamPacket.Parameters> parameters, Collection<String> players) {
this.name = name;
this.method = method;
@@ -198,7 +_,7 @@
@@ -199,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 ? PlayerTeam.CollisionRule.NEVER.name : this.collisionRule); // Paper - Configurable player collision
Team.Visibility.STREAM_CODEC.encode(buffer, this.nametagVisibility);
- Team.CollisionRule.STREAM_CODEC.encode(buffer, this.collisionRule);
+ Team.CollisionRule.STREAM_CODEC.encode(buffer, !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? PlayerTeam.CollisionRule.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);

View File

@@ -6,7 +6,7 @@
);
+ // 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);
+ this(org.bukkit.craftbukkit.util.CraftChatMessage.bungeeToVanilla(content), overlay);
+ }
+ // Spigot end
+ // Paper start

View File

@@ -1,20 +0,0 @@
--- a/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java
+++ b/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java
@@ -17,7 +_,7 @@
);
private static final int MAX_SLOT_COUNT = 128;
private static final StreamCodec<RegistryFriendlyByteBuf, Int2ObjectMap<ItemStack>> SLOTS_STREAM_CODEC = ByteBufCodecs.map(
- Int2ObjectOpenHashMap::new, ByteBufCodecs.SHORT.map(Short::intValue, Integer::shortValue), ItemStack.OPTIONAL_STREAM_CODEC, 128
+ Int2ObjectOpenHashMap::new, ByteBufCodecs.SHORT.map(Short::intValue, Integer::shortValue), ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs::trackDepth), 128 // Paper - Track codec depth
);
private final int containerId;
private final int stateId;
@@ -46,7 +_,7 @@
this.buttonNum = buffer.readByte();
this.clickType = buffer.readEnum(ClickType.class);
this.changedSlots = Int2ObjectMaps.unmodifiable(SLOTS_STREAM_CODEC.decode(buffer));
- this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.decode(buffer);
+ this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs::trackDepth).decode(buffer); // Paper - Track codec depth
}
private void write(RegistryFriendlyByteBuf buffer) {

View File

@@ -4,8 +4,8 @@
public static final StreamCodec<RegistryFriendlyByteBuf, ServerboundSetCreativeModeSlotPacket> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.SHORT,
ServerboundSetCreativeModeSlotPacket::slotNum,
- ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_STREAM_CODEC),
+ ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_STREAM_CODEC).apply(ByteBufCodecs::trackDepth), // Paper - Track codec depth
- ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_UNTRUSTED_STREAM_CODEC),
+ ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_UNTRUSTED_STREAM_CODEC).apply(ByteBufCodecs::trackDepth), // Paper - Track codec depth
ServerboundSetCreativeModeSlotPacket::itemStack,
ServerboundSetCreativeModeSlotPacket::new
);

View File

@@ -1,14 +1,5 @@
--- a/net/minecraft/network/syncher/SynchedEntityData.java
+++ b/net/minecraft/network/syncher/SynchedEntityData.java
@@ -45,7 +_,7 @@
}
}
- private <T> SynchedEntityData.DataItem<T> getItem(EntityDataAccessor<T> key) {
+ public <T> SynchedEntityData.DataItem<T> getItem(EntityDataAccessor<T> key) { // Paper - public
return (SynchedEntityData.DataItem<T>)this.itemsById[key.id()];
}
@@ -67,6 +_,13 @@
}
}