1.21.6 dev
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
committed by
Nassim Jahnke
parent
39203a65e0
commit
a24f9b204c
@@ -192,7 +192,7 @@
|
||||
} catch (RejectedExecutionException var6) {
|
||||
this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown"));
|
||||
} catch (ClassCastException var7) {
|
||||
@@ -385,10 +_,30 @@
|
||||
@@ -373,10 +_,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@
|
||||
}
|
||||
|
||||
if (!this.isConnected() && !this.disconnectionHandled) {
|
||||
@@ -396,7 +_,7 @@
|
||||
@@ -384,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (this.channel != null) {
|
||||
@@ -232,7 +232,7 @@
|
||||
}
|
||||
|
||||
if (this.tickCount++ % 20 == 0) {
|
||||
@@ -432,12 +_,13 @@
|
||||
@@ -420,12 +_,13 @@
|
||||
}
|
||||
|
||||
public void disconnect(DisconnectionDetails disconnectionDetails) {
|
||||
@@ -247,7 +247,7 @@
|
||||
this.disconnectionDetails = disconnectionDetails;
|
||||
}
|
||||
}
|
||||
@@ -584,6 +_,13 @@
|
||||
@@ -572,6 +_,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@
|
||||
public void setupCompression(int threshold, boolean validateDecompressed) {
|
||||
if (threshold >= 0) {
|
||||
if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder compressionDecoder) {
|
||||
@@ -597,6 +_,7 @@
|
||||
@@ -585,6 +_,7 @@
|
||||
} else {
|
||||
this.channel.pipeline().addAfter("prepender", "compress", new CompressionEncoder(threshold));
|
||||
}
|
||||
@@ -269,7 +269,7 @@
|
||||
} else {
|
||||
if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) {
|
||||
this.channel.pipeline().remove("decompress");
|
||||
@@ -605,6 +_,7 @@
|
||||
@@ -593,6 +_,7 @@
|
||||
if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) {
|
||||
this.channel.pipeline().remove("compress");
|
||||
}
|
||||
@@ -277,7 +277,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,6 +_,26 @@
|
||||
@@ -610,6 +_,26 @@
|
||||
);
|
||||
packetListener1.onDisconnect(disconnectionDetails);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/FriendlyByteBuf.java
|
||||
+++ b/net/minecraft/network/FriendlyByteBuf.java
|
||||
@@ -70,14 +_,20 @@
|
||||
@@ -71,14 +_,20 @@
|
||||
public class FriendlyByteBuf extends ByteBuf {
|
||||
public static final int DEFAULT_NBT_QUOTA = 2097152;
|
||||
private final ByteBuf source;
|
||||
@@ -21,7 +21,7 @@
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@@ -106,8 +_,13 @@
|
||||
@@ -107,8 +_,13 @@
|
||||
}
|
||||
|
||||
public <T> void writeJsonWithCodec(Codec<T> codec, T value) {
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
|
||||
public static <T> IntFunction<T> limitValue(IntFunction<T> function, int limit) {
|
||||
@@ -539,7 +_,7 @@
|
||||
@@ -556,7 +_,7 @@
|
||||
|
||||
try {
|
||||
NbtIo.writeAnyTag(nbt, new ByteBufOutputStream(buffer));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/chat/Component.java
|
||||
+++ b/net/minecraft/network/chat/Component.java
|
||||
@@ -37,7 +_,19 @@
|
||||
@@ -23,7 +_,19 @@
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/codec/ByteBufCodecs.java
|
||||
+++ b/net/minecraft/network/codec/ByteBufCodecs.java
|
||||
@@ -389,6 +_,48 @@
|
||||
@@ -435,6 +_,48 @@
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
throw new RuntimeException("Chunk Packet trying to allocate too much memory on read.");
|
||||
} else {
|
||||
this.buffer = new byte[varInt];
|
||||
@@ -151,6 +_,7 @@
|
||||
@@ -155,6 +_,7 @@
|
||||
CompoundTag updateTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess());
|
||||
BlockPos blockPos = blockEntity.getBlockPos();
|
||||
int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ());
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
--- a/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java
|
||||
+++ b/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java
|
||||
@@ -18,11 +_,16 @@
|
||||
}
|
||||
@@ -14,8 +_,25 @@
|
||||
|
||||
private ClientboundLoginDisconnectPacket(FriendlyByteBuf buffer) {
|
||||
- this.reason = Component.Serializer.fromJsonLenient(buffer.readUtf(262144), RegistryAccess.EMPTY);
|
||||
+ this.reason = Component.Serializer.fromJsonLenient(buffer.readUtf(FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH), RegistryAccess.EMPTY); // Paper - diff on change
|
||||
}
|
||||
|
||||
private void write(FriendlyByteBuf buffer) {
|
||||
- buffer.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY));
|
||||
+ // Paper start - Adventure
|
||||
+ // buffer.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY));
|
||||
+ // In the login phase, buffer.adventure$locale field is most likely null, but plugins may use internals to set it via the channel attribute
|
||||
+ java.util.Locale bufLocale = buffer.adventure$locale;
|
||||
+ buffer.writeJsonWithCodec(net.minecraft.network.chat.ComponentSerialization.localizedCodec(bufLocale == null ? java.util.Locale.US : bufLocale), this.reason, FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH);
|
||||
+ // Paper end - Adventure
|
||||
}
|
||||
|
||||
@Override
|
||||
public record ClientboundLoginDisconnectPacket(Component reason) implements Packet<ClientLoginPacketListener> {
|
||||
private static final RegistryOps<JsonElement> OPS = RegistryAccess.EMPTY.createSerializationContext(JsonOps.INSTANCE);
|
||||
- public static final StreamCodec<ByteBuf, ClientboundLoginDisconnectPacket> STREAM_CODEC = StreamCodec.composite(
|
||||
- ByteBufCodecs.lenientJson(262144).apply(ByteBufCodecs.fromCodec(OPS, ComponentSerialization.CODEC)),
|
||||
+ // Paper start - localized codec
|
||||
+ // In the login phase, buffer.adventure$locale field is most likely null, but plugins may use internals to set it via the channel attribute
|
||||
+ public static final StreamCodec<net.minecraft.network.FriendlyByteBuf, ClientboundLoginDisconnectPacket> STREAM_CODEC = StreamCodec.composite(
|
||||
+ new StreamCodec<>() {
|
||||
+
|
||||
+ private static final net.minecraft.network.codec.StreamCodec<ByteBuf, JsonElement> LENIENT_JSON = ByteBufCodecs.lenientJson(net.minecraft.network.FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH);
|
||||
+ @Override
|
||||
+ public Component decode(final net.minecraft.network.FriendlyByteBuf buffer) {
|
||||
+ java.util.Locale bufLocale = buffer.adventure$locale;
|
||||
+ return LENIENT_JSON.apply(ByteBufCodecs.fromCodec(OPS, ComponentSerialization.localizedCodec(bufLocale == null ? java.util.Locale.US : bufLocale))).decode(buffer);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void encode(final net.minecraft.network.FriendlyByteBuf buffer, final Component value) {
|
||||
+ java.util.Locale bufLocale = buffer.adventure$locale;
|
||||
+ LENIENT_JSON.apply(ByteBufCodecs.fromCodec(OPS, ComponentSerialization.localizedCodec(bufLocale == null ? java.util.Locale.US : bufLocale))).encode(buffer, value);
|
||||
+ }
|
||||
+ },
|
||||
+ // Paper end - localized codec
|
||||
ClientboundLoginDisconnectPacket::reason,
|
||||
ClientboundLoginDisconnectPacket::new
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user