diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/network')
14 files changed, 3573 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/Connection.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/Connection.java.patch new file mode 100644 index 0000000000..e15b114d99 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/Connection.java.patch @@ -0,0 +1,386 @@ +--- a/net/minecraft/network/Connection.java ++++ b/net/minecraft/network/Connection.java +@@ -50,7 +50,7 @@ + import net.minecraft.network.protocol.login.ClientLoginPacketListener; + import net.minecraft.network.protocol.login.ClientboundLoginDisconnectPacket; + import net.minecraft.network.protocol.status.ClientStatusPacketListener; +-import net.minecraft.server.RunningOnDifferentThreadException; ++import net.minecraft.server.CancelledPacketHandleException; + import net.minecraft.util.Mth; + import net.minecraft.util.SampleLogger; + import org.apache.commons.lang3.Validate; +@@ -72,8 +72,8 @@ + public static final Marker PACKET_SENT_MARKER = (Marker) Util.make(MarkerFactory.getMarker("PACKET_SENT"), (marker) -> { + marker.add(Connection.PACKET_MARKER); + }); +- public static final AttributeKey<ConnectionProtocol.CodecData<?>> ATTRIBUTE_SERVERBOUND_PROTOCOL = AttributeKey.valueOf("serverbound_protocol"); +- public static final AttributeKey<ConnectionProtocol.CodecData<?>> ATTRIBUTE_CLIENTBOUND_PROTOCOL = AttributeKey.valueOf("clientbound_protocol"); ++ public static final AttributeKey<ConnectionProtocol.a<?>> ATTRIBUTE_SERVERBOUND_PROTOCOL = AttributeKey.valueOf("serverbound_protocol"); ++ public static final AttributeKey<ConnectionProtocol.a<?>> ATTRIBUTE_CLIENTBOUND_PROTOCOL = AttributeKey.valueOf("clientbound_protocol"); + public static final Supplier<NioEventLoopGroup> NETWORK_WORKER_GROUP = Suppliers.memoize(() -> { + return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build()); + }); +@@ -85,8 +85,8 @@ + }); + private final PacketFlow receiving; + private final Queue<Consumer<Connection>> pendingActions = Queues.newConcurrentLinkedQueue(); +- private Channel channel; +- private SocketAddress address; ++ public Channel channel; ++ public SocketAddress address; + @Nullable + private volatile PacketListener disconnectListener; + @Nullable +@@ -105,12 +105,12 @@ + private volatile Component delayedDisconnect; + @Nullable + BandwidthDebugMonitor bandwidthDebugMonitor; ++ public String hostname = ""; // CraftBukkit - add field + +- public Connection(PacketFlow packetflow) { +- this.receiving = packetflow; ++ public Connection(PacketFlow receiving) { ++ this.receiving = receiving; + } + +- @Override + public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { + super.channelActive(channelhandlercontext); + this.channel = channelhandlercontext.channel(); +@@ -126,12 +126,10 @@ + channel.attr(Connection.ATTRIBUTE_CLIENTBOUND_PROTOCOL).set(ConnectionProtocol.HANDSHAKING.codec(PacketFlow.CLIENTBOUND)); + } + +- @Override + public void channelInactive(ChannelHandlerContext channelhandlercontext) { + this.disconnect(Component.translatable("disconnect.endOfStream")); + } + +- @Override + public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) { + if (throwable instanceof SkipPacketException) { + Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause()); +@@ -144,25 +142,25 @@ + Connection.LOGGER.debug("Timeout", throwable); + this.disconnect(Component.translatable("disconnect.timeout")); + } else { +- MutableComponent mutablecomponent = Component.translatable("disconnect.genericReason", "Internal Exception: " + throwable); ++ MutableComponent ichatmutablecomponent = Component.translatable("disconnect.genericReason", "Internal Exception: " + throwable); + + if (flag) { + Connection.LOGGER.debug("Failed to sent packet", throwable); + if (this.getSending() == PacketFlow.CLIENTBOUND) { +- ConnectionProtocol connectionprotocol = ((ConnectionProtocol.CodecData) this.channel.attr(Connection.ATTRIBUTE_CLIENTBOUND_PROTOCOL).get()).protocol(); +- Packet<?> packet = connectionprotocol == ConnectionProtocol.LOGIN ? new ClientboundLoginDisconnectPacket(mutablecomponent) : new ClientboundDisconnectPacket(mutablecomponent); ++ ConnectionProtocol enumprotocol = ((ConnectionProtocol.a) this.channel.attr(Connection.ATTRIBUTE_CLIENTBOUND_PROTOCOL).get()).protocol(); ++ Packet<?> packet = enumprotocol == ConnectionProtocol.LOGIN ? new ClientboundLoginDisconnectPacket(ichatmutablecomponent) : new ClientboundDisconnectPacket(ichatmutablecomponent); + + this.send((Packet) packet, PacketSendListener.thenRun(() -> { +- this.disconnect(mutablecomponent); ++ this.disconnect(ichatmutablecomponent); + })); + } else { +- this.disconnect(mutablecomponent); ++ this.disconnect(ichatmutablecomponent); + } + + this.setReadOnly(); + } else { + Connection.LOGGER.debug("Double fault", throwable); +- this.disconnect(mutablecomponent); ++ this.disconnect(ichatmutablecomponent); + } + } + +@@ -170,8 +168,7 @@ + } + } + +- @Override +- protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet<?> packet) { ++ protected void channelRead0(ChannelHandlerContext context, Packet<?> packet) { + if (this.channel.isOpen()) { + PacketListener packetlistener = this.packetListener; + +@@ -181,7 +178,7 @@ + if (packetlistener.shouldHandleMessage(packet)) { + try { + genericsFtw(packet, packetlistener); +- } catch (RunningOnDifferentThreadException runningondifferentthreadexception) { ++ } catch (CancelledPacketHandleException cancelledpackethandleexception) { + ; + } catch (RejectedExecutionException rejectedexecutionexception) { + this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); +@@ -197,8 +194,8 @@ + } + } + +- private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener packetlistener) { +- packet.handle(packetlistener); ++ private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) { ++ packet.handle((T) listener); // CraftBukkit - decompile error + } + + public void suspendInboundAfterProtocolChange() { +@@ -209,20 +206,20 @@ + this.channel.config().setAutoRead(true); + } + +- public void setListener(PacketListener packetlistener) { +- Validate.notNull(packetlistener, "packetListener", new Object[0]); +- PacketFlow packetflow = packetlistener.flow(); ++ public void setListener(PacketListener handler) { ++ Validate.notNull(handler, "packetListener", new Object[0]); ++ PacketFlow enumprotocoldirection = handler.flow(); + +- if (packetflow != this.receiving) { +- throw new IllegalStateException("Trying to set listener for wrong side: connection is " + this.receiving + ", but listener is " + packetflow); ++ if (enumprotocoldirection != this.receiving) { ++ throw new IllegalStateException("Trying to set listener for wrong side: connection is " + this.receiving + ", but listener is " + enumprotocoldirection); + } else { +- ConnectionProtocol connectionprotocol = packetlistener.protocol(); +- ConnectionProtocol connectionprotocol1 = ((ConnectionProtocol.CodecData) this.channel.attr(getProtocolKey(packetflow)).get()).protocol(); ++ ConnectionProtocol enumprotocol = handler.protocol(); ++ ConnectionProtocol enumprotocol1 = ((ConnectionProtocol.a) this.channel.attr(getProtocolKey(enumprotocoldirection)).get()).protocol(); + +- if (connectionprotocol1 != connectionprotocol) { +- throw new IllegalStateException("Trying to set listener for protocol " + connectionprotocol.id() + ", but current " + packetflow + " protocol is " + connectionprotocol1.id()); ++ if (enumprotocol1 != enumprotocol) { ++ throw new IllegalStateException("Trying to set listener for protocol " + enumprotocol.id() + ", but current " + enumprotocoldirection + " protocol is " + enumprotocol1.id()); + } else { +- this.packetListener = packetlistener; ++ this.packetListener = handler; + this.disconnectListener = null; + } + } +@@ -238,20 +235,20 @@ + } + } + +- public void initiateServerboundStatusConnection(String s, int i, ClientStatusPacketListener clientstatuspacketlistener) { +- this.initiateServerboundConnection(s, i, clientstatuspacketlistener, ClientIntent.STATUS); ++ public void initiateServerboundStatusConnection(String s, int i, ClientStatusPacketListener packetstatusoutlistener) { ++ this.initiateServerboundConnection(s, i, packetstatusoutlistener, ClientIntent.STATUS); + } + +- public void initiateServerboundPlayConnection(String s, int i, ClientLoginPacketListener clientloginpacketlistener) { +- this.initiateServerboundConnection(s, i, clientloginpacketlistener, ClientIntent.LOGIN); ++ public void initiateServerboundPlayConnection(String s, int i, ClientLoginPacketListener packetloginoutlistener) { ++ this.initiateServerboundConnection(s, i, packetloginoutlistener, ClientIntent.LOGIN); + } + + private void initiateServerboundConnection(String s, int i, PacketListener packetlistener, ClientIntent clientintent) { + this.disconnectListener = packetlistener; +- this.runOnceConnected((connection) -> { +- connection.setClientboundProtocolAfterHandshake(clientintent); ++ this.runOnceConnected((networkmanager) -> { ++ networkmanager.setClientboundProtocolAfterHandshake(clientintent); + this.setListener(packetlistener); +- connection.sendPacket(new ClientIntentionPacket(SharedConstants.getCurrentVersion().getProtocolVersion(), s, i, clientintent), (PacketSendListener) null, true); ++ networkmanager.sendPacket(new ClientIntentionPacket(SharedConstants.getCurrentVersion().getProtocolVersion(), s, i, clientintent), (PacketSendListener) null, true); + }); + } + +@@ -263,8 +260,8 @@ + this.send(packet, (PacketSendListener) null); + } + +- public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) { +- this.send(packet, packetsendlistener, true); ++ public void send(Packet<?> packet, @Nullable PacketSendListener sendListener) { ++ this.send(packet, sendListener, true); + } + + public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, boolean flag) { +@@ -272,8 +269,8 @@ + this.flushQueue(); + this.sendPacket(packet, packetsendlistener, flag); + } else { +- this.pendingActions.add((connection) -> { +- connection.sendPacket(packet, packetsendlistener, flag); ++ this.pendingActions.add((networkmanager) -> { ++ networkmanager.sendPacket(packet, packetsendlistener, flag); + }); + } + +@@ -344,10 +341,10 @@ + + } + +- private static AttributeKey<ConnectionProtocol.CodecData<?>> getProtocolKey(PacketFlow packetflow) { ++ private static AttributeKey<ConnectionProtocol.a<?>> getProtocolKey(PacketFlow enumprotocoldirection) { + AttributeKey attributekey; + +- switch (packetflow) { ++ switch (enumprotocoldirection) { + case CLIENTBOUND: + attributekey = Connection.ATTRIBUTE_CLIENTBOUND_PROTOCOL; + break; +@@ -419,14 +416,14 @@ + return this.address == null ? "local" : (flag ? this.address.toString() : "IP hidden"); + } + +- public void disconnect(Component component) { ++ public void disconnect(Component message) { + if (this.channel == null) { +- this.delayedDisconnect = component; ++ this.delayedDisconnect = message; + } + + if (this.isConnected()) { +- this.channel.close().awaitUninterruptibly(); +- this.disconnectedReason = component; ++ this.channel.close(); // We can't wait as this may be called from an event loop. ++ this.disconnectedReason = message; + } + + } +@@ -444,23 +441,23 @@ + } + + public static Connection connectToServer(InetSocketAddress inetsocketaddress, boolean flag, @Nullable SampleLogger samplelogger) { +- Connection connection = new Connection(PacketFlow.CLIENTBOUND); ++ Connection networkmanager = new Connection(PacketFlow.CLIENTBOUND); + + if (samplelogger != null) { +- connection.setBandwidthLogger(samplelogger); ++ networkmanager.setBandwidthLogger(samplelogger); + } + +- ChannelFuture channelfuture = connect(inetsocketaddress, flag, connection); ++ ChannelFuture channelfuture = connect(inetsocketaddress, flag, networkmanager); + + channelfuture.syncUninterruptibly(); +- return connection; ++ return networkmanager; + } + +- public static ChannelFuture connect(InetSocketAddress inetsocketaddress, boolean flag, final Connection connection) { ++ public static ChannelFuture connect(InetSocketAddress address, boolean useEpollIfAvailable, final Connection connection) { + Class oclass; + EventLoopGroup eventloopgroup; + +- if (Epoll.isAvailable() && flag) { ++ if (Epoll.isAvailable() && useEpollIfAvailable) { + oclass = EpollSocketChannel.class; + eventloopgroup = (EventLoopGroup) Connection.NETWORK_EPOLL_WORKER_GROUP.get(); + } else { +@@ -469,7 +466,6 @@ + } + + return ((Bootstrap) ((Bootstrap) ((Bootstrap) (new Bootstrap()).group(eventloopgroup)).handler(new ChannelInitializer<Channel>() { +- @Override + protected void initChannel(Channel channel) { + Connection.setInitialProtocolAttributes(channel); + +@@ -484,13 +480,13 @@ + Connection.configureSerialization(channelpipeline, PacketFlow.CLIENTBOUND, connection.bandwidthDebugMonitor); + connection.configurePacketHandler(channelpipeline); + } +- })).channel(oclass)).connect(inetsocketaddress.getAddress(), inetsocketaddress.getPort()); ++ })).channel(oclass)).connect(address.getAddress(), address.getPort()); + } + +- public static void configureSerialization(ChannelPipeline channelpipeline, PacketFlow packetflow, @Nullable BandwidthDebugMonitor bandwidthdebugmonitor) { +- PacketFlow packetflow1 = packetflow.getOpposite(); +- AttributeKey<ConnectionProtocol.CodecData<?>> attributekey = getProtocolKey(packetflow); +- AttributeKey<ConnectionProtocol.CodecData<?>> attributekey1 = getProtocolKey(packetflow1); ++ public static void configureSerialization(ChannelPipeline channelpipeline, PacketFlow enumprotocoldirection, @Nullable BandwidthDebugMonitor bandwidthdebugmonitor) { ++ PacketFlow enumprotocoldirection1 = enumprotocoldirection.getOpposite(); ++ AttributeKey<ConnectionProtocol.a<?>> attributekey = getProtocolKey(enumprotocoldirection); ++ AttributeKey<ConnectionProtocol.a<?>> attributekey1 = getProtocolKey(enumprotocoldirection1); + + channelpipeline.addLast("splitter", new Varint21FrameDecoder(bandwidthdebugmonitor)).addLast("decoder", new PacketDecoder(attributekey)).addLast("prepender", new Varint21LengthFieldPrepender()).addLast("encoder", new PacketEncoder(attributekey1)).addLast("unbundler", new PacketBundleUnpacker(attributekey1)).addLast("bundler", new PacketBundlePacker(attributekey)); + } +@@ -499,38 +495,37 @@ + channelpipeline.addLast(new ChannelHandler[]{new FlowControlHandler()}).addLast("packet_handler", this); + } + +- private static void configureInMemoryPacketValidation(ChannelPipeline channelpipeline, PacketFlow packetflow) { +- PacketFlow packetflow1 = packetflow.getOpposite(); +- AttributeKey<ConnectionProtocol.CodecData<?>> attributekey = getProtocolKey(packetflow); +- AttributeKey<ConnectionProtocol.CodecData<?>> attributekey1 = getProtocolKey(packetflow1); ++ private static void configureInMemoryPacketValidation(ChannelPipeline channelpipeline, PacketFlow enumprotocoldirection) { ++ PacketFlow enumprotocoldirection1 = enumprotocoldirection.getOpposite(); ++ AttributeKey<ConnectionProtocol.a<?>> attributekey = getProtocolKey(enumprotocoldirection); ++ AttributeKey<ConnectionProtocol.a<?>> attributekey1 = getProtocolKey(enumprotocoldirection1); + + channelpipeline.addLast("validator", new PacketFlowValidator(attributekey, attributekey1)); + } + +- public static void configureInMemoryPipeline(ChannelPipeline channelpipeline, PacketFlow packetflow) { +- configureInMemoryPacketValidation(channelpipeline, packetflow); ++ public static void configureInMemoryPipeline(ChannelPipeline channelpipeline, PacketFlow enumprotocoldirection) { ++ configureInMemoryPacketValidation(channelpipeline, enumprotocoldirection); + } + +- public static Connection connectToLocalServer(SocketAddress socketaddress) { +- final Connection connection = new Connection(PacketFlow.CLIENTBOUND); ++ public static Connection connectToLocalServer(SocketAddress address) { ++ final Connection networkmanager = new Connection(PacketFlow.CLIENTBOUND); + + ((Bootstrap) ((Bootstrap) ((Bootstrap) (new Bootstrap()).group((EventLoopGroup) Connection.LOCAL_WORKER_GROUP.get())).handler(new ChannelInitializer<Channel>() { +- @Override + protected void initChannel(Channel channel) { + Connection.setInitialProtocolAttributes(channel); + ChannelPipeline channelpipeline = channel.pipeline(); + + Connection.configureInMemoryPipeline(channelpipeline, PacketFlow.CLIENTBOUND); +- connection.configurePacketHandler(channelpipeline); ++ networkmanager.configurePacketHandler(channelpipeline); + } +- })).channel(LocalChannel.class)).connect(socketaddress).syncUninterruptibly(); +- return connection; ++ })).channel(LocalChannel.class)).connect(address).syncUninterruptibly(); ++ return networkmanager; + } + +- public void setEncryptionKey(Cipher cipher, Cipher cipher1) { ++ public void setEncryptionKey(Cipher decryptingCipher, Cipher encryptingCipher) { + this.encrypted = true; +- this.channel.pipeline().addBefore("splitter", "decrypt", new CipherDecoder(cipher)); +- this.channel.pipeline().addBefore("prepender", "encrypt", new CipherEncoder(cipher1)); ++ this.channel.pipeline().addBefore("splitter", "decrypt", new CipherDecoder(decryptingCipher)); ++ this.channel.pipeline().addBefore("prepender", "encrypt", new CipherEncoder(encryptingCipher)); + } + + public boolean isEncrypted() { +@@ -562,18 +557,18 @@ + + } + +- public void setupCompression(int i, boolean flag) { +- if (i >= 0) { ++ public void setupCompression(int threshold, boolean validateDecompressed) { ++ if (threshold >= 0) { + if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) { +- ((CompressionDecoder) this.channel.pipeline().get("decompress")).setThreshold(i, flag); ++ ((CompressionDecoder) this.channel.pipeline().get("decompress")).setThreshold(threshold, validateDecompressed); + } else { +- this.channel.pipeline().addBefore("decoder", "decompress", new CompressionDecoder(i, flag)); ++ this.channel.pipeline().addBefore("decoder", "decompress", new CompressionDecoder(threshold, validateDecompressed)); + } + + if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) { +- ((CompressionEncoder) this.channel.pipeline().get("compress")).setThreshold(i); ++ ((CompressionEncoder) this.channel.pipeline().get("compress")).setThreshold(threshold); + } else { +- this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(i)); ++ this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(threshold)); + } + } else { + if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) { +@@ -597,11 +592,11 @@ + PacketListener packetlistener1 = packetlistener != null ? packetlistener : this.disconnectListener; + + if (packetlistener1 != null) { +- Component component = (Component) Objects.requireNonNullElseGet(this.getDisconnectedReason(), () -> { ++ Component ichatbasecomponent = (Component) Objects.requireNonNullElseGet(this.getDisconnectedReason(), () -> { + return Component.translatable("multiplayer.disconnect.generic"); + }); + +- packetlistener1.onDisconnect(component); ++ packetlistener1.onDisconnect(ichatbasecomponent); + } + + } diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/FriendlyByteBuf.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/FriendlyByteBuf.java.patch new file mode 100644 index 0000000000..b2743abcda --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/FriendlyByteBuf.java.patch @@ -0,0 +1,1851 @@ +--- a/net/minecraft/network/FriendlyByteBuf.java ++++ b/net/minecraft/network/FriendlyByteBuf.java +@@ -81,6 +81,8 @@ + import org.joml.Quaternionf; + import org.joml.Vector3f; + ++import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit ++ + public class FriendlyByteBuf extends ByteBuf { + + public static final int DEFAULT_NBT_QUOTA = 2097152; +@@ -92,8 +94,8 @@ + private static final int MAX_PUBLIC_KEY_LENGTH = 512; + private static final Gson GSON = new Gson(); + +- public FriendlyByteBuf(ByteBuf bytebuf) { +- this.source = bytebuf; ++ public FriendlyByteBuf(ByteBuf source) { ++ this.source = source; + } + + /** @deprecated */ +@@ -104,22 +106,22 @@ + + /** @deprecated */ + @Deprecated +- public <T> T readWithCodec(DynamicOps<Tag> dynamicops, Codec<T> codec, NbtAccounter nbtaccounter) { +- Tag tag = this.readNbt(nbtaccounter); ++ public <T> T readWithCodec(DynamicOps<Tag> dynamicops, Codec<T> codec, NbtAccounter nbtreadlimiter) { ++ Tag nbtbase = this.readNbt(nbtreadlimiter); + +- return Util.getOrThrow(codec.parse(dynamicops, tag), (s) -> { +- return new DecoderException("Failed to decode: " + s + " " + tag); ++ return Util.getOrThrow(codec.parse(dynamicops, nbtbase), (s) -> { ++ return new DecoderException("Failed to decode: " + s + " " + nbtbase); + }); + } + + /** @deprecated */ + @Deprecated + public <T> FriendlyByteBuf writeWithCodec(DynamicOps<Tag> dynamicops, Codec<T> codec, T t0) { +- Tag tag = (Tag) Util.getOrThrow(codec.encodeStart(dynamicops, t0), (s) -> { ++ Tag nbtbase = (Tag) Util.getOrThrow(codec.encodeStart(dynamicops, t0), (s) -> { + return new EncoderException("Failed to encode: " + s + " " + t0); + }); + +- this.writeNbt(tag); ++ this.writeNbt(nbtbase); + return this; + } + +@@ -132,58 +134,58 @@ + }); + } + +- public <T> void writeJsonWithCodec(Codec<T> codec, T t0) { +- DataResult<JsonElement> dataresult = codec.encodeStart(JsonOps.INSTANCE, t0); ++ public <T> void writeJsonWithCodec(Codec<T> codec, T value) { ++ DataResult<JsonElement> dataresult = codec.encodeStart(JsonOps.INSTANCE, value); + + this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) Util.getOrThrow(dataresult, (s) -> { +- return new EncoderException("Failed to encode: " + s + " " + t0); ++ return new EncoderException("Failed to encode: " + s + " " + value); + }))); + } + +- public <T> void writeId(IdMap<T> idmap, T t0) { +- int i = idmap.getId(t0); ++ public <T> void writeId(IdMap<T> idMap, T value) { ++ int i = idMap.getId(value); + + if (i == -1) { +- throw new IllegalArgumentException("Can't find id for '" + t0 + "' in map " + idmap); ++ throw new IllegalArgumentException("Can't find id for '" + value + "' in map " + idMap); + } else { + this.writeVarInt(i); + } + } + +- public <T> void writeId(IdMap<Holder<T>> idmap, Holder<T> holder, FriendlyByteBuf.Writer<T> friendlybytebuf_writer) { +- switch (holder.kind()) { ++ public <T> void writeId(IdMap<Holder<T>> idMap, Holder<T> value, FriendlyByteBuf.b<T> writer) { ++ switch (value.kind()) { + case REFERENCE: +- int i = idmap.getId(holder); ++ int i = idMap.getId(value); + + if (i == -1) { +- Object object = holder.value(); ++ Object object = value.value(); + +- throw new IllegalArgumentException("Can't find id for '" + object + "' in map " + idmap); ++ throw new IllegalArgumentException("Can't find id for '" + object + "' in map " + idMap); + } + + this.writeVarInt(i + 1); + break; + case DIRECT: + this.writeVarInt(0); +- friendlybytebuf_writer.accept(this, holder.value()); ++ writer.accept(this, value.value()); + } + + } + + @Nullable +- public <T> T readById(IdMap<T> idmap) { ++ public <T> T readById(IdMap<T> idMap) { + int i = this.readVarInt(); + +- return idmap.byId(i); ++ return idMap.byId(i); + } + +- public <T> Holder<T> readById(IdMap<Holder<T>> idmap, FriendlyByteBuf.Reader<T> friendlybytebuf_reader) { ++ public <T> Holder<T> readById(IdMap<Holder<T>> idMap, FriendlyByteBuf.a<T> reader) { + int i = this.readVarInt(); + + if (i == 0) { +- return Holder.direct(friendlybytebuf_reader.apply(this)); ++ return Holder.direct(reader.apply(this)); + } else { +- Holder<T> holder = (Holder) idmap.byId(i - 1); ++ Holder<T> holder = (Holder) idMap.byId(i - 1); + + if (holder == null) { + throw new IllegalArgumentException("Can't find element with id " + i); +@@ -193,41 +195,41 @@ + } + } + +- public static <T> IntFunction<T> limitValue(IntFunction<T> intfunction, int i) { ++ public static <T> IntFunction<T> limitValue(IntFunction<T> function, int limit) { + return (j) -> { +- if (j > i) { +- throw new DecoderException("Value " + j + " is larger than limit " + i); ++ if (j > limit) { ++ throw new DecoderException("Value " + j + " is larger than limit " + limit); + } else { +- return intfunction.apply(j); ++ return function.apply(j); + } + }; + } + +- public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, FriendlyByteBuf.Reader<T> friendlybytebuf_reader) { ++ public <T, C extends Collection<T>> C readCollection(IntFunction<C> collectionFactory, FriendlyByteBuf.a<T> elementReader) { + int i = this.readVarInt(); +- C c0 = (Collection) intfunction.apply(i); ++ C c0 = collectionFactory.apply(i); // CraftBukkit - decompile error + + for (int j = 0; j < i; ++j) { +- c0.add(friendlybytebuf_reader.apply(this)); ++ c0.add(elementReader.apply(this)); + } + + return c0; + } + +- public <T> void writeCollection(Collection<T> collection, FriendlyByteBuf.Writer<T> friendlybytebuf_writer) { ++ public <T> void writeCollection(Collection<T> collection, FriendlyByteBuf.b<T> elementWriter) { + this.writeVarInt(collection.size()); +- Iterator iterator = collection.iterator(); ++ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error + + while (iterator.hasNext()) { + T t0 = iterator.next(); + +- friendlybytebuf_writer.accept(this, t0); ++ elementWriter.accept(this, t0); + } + + } + +- public <T> List<T> readList(FriendlyByteBuf.Reader<T> friendlybytebuf_reader) { +- return (List) this.readCollection(Lists::newArrayListWithCapacity, friendlybytebuf_reader); ++ public <T> List<T> readList(FriendlyByteBuf.a<T> elementReader) { ++ return (List) this.readCollection(Lists::newArrayListWithCapacity, elementReader); + } + + public IntList readIntIdList() { +@@ -241,18 +243,18 @@ + return intarraylist; + } + +- public void writeIntIdList(IntList intlist) { +- this.writeVarInt(intlist.size()); +- intlist.forEach(this::writeVarInt); ++ public void writeIntIdList(IntList itIdList) { ++ this.writeVarInt(itIdList.size()); ++ itIdList.forEach((java.util.function.IntConsumer) this::writeVarInt); // CraftBukkit - decompile error + } + +- public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> intfunction, FriendlyByteBuf.Reader<K> friendlybytebuf_reader, FriendlyByteBuf.Reader<V> friendlybytebuf_reader1) { ++ public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> mapFactory, FriendlyByteBuf.a<K> keyReader, FriendlyByteBuf.a<V> valueReader) { + int i = this.readVarInt(); +- M m0 = (Map) intfunction.apply(i); ++ M m0 = mapFactory.apply(i); // CraftBukkit - decompile error + + for (int j = 0; j < i; ++j) { +- K k0 = friendlybytebuf_reader.apply(this); +- V v0 = friendlybytebuf_reader1.apply(this); ++ K k0 = keyReader.apply(this); ++ V v0 = valueReader.apply(this); + + m0.put(k0, v0); + } +@@ -260,42 +262,42 @@ + return m0; + } + +- public <K, V> Map<K, V> readMap(FriendlyByteBuf.Reader<K> friendlybytebuf_reader, FriendlyByteBuf.Reader<V> friendlybytebuf_reader1) { +- return this.readMap(Maps::newHashMapWithExpectedSize, friendlybytebuf_reader, friendlybytebuf_reader1); ++ public <K, V> Map<K, V> readMap(FriendlyByteBuf.a<K> keyReader, FriendlyByteBuf.a<V> valueReader) { ++ return this.readMap(Maps::newHashMapWithExpectedSize, keyReader, valueReader); + } + +- public <K, V> void writeMap(Map<K, V> map, FriendlyByteBuf.Writer<K> friendlybytebuf_writer, FriendlyByteBuf.Writer<V> friendlybytebuf_writer1) { ++ public <K, V> void writeMap(Map<K, V> map, FriendlyByteBuf.b<K> keyWriter, FriendlyByteBuf.b<V> valueWriter) { + this.writeVarInt(map.size()); + map.forEach((object, object1) -> { +- friendlybytebuf_writer.accept(this, object); +- friendlybytebuf_writer1.accept(this, object1); ++ keyWriter.accept(this, object); ++ valueWriter.accept(this, object1); + }); + } + +- public void readWithCount(Consumer<FriendlyByteBuf> consumer) { ++ public void readWithCount(Consumer<FriendlyByteBuf> reader) { + int i = this.readVarInt(); + + for (int j = 0; j < i; ++j) { +- consumer.accept(this); ++ reader.accept(this); + } + + } + +- public <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumset, Class<E> oclass) { +- E[] ae = (Enum[]) oclass.getEnumConstants(); ++ public <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumSet, Class<E> enumClass) { ++ E[] ae = enumClass.getEnumConstants(); // CraftBukkit - decompile error + BitSet bitset = new BitSet(ae.length); + + for (int i = 0; i < ae.length; ++i) { +- bitset.set(i, enumset.contains(ae[i])); ++ bitset.set(i, enumSet.contains(ae[i])); + } + + this.writeFixedBitSet(bitset, ae.length); + } + +- public <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> oclass) { +- E[] ae = (Enum[]) oclass.getEnumConstants(); ++ public <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> enumClass) { ++ E[] ae = enumClass.getEnumConstants(); // CraftBukkit - decompile error + BitSet bitset = this.readFixedBitSet(ae.length); +- EnumSet<E> enumset = EnumSet.noneOf(oclass); ++ EnumSet<E> enumset = EnumSet.noneOf(enumClass); + + for (int i = 0; i < ae.length; ++i) { + if (bitset.get(i)) { +@@ -306,64 +308,64 @@ + return enumset; + } + +- public <T> void writeOptional(Optional<T> optional, FriendlyByteBuf.Writer<T> friendlybytebuf_writer) { ++ public <T> void writeOptional(Optional<T> optional, FriendlyByteBuf.b<T> writer) { + if (optional.isPresent()) { + this.writeBoolean(true); +- friendlybytebuf_writer.accept(this, optional.get()); ++ writer.accept(this, optional.get()); + } else { + this.writeBoolean(false); + } + + } + +- public <T> Optional<T> readOptional(FriendlyByteBuf.Reader<T> friendlybytebuf_reader) { +- return this.readBoolean() ? Optional.of(friendlybytebuf_reader.apply(this)) : Optional.empty(); ++ public <T> Optional<T> readOptional(FriendlyByteBuf.a<T> reader) { ++ return this.readBoolean() ? Optional.of(reader.apply(this)) : Optional.empty(); + } + + @Nullable +- public <T> T readNullable(FriendlyByteBuf.Reader<T> friendlybytebuf_reader) { +- return this.readBoolean() ? friendlybytebuf_reader.apply(this) : null; ++ public <T> T readNullable(FriendlyByteBuf.a<T> reader) { ++ return this.readBoolean() ? reader.apply(this) : null; + } + +- public <T> void writeNullable(@Nullable T t0, FriendlyByteBuf.Writer<T> friendlybytebuf_writer) { +- if (t0 != null) { ++ public <T> void writeNullable(@Nullable T value, FriendlyByteBuf.b<T> writer) { ++ if (value != null) { + this.writeBoolean(true); +- friendlybytebuf_writer.accept(this, t0); ++ writer.accept(this, value); + } else { + this.writeBoolean(false); + } + + } + +- public <L, R> void writeEither(Either<L, R> either, FriendlyByteBuf.Writer<L> friendlybytebuf_writer, FriendlyByteBuf.Writer<R> friendlybytebuf_writer1) { +- either.ifLeft((object) -> { ++ public <L, R> void writeEither(Either<L, R> value, FriendlyByteBuf.b<L> leftWriter, FriendlyByteBuf.b<R> rightWriter) { ++ value.ifLeft((object) -> { + this.writeBoolean(true); +- friendlybytebuf_writer.accept(this, object); ++ leftWriter.accept(this, object); + }).ifRight((object) -> { + this.writeBoolean(false); +- friendlybytebuf_writer1.accept(this, object); ++ rightWriter.accept(this, object); + }); + } + +- public <L, R> Either<L, R> readEither(FriendlyByteBuf.Reader<L> friendlybytebuf_reader, FriendlyByteBuf.Reader<R> friendlybytebuf_reader1) { +- return this.readBoolean() ? Either.left(friendlybytebuf_reader.apply(this)) : Either.right(friendlybytebuf_reader1.apply(this)); ++ public <L, R> Either<L, R> readEither(FriendlyByteBuf.a<L> leftReader, FriendlyByteBuf.a<R> rightReader) { ++ return this.readBoolean() ? Either.left(leftReader.apply(this)) : Either.right(rightReader.apply(this)); + } + + public byte[] readByteArray() { + return this.readByteArray(this.readableBytes()); + } + +- public FriendlyByteBuf writeByteArray(byte[] abyte) { +- this.writeVarInt(abyte.length); +- this.writeBytes(abyte); ++ public FriendlyByteBuf writeByteArray(byte[] array) { ++ this.writeVarInt(array.length); ++ this.writeBytes(array); + return this; + } + +- public byte[] readByteArray(int i) { ++ public byte[] readByteArray(int maxLength) { + int j = this.readVarInt(); + +- if (j > i) { +- throw new DecoderException("ByteArray with size " + j + " is bigger than allowed " + i); ++ if (j > maxLength) { ++ throw new DecoderException("ByteArray with size " + j + " is bigger than allowed " + maxLength); + } else { + byte[] abyte = new byte[j]; + +@@ -372,10 +374,10 @@ + } + } + +- public FriendlyByteBuf writeVarIntArray(int[] aint) { +- this.writeVarInt(aint.length); +- int[] aint1 = aint; +- int i = aint.length; ++ public FriendlyByteBuf writeVarIntArray(int[] array) { ++ this.writeVarInt(array.length); ++ int[] aint1 = array; ++ int i = array.length; + + for (int j = 0; j < i; ++j) { + int k = aint1[j]; +@@ -390,11 +392,11 @@ + return this.readVarIntArray(this.readableBytes()); + } + +- public int[] readVarIntArray(int i) { ++ public int[] readVarIntArray(int maxLength) { + int j = this.readVarInt(); + +- if (j > i) { +- throw new DecoderException("VarIntArray with size " + j + " is bigger than allowed " + i); ++ if (j > maxLength) { ++ throw new DecoderException("VarIntArray with size " + j + " is bigger than allowed " + maxLength); + } else { + int[] aint = new int[j]; + +@@ -406,10 +408,10 @@ + } + } + +- public FriendlyByteBuf writeLongArray(long[] along) { +- this.writeVarInt(along.length); +- long[] along1 = along; +- int i = along.length; ++ public FriendlyByteBuf writeLongArray(long[] array) { ++ this.writeVarInt(array.length); ++ long[] along1 = array; ++ int i = array.length; + + for (int j = 0; j < i; ++j) { + long k = along1[j]; +@@ -424,34 +426,34 @@ + return this.readLongArray((long[]) null); + } + +- public long[] readLongArray(@Nullable long[] along) { +- return this.readLongArray(along, this.readableBytes() / 8); ++ public long[] readLongArray(@Nullable long[] array) { ++ return this.readLongArray(array, this.readableBytes() / 8); + } + +- public long[] readLongArray(@Nullable long[] along, int i) { ++ public long[] readLongArray(@Nullable long[] array, int maxLength) { + int j = this.readVarInt(); + +- if (along == null || along.length != j) { +- if (j > i) { +- throw new DecoderException("LongArray with size " + j + " is bigger than allowed " + i); ++ if (array == null || array.length != j) { ++ if (j > maxLength) { ++ throw new DecoderException("LongArray with size " + j + " is bigger than allowed " + maxLength); + } + +- along = new long[j]; ++ array = new long[j]; + } + +- for (int k = 0; k < along.length; ++k) { +- along[k] = this.readLong(); ++ for (int k = 0; k < array.length; ++k) { ++ array[k] = this.readLong(); + } + +- return along; ++ return array; + } + + public BlockPos readBlockPos() { + return BlockPos.of(this.readLong()); + } + +- public FriendlyByteBuf writeBlockPos(BlockPos blockpos) { +- this.writeLong(blockpos.asLong()); ++ public FriendlyByteBuf writeBlockPos(BlockPos pos) { ++ this.writeLong(pos.asLong()); + return this; + } + +@@ -459,8 +461,8 @@ + return new ChunkPos(this.readLong()); + } + +- public FriendlyByteBuf writeChunkPos(ChunkPos chunkpos) { +- this.writeLong(chunkpos.toLong()); ++ public FriendlyByteBuf writeChunkPos(ChunkPos chunkPos) { ++ this.writeLong(chunkPos.toLong()); + return this; + } + +@@ -468,21 +470,21 @@ + return SectionPos.of(this.readLong()); + } + +- public FriendlyByteBuf writeSectionPos(SectionPos sectionpos) { +- this.writeLong(sectionpos.asLong()); ++ public FriendlyByteBuf writeSectionPos(SectionPos sectionPos) { ++ this.writeLong(sectionPos.asLong()); + return this; + } + + public GlobalPos readGlobalPos() { + ResourceKey<Level> resourcekey = this.readResourceKey(Registries.DIMENSION); +- BlockPos blockpos = this.readBlockPos(); ++ BlockPos blockposition = this.readBlockPos(); + +- return GlobalPos.of(resourcekey, blockpos); ++ return GlobalPos.of(resourcekey, blockposition); + } + +- public void writeGlobalPos(GlobalPos globalpos) { +- this.writeResourceKey(globalpos.dimension()); +- this.writeBlockPos(globalpos.pos()); ++ public void writeGlobalPos(GlobalPos pos) { ++ this.writeResourceKey(pos.dimension()); ++ this.writeBlockPos(pos.pos()); + } + + public Vector3f readVector3f() { +@@ -499,21 +501,21 @@ + return new Quaternionf(this.readFloat(), this.readFloat(), this.readFloat(), this.readFloat()); + } + +- public void writeQuaternion(Quaternionf quaternionf) { +- this.writeFloat(quaternionf.x); +- this.writeFloat(quaternionf.y); +- this.writeFloat(quaternionf.z); +- this.writeFloat(quaternionf.w); ++ public void writeQuaternion(Quaternionf quaternion) { ++ this.writeFloat(quaternion.x); ++ this.writeFloat(quaternion.y); ++ this.writeFloat(quaternion.z); ++ this.writeFloat(quaternion.w); + } + + public Vec3 readVec3() { + return new Vec3(this.readDouble(), this.readDouble(), this.readDouble()); + } + +- public void writeVec3(Vec3 vec3) { +- this.writeDouble(vec3.x()); +- this.writeDouble(vec3.y()); +- this.writeDouble(vec3.z()); ++ public void writeVec3(Vec3 vec3d) { ++ this.writeDouble(vec3d.x()); ++ this.writeDouble(vec3d.y()); ++ this.writeDouble(vec3d.z()); + } + + public Component readComponent() { +@@ -528,12 +530,12 @@ + return this.writeWithCodec(NbtOps.INSTANCE, ComponentSerialization.CODEC, component); + } + +- public <T extends Enum<T>> T readEnum(Class<T> oclass) { +- return ((Enum[]) oclass.getEnumConstants())[this.readVarInt()]; ++ public <T extends Enum<T>> T readEnum(Class<T> enumClass) { ++ return ((T[]) enumClass.getEnumConstants())[this.readVarInt()]; // CraftBukkit - fix decompile error + } + +- public FriendlyByteBuf writeEnum(Enum<?> oenum) { +- return this.writeVarInt(oenum.ordinal()); ++ public FriendlyByteBuf writeEnum(Enum<?> value) { ++ return this.writeVarInt(value.ordinal()); + } + + public <T> T readById(IntFunction<T> intfunction) { +@@ -566,67 +568,67 @@ + return new UUID(this.readLong(), this.readLong()); + } + +- public FriendlyByteBuf writeVarInt(int i) { +- VarInt.write(this.source, i); ++ public FriendlyByteBuf writeVarInt(int input) { ++ VarInt.write(this.source, input); + return this; + } + +- public FriendlyByteBuf writeVarLong(long i) { +- VarLong.write(this.source, i); ++ public FriendlyByteBuf writeVarLong(long value) { ++ VarLong.write(this.source, value); + return this; + } + +- public FriendlyByteBuf writeNbt(@Nullable Tag tag) { +- if (tag == null) { +- tag = EndTag.INSTANCE; ++ public FriendlyByteBuf writeNbt(@Nullable Tag nbtbase) { ++ if (nbtbase == null) { ++ nbtbase = EndTag.INSTANCE; + } + + try { +- NbtIo.writeAnyTag((Tag) tag, new ByteBufOutputStream(this)); ++ NbtIo.writeAnyTag((Tag) nbtbase, new ByteBufOutputStream(this)); + return this; +- } catch (IOException ioexception) { ++ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception + throw new EncoderException(ioexception); + } + } + + @Nullable + public CompoundTag readNbt() { +- Tag tag = this.readNbt(NbtAccounter.create(2097152L)); ++ Tag nbtbase = this.readNbt(NbtAccounter.create(2097152L)); + +- if (tag != null && !(tag instanceof CompoundTag)) { +- throw new DecoderException("Not a compound tag: " + tag); ++ if (nbtbase != null && !(nbtbase instanceof CompoundTag)) { ++ throw new DecoderException("Not a compound tag: " + nbtbase); + } else { +- return (CompoundTag) tag; ++ return (CompoundTag) nbtbase; + } + } + + @Nullable +- public Tag readNbt(NbtAccounter nbtaccounter) { ++ public Tag readNbt(NbtAccounter nbtreadlimiter) { + try { +- Tag tag = NbtIo.readAnyTag(new ByteBufInputStream(this), nbtaccounter); ++ Tag nbtbase = NbtIo.readAnyTag(new ByteBufInputStream(this), nbtreadlimiter); + +- return tag.getId() == 0 ? null : tag; ++ return nbtbase.getId() == 0 ? null : nbtbase; + } catch (IOException ioexception) { + throw new EncoderException(ioexception); + } + } + +- public FriendlyByteBuf writeItem(ItemStack itemstack) { +- if (itemstack.isEmpty()) { ++ public FriendlyByteBuf writeItem(ItemStack stack) { ++ if (stack.isEmpty() || stack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() + this.writeBoolean(false); + } else { + this.writeBoolean(true); +- Item item = itemstack.getItem(); ++ Item item = stack.getItem(); + + this.writeId(BuiltInRegistries.ITEM, item); +- this.writeByte(itemstack.getCount()); +- CompoundTag compoundtag = null; ++ this.writeByte(stack.getCount()); ++ CompoundTag nbttagcompound = null; + + if (item.canBeDepleted() || item.shouldOverrideMultiplayerNbt()) { +- compoundtag = itemstack.getTag(); ++ nbttagcompound = stack.getTag(); + } + +- this.writeNbt(compoundtag); ++ this.writeNbt(nbttagcompound); + } + + return this; +@@ -641,6 +643,11 @@ + ItemStack itemstack = new ItemStack(item, b0); + + itemstack.setTag(this.readNbt()); ++ // CraftBukkit start ++ if (itemstack.getTag() != null) { ++ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); ++ } ++ // CraftBukkit end + return itemstack; + } + } +@@ -649,16 +656,16 @@ + return this.readUtf(32767); + } + +- public String readUtf(int i) { +- return Utf8String.read(this.source, i); ++ public String readUtf(int maxLength) { ++ return Utf8String.read(this.source, maxLength); + } + +- public FriendlyByteBuf writeUtf(String s) { +- return this.writeUtf(s, 32767); ++ public FriendlyByteBuf writeUtf(String string) { ++ return this.writeUtf(string, 32767); + } + +- public FriendlyByteBuf writeUtf(String s, int i) { +- Utf8String.write(this.source, s, i); ++ public FriendlyByteBuf writeUtf(String string, int maxLength) { ++ Utf8String.write(this.source, string, maxLength); + return this; + } + +@@ -666,33 +673,33 @@ + return new ResourceLocation(this.readUtf(32767)); + } + +- public FriendlyByteBuf writeResourceLocation(ResourceLocation resourcelocation) { +- this.writeUtf(resourcelocation.toString()); ++ public FriendlyByteBuf writeResourceLocation(ResourceLocation resourceLocation) { ++ this.writeUtf(resourceLocation.toString()); + return this; + } + +- public <T> ResourceKey<T> readResourceKey(ResourceKey<? extends Registry<T>> resourcekey) { +- ResourceLocation resourcelocation = this.readResourceLocation(); ++ public <T> ResourceKey<T> readResourceKey(ResourceKey<? extends Registry<T>> registryKey) { ++ ResourceLocation minecraftkey = this.readResourceLocation(); + +- return ResourceKey.create(resourcekey, resourcelocation); ++ return ResourceKey.create(registryKey, minecraftkey); + } + +- public void writeResourceKey(ResourceKey<?> resourcekey) { +- this.writeResourceLocation(resourcekey.location()); ++ public void writeResourceKey(ResourceKey<?> resourceKey) { ++ this.writeResourceLocation(resourceKey.location()); + } + + public <T> ResourceKey<? extends Registry<T>> readRegistryKey() { +- ResourceLocation resourcelocation = this.readResourceLocation(); ++ ResourceLocation minecraftkey = this.readResourceLocation(); + +- return ResourceKey.createRegistryKey(resourcelocation); ++ return ResourceKey.createRegistryKey(minecraftkey); + } + + public Date readDate() { + return new Date(this.readLong()); + } + +- public FriendlyByteBuf writeDate(Date date) { +- this.writeLong(date.getTime()); ++ public FriendlyByteBuf writeDate(Date time) { ++ this.writeLong(time.getTime()); + return this; + } + +@@ -707,64 +714,64 @@ + public PublicKey readPublicKey() { + try { + return Crypt.byteToPublicKey(this.readByteArray(512)); +- } catch (CryptException cryptexception) { +- throw new DecoderException("Malformed public key bytes", cryptexception); ++ } catch (CryptException cryptographyexception) { ++ throw new DecoderException("Malformed public key bytes", cryptographyexception); + } + } + +- public FriendlyByteBuf writePublicKey(PublicKey publickey) { +- this.writeByteArray(publickey.getEncoded()); ++ public FriendlyByteBuf writePublicKey(PublicKey publicKey) { ++ this.writeByteArray(publicKey.getEncoded()); + return this; + } + + public BlockHitResult readBlockHitResult() { +- BlockPos blockpos = this.readBlockPos(); +- Direction direction = (Direction) this.readEnum(Direction.class); ++ BlockPos blockposition = this.readBlockPos(); ++ Direction enumdirection = (Direction) this.readEnum(Direction.class); + float f = this.readFloat(); + float f1 = this.readFloat(); + float f2 = this.readFloat(); + boolean flag = this.readBoolean(); + +- return new BlockHitResult(new Vec3((double) blockpos.getX() + (double) f, (double) blockpos.getY() + (double) f1, (double) blockpos.getZ() + (double) f2), direction, blockpos, flag); ++ return new BlockHitResult(new Vec3((double) blockposition.getX() + (double) f, (double) blockposition.getY() + (double) f1, (double) blockposition.getZ() + (double) f2), enumdirection, blockposition, flag); + } + +- public void writeBlockHitResult(BlockHitResult blockhitresult) { +- BlockPos blockpos = blockhitresult.getBlockPos(); ++ public void writeBlockHitResult(BlockHitResult result) { ++ BlockPos blockposition = result.getBlockPos(); + +- this.writeBlockPos(blockpos); +- this.writeEnum(blockhitresult.getDirection()); +- Vec3 vec3 = blockhitresult.getLocation(); ++ this.writeBlockPos(blockposition); ++ this.writeEnum(result.getDirection()); ++ Vec3 vec3d = result.getLocation(); + +- this.writeFloat((float) (vec3.x - (double) blockpos.getX())); +- this.writeFloat((float) (vec3.y - (double) blockpos.getY())); +- this.writeFloat((float) (vec3.z - (double) blockpos.getZ())); +- this.writeBoolean(blockhitresult.isInside()); ++ this.writeFloat((float) (vec3d.x - (double) blockposition.getX())); ++ this.writeFloat((float) (vec3d.y - (double) blockposition.getY())); ++ this.writeFloat((float) (vec3d.z - (double) blockposition.getZ())); ++ this.writeBoolean(result.isInside()); + } + + public BitSet readBitSet() { + return BitSet.valueOf(this.readLongArray()); + } + +- public void writeBitSet(BitSet bitset) { +- this.writeLongArray(bitset.toLongArray()); ++ public void writeBitSet(BitSet bitSet) { ++ this.writeLongArray(bitSet.toLongArray()); + } + +- public BitSet readFixedBitSet(int i) { +- byte[] abyte = new byte[Mth.positiveCeilDiv(i, 8)]; ++ public BitSet readFixedBitSet(int size) { ++ byte[] abyte = new byte[Mth.positiveCeilDiv(size, 8)]; + + this.readBytes(abyte); + return BitSet.valueOf(abyte); + } + +- public void writeFixedBitSet(BitSet bitset, int i) { +- if (bitset.length() > i) { +- int j = bitset.length(); ++ public void writeFixedBitSet(BitSet bitSet, int size) { ++ if (bitSet.length() > size) { ++ int j = bitSet.length(); + +- throw new EncoderException("BitSet is larger than expected size (" + j + ">" + i + ")"); ++ throw new EncoderException("BitSet is larger than expected size (" + j + ">" + size + ")"); + } else { +- byte[] abyte = bitset.toByteArray(); ++ byte[] abyte = bitSet.toByteArray(); + +- this.writeBytes(Arrays.copyOf(abyte, Mth.positiveCeilDiv(i, 8))); ++ this.writeBytes(Arrays.copyOf(abyte, Mth.positiveCeilDiv(size, 8))); + } + } + +@@ -777,16 +784,16 @@ + return gameprofile; + } + +- public void writeGameProfile(GameProfile gameprofile) { +- this.writeUUID(gameprofile.getId()); +- this.writeUtf(gameprofile.getName()); +- this.writeGameProfileProperties(gameprofile.getProperties()); ++ public void writeGameProfile(GameProfile gameProfile) { ++ this.writeUUID(gameProfile.getId()); ++ this.writeUtf(gameProfile.getName()); ++ this.writeGameProfileProperties(gameProfile.getProperties()); + } + + public PropertyMap readGameProfileProperties() { + PropertyMap propertymap = new PropertyMap(); + +- this.readWithCount((friendlybytebuf) -> { ++ this.readWithCount((packetdataserializer) -> { + Property property = this.readProperty(); + + propertymap.put(property.name(), property); +@@ -794,8 +801,8 @@ + return propertymap; + } + +- public void writeGameProfileProperties(PropertyMap propertymap) { +- this.writeCollection(propertymap.values(), FriendlyByteBuf::writeProperty); ++ public void writeGameProfileProperties(PropertyMap gameProfileProperties) { ++ this.writeCollection(gameProfileProperties.values(), FriendlyByteBuf::writeProperty); + } + + public Property readProperty() { +@@ -812,1018 +819,833 @@ + this.writeNullable(property.signature(), FriendlyByteBuf::writeUtf); + } + +- @Override + public boolean isContiguous() { + return this.source.isContiguous(); + } + +- @Override + public int maxFastWritableBytes() { + return this.source.maxFastWritableBytes(); + } + +- @Override + public int capacity() { + return this.source.capacity(); + } + +- @Override + public FriendlyByteBuf capacity(int i) { + this.source.capacity(i); + return this; + } + +- @Override + public int maxCapacity() { + return this.source.maxCapacity(); + } + +- @Override + public ByteBufAllocator alloc() { + return this.source.alloc(); + } + +- @Override + public ByteOrder order() { + return this.source.order(); + } + +- @Override + public ByteBuf order(ByteOrder byteorder) { + return this.source.order(byteorder); + } + +- @Override + public ByteBuf unwrap() { + return this.source; + } + +- @Override + public boolean isDirect() { + return this.source.isDirect(); + } + +- @Override + public boolean isReadOnly() { + return this.source.isReadOnly(); + } + +- @Override + public ByteBuf asReadOnly() { + return this.source.asReadOnly(); + } + +- @Override + public int readerIndex() { + return this.source.readerIndex(); + } + +- @Override + public FriendlyByteBuf readerIndex(int i) { + this.source.readerIndex(i); + return this; + } + +- @Override + public int writerIndex() { + return this.source.writerIndex(); + } + +- @Override + public FriendlyByteBuf writerIndex(int i) { + this.source.writerIndex(i); + return this; + } + +- @Override + public FriendlyByteBuf setIndex(int i, int j) { + this.source.setIndex(i, j); + return this; + } + +- @Override + public int readableBytes() { + return this.source.readableBytes(); + } + +- @Override + public int writableBytes() { + return this.source.writableBytes(); + } + +- @Override + public int maxWritableBytes() { + return this.source.maxWritableBytes(); + } + +- @Override + public boolean isReadable() { + return this.source.isReadable(); + } + +- @Override + public boolean isReadable(int i) { + return this.source.isReadable(i); + } + +- @Override + public boolean isWritable() { + return this.source.isWritable(); + } + +- @Override + public boolean isWritable(int i) { + return this.source.isWritable(i); + } + +- @Override + public FriendlyByteBuf clear() { + this.source.clear(); + return this; + } + +- @Override + public FriendlyByteBuf markReaderIndex() { + this.source.markReaderIndex(); + return this; + } + +- @Override + public FriendlyByteBuf resetReaderIndex() { + this.source.resetReaderIndex(); + return this; + } + +- @Override + public FriendlyByteBuf markWriterIndex() { + this.source.markWriterIndex(); + return this; + } + +- @Override + public FriendlyByteBuf resetWriterIndex() { + this.source.resetWriterIndex(); + return this; + } + +- @Override + public FriendlyByteBuf discardReadBytes() { + this.source.discardReadBytes(); + return this; + } + +- @Override + public FriendlyByteBuf discardSomeReadBytes() { + this.source.discardSomeReadBytes(); + return this; + } + +- @Override + public FriendlyByteBuf ensureWritable(int i) { + this.source.ensureWritable(i); + return this; + } + +- @Override + public int ensureWritable(int i, boolean flag) { + return this.source.ensureWritable(i, flag); + } + +- @Override + public boolean getBoolean(int i) { + return this.source.getBoolean(i); + } + +- @Override + public byte getByte(int i) { + return this.source.getByte(i); + } + +- @Override + public short getUnsignedByte(int i) { + return this.source.getUnsignedByte(i); + } + +- @Override + public short getShort(int i) { + return this.source.getShort(i); + } + +- @Override + public short getShortLE(int i) { + return this.source.getShortLE(i); + } + +- @Override + public int getUnsignedShort(int i) { + return this.source.getUnsignedShort(i); + } + +- @Override + public int getUnsignedShortLE(int i) { + return this.source.getUnsignedShortLE(i); + } + +- @Override + public int getMedium(int i) { + return this.source.getMedium(i); + } + +- @Override + public int getMediumLE(int i) { + return this.source.getMediumLE(i); + } + +- @Override + public int getUnsignedMedium(int i) { + return this.source.getUnsignedMedium(i); + } + +- @Override + public int getUnsignedMediumLE(int i) { + return this.source.getUnsignedMediumLE(i); + } + +- @Override + public int getInt(int i) { + return this.source.getInt(i); + } + +- @Override + public int getIntLE(int i) { + return this.source.getIntLE(i); + } + +- @Override + public long getUnsignedInt(int i) { + return this.source.getUnsignedInt(i); + } + +- @Override + public long getUnsignedIntLE(int i) { + return this.source.getUnsignedIntLE(i); + } + +- @Override + public long getLong(int i) { + return this.source.getLong(i); + } + +- @Override + public long getLongLE(int i) { + return this.source.getLongLE(i); + } + +- @Override + public char getChar(int i) { + return this.source.getChar(i); + } + +- @Override + public float getFloat(int i) { + return this.source.getFloat(i); + } + +- @Override + public double getDouble(int i) { + return this.source.getDouble(i); + } + +- @Override + public FriendlyByteBuf getBytes(int i, ByteBuf bytebuf) { + this.source.getBytes(i, bytebuf); + return this; + } + +- @Override + public FriendlyByteBuf getBytes(int i, ByteBuf bytebuf, int j) { + this.source.getBytes(i, bytebuf, j); + return this; + } + +- @Override + public FriendlyByteBuf getBytes(int i, ByteBuf bytebuf, int j, int k) { + this.source.getBytes(i, bytebuf, j, k); + return this; + } + +- @Override + public FriendlyByteBuf getBytes(int i, byte[] abyte) { + this.source.getBytes(i, abyte); + return this; + } + +- @Override + public FriendlyByteBuf getBytes(int i, byte[] abyte, int j, int k) { + this.source.getBytes(i, abyte, j, k); + return this; + } + +- @Override + public FriendlyByteBuf getBytes(int i, ByteBuffer bytebuffer) { + this.source.getBytes(i, bytebuffer); + return this; + } + +- @Override + public FriendlyByteBuf getBytes(int i, OutputStream outputstream, int j) throws IOException { + this.source.getBytes(i, outputstream, j); + return this; + } + +- @Override + public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) throws IOException { + return this.source.getBytes(i, gatheringbytechannel, j); + } + +- @Override + public int getBytes(int i, FileChannel filechannel, long j, int k) throws IOException { + return this.source.getBytes(i, filechannel, j, k); + } + +- @Override + public CharSequence getCharSequence(int i, int j, Charset charset) { + return this.source.getCharSequence(i, j, charset); + } + +- @Override + public FriendlyByteBuf setBoolean(int i, boolean flag) { + this.source.setBoolean(i, flag); + return this; + } + +- @Override + public FriendlyByteBuf setByte(int i, int j) { + this.source.setByte(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setShort(int i, int j) { + this.source.setShort(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setShortLE(int i, int j) { + this.source.setShortLE(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setMedium(int i, int j) { + this.source.setMedium(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setMediumLE(int i, int j) { + this.source.setMediumLE(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setInt(int i, int j) { + this.source.setInt(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setIntLE(int i, int j) { + this.source.setIntLE(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setLong(int i, long j) { + this.source.setLong(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setLongLE(int i, long j) { + this.source.setLongLE(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setChar(int i, int j) { + this.source.setChar(i, j); + return this; + } + +- @Override + public FriendlyByteBuf setFloat(int i, float f) { + this.source.setFloat(i, f); + return this; + } + +- @Override + public FriendlyByteBuf setDouble(int i, double d0) { + this.source.setDouble(i, d0); + return this; + } + +- @Override + public FriendlyByteBuf setBytes(int i, ByteBuf bytebuf) { + this.source.setBytes(i, bytebuf); + return this; + } + +- @Override + public FriendlyByteBuf setBytes(int i, ByteBuf bytebuf, int j) { + this.source.setBytes(i, bytebuf, j); + return this; + } + +- @Override + public FriendlyByteBuf setBytes(int i, ByteBuf bytebuf, int j, int k) { + this.source.setBytes(i, bytebuf, j, k); + return this; + } + +- @Override + public FriendlyByteBuf setBytes(int i, byte[] abyte) { + this.source.setBytes(i, abyte); + return this; + } + +- @Override + public FriendlyByteBuf setBytes(int i, byte[] abyte, int j, int k) { + this.source.setBytes(i, abyte, j, k); + return this; + } + +- @Override + public FriendlyByteBuf setBytes(int i, ByteBuffer bytebuffer) { + this.source.setBytes(i, bytebuffer); + return this; + } + +- @Override + public int setBytes(int i, InputStream inputstream, int j) throws IOException { + return this.source.setBytes(i, inputstream, j); + } + +- @Override + public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) throws IOException { + return this.source.setBytes(i, scatteringbytechannel, j); + } + +- @Override + public int setBytes(int i, FileChannel filechannel, long j, int k) throws IOException { + return this.source.setBytes(i, filechannel, j, k); + } + +- @Override + public FriendlyByteBuf setZero(int i, int j) { + this.source.setZero(i, j); + return this; + } + +- @Override + public int setCharSequence(int i, CharSequence charsequence, Charset charset) { + return this.source.setCharSequence(i, charsequence, charset); + } + +- @Override + public boolean readBoolean() { + return this.source.readBoolean(); + } + +- @Override + public byte readByte() { + return this.source.readByte(); + } + +- @Override + public short readUnsignedByte() { + return this.source.readUnsignedByte(); + } + +- @Override + public short readShort() { + return this.source.readShort(); + } + +- @Override + public short readShortLE() { + return this.source.readShortLE(); + } + +- @Override + public int readUnsignedShort() { + return this.source.readUnsignedShort(); + } + +- @Override + public int readUnsignedShortLE() { + return this.source.readUnsignedShortLE(); + } + +- @Override + public int readMedium() { + return this.source.readMedium(); + } + +- @Override + public int readMediumLE() { + return this.source.readMediumLE(); + } + +- @Override + public int readUnsignedMedium() { + return this.source.readUnsignedMedium(); + } + +- @Override + public int readUnsignedMediumLE() { + return this.source.readUnsignedMediumLE(); + } + +- @Override + public int readInt() { + return this.source.readInt(); + } + +- @Override + public int readIntLE() { + return this.source.readIntLE(); + } + +- @Override + public long readUnsignedInt() { + return this.source.readUnsignedInt(); + } + +- @Override + public long readUnsignedIntLE() { + return this.source.readUnsignedIntLE(); + } + +- @Override + public long readLong() { + return this.source.readLong(); + } + +- @Override + public long readLongLE() { + return this.source.readLongLE(); + } + +- @Override + public char readChar() { + return this.source.readChar(); + } + +- @Override + public float readFloat() { + return this.source.readFloat(); + } + +- @Override + public double readDouble() { + return this.source.readDouble(); + } + +- @Override + public ByteBuf readBytes(int i) { + return this.source.readBytes(i); + } + +- @Override + public ByteBuf readSlice(int i) { + return this.source.readSlice(i); + } + +- @Override + public ByteBuf readRetainedSlice(int i) { + return this.source.readRetainedSlice(i); + } + +- @Override + public FriendlyByteBuf readBytes(ByteBuf bytebuf) { + this.source.readBytes(bytebuf); + return this; + } + +- @Override + public FriendlyByteBuf readBytes(ByteBuf bytebuf, int i) { + this.source.readBytes(bytebuf, i); + return this; + } + +- @Override + public FriendlyByteBuf readBytes(ByteBuf bytebuf, int i, int j) { + this.source.readBytes(bytebuf, i, j); + return this; + } + +- @Override + public FriendlyByteBuf readBytes(byte[] abyte) { + this.source.readBytes(abyte); + return this; + } + +- @Override + public FriendlyByteBuf readBytes(byte[] abyte, int i, int j) { + this.source.readBytes(abyte, i, j); + return this; + } + +- @Override + public FriendlyByteBuf readBytes(ByteBuffer bytebuffer) { + this.source.readBytes(bytebuffer); + return this; + } + +- @Override + public FriendlyByteBuf readBytes(OutputStream outputstream, int i) throws IOException { + this.source.readBytes(outputstream, i); + return this; + } + +- @Override + public int readBytes(GatheringByteChannel gatheringbytechannel, int i) throws IOException { + return this.source.readBytes(gatheringbytechannel, i); + } + +- @Override + public CharSequence readCharSequence(int i, Charset charset) { + return this.source.readCharSequence(i, charset); + } + +- @Override + public int readBytes(FileChannel filechannel, long i, int j) throws IOException { + return this.source.readBytes(filechannel, i, j); + } + +- @Override + public FriendlyByteBuf skipBytes(int i) { + this.source.skipBytes(i); + return this; + } + +- @Override + public FriendlyByteBuf writeBoolean(boolean flag) { + this.source.writeBoolean(flag); + return this; + } + +- @Override + public FriendlyByteBuf writeByte(int i) { + this.source.writeByte(i); + return this; + } + +- @Override + public FriendlyByteBuf writeShort(int i) { + this.source.writeShort(i); + return this; + } + +- @Override + public FriendlyByteBuf writeShortLE(int i) { + this.source.writeShortLE(i); + return this; + } + +- @Override + public FriendlyByteBuf writeMedium(int i) { + this.source.writeMedium(i); + return this; + } + +- @Override + public FriendlyByteBuf writeMediumLE(int i) { + this.source.writeMediumLE(i); + return this; + } + +- @Override + public FriendlyByteBuf writeInt(int i) { + this.source.writeInt(i); + return this; + } + +- @Override + public FriendlyByteBuf writeIntLE(int i) { + this.source.writeIntLE(i); + return this; + } + +- @Override + public FriendlyByteBuf writeLong(long i) { + this.source.writeLong(i); + return this; + } + +- @Override + public FriendlyByteBuf writeLongLE(long i) { + this.source.writeLongLE(i); + return this; + } + +- @Override + public FriendlyByteBuf writeChar(int i) { + this.source.writeChar(i); + return this; + } + +- @Override + public FriendlyByteBuf writeFloat(float f) { + this.source.writeFloat(f); + return this; + } + +- @Override + public FriendlyByteBuf writeDouble(double d0) { + this.source.writeDouble(d0); + return this; + } + +- @Override + public FriendlyByteBuf writeBytes(ByteBuf bytebuf) { + this.source.writeBytes(bytebuf); + return this; + } + +- @Override + public FriendlyByteBuf writeBytes(ByteBuf bytebuf, int i) { + this.source.writeBytes(bytebuf, i); + return this; + } + +- @Override + public FriendlyByteBuf writeBytes(ByteBuf bytebuf, int i, int j) { + this.source.writeBytes(bytebuf, i, j); + return this; + } + +- @Override + public FriendlyByteBuf writeBytes(byte[] abyte) { + this.source.writeBytes(abyte); + return this; + } + +- @Override + public FriendlyByteBuf writeBytes(byte[] abyte, int i, int j) { + this.source.writeBytes(abyte, i, j); + return this; + } + +- @Override + public FriendlyByteBuf writeBytes(ByteBuffer bytebuffer) { + this.source.writeBytes(bytebuffer); + return this; + } + +- @Override + public int writeBytes(InputStream inputstream, int i) throws IOException { + return this.source.writeBytes(inputstream, i); + } + +- @Override + public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) throws IOException { + return this.source.writeBytes(scatteringbytechannel, i); + } + +- @Override + public int writeBytes(FileChannel filechannel, long i, int j) throws IOException { + return this.source.writeBytes(filechannel, i, j); + } + +- @Override + public FriendlyByteBuf writeZero(int i) { + this.source.writeZero(i); + return this; + } + +- @Override + public int writeCharSequence(CharSequence charsequence, Charset charset) { + return this.source.writeCharSequence(charsequence, charset); + } + +- @Override + public int indexOf(int i, int j, byte b0) { + return this.source.indexOf(i, j, b0); + } + +- @Override + public int bytesBefore(byte b0) { + return this.source.bytesBefore(b0); + } + +- @Override + public int bytesBefore(int i, byte b0) { + return this.source.bytesBefore(i, b0); + } + +- @Override + public int bytesBefore(int i, int j, byte b0) { + return this.source.bytesBefore(i, j, b0); + } + +- @Override + public int forEachByte(ByteProcessor byteprocessor) { + return this.source.forEachByte(byteprocessor); + } + +- @Override + public int forEachByte(int i, int j, ByteProcessor byteprocessor) { + return this.source.forEachByte(i, j, byteprocessor); + } + +- @Override + public int forEachByteDesc(ByteProcessor byteprocessor) { + return this.source.forEachByteDesc(byteprocessor); + } + +- @Override + public int forEachByteDesc(int i, int j, ByteProcessor byteprocessor) { + return this.source.forEachByteDesc(i, j, byteprocessor); + } + +- @Override + public ByteBuf copy() { + return this.source.copy(); + } + +- @Override + public ByteBuf copy(int i, int j) { + return this.source.copy(i, j); + } + +- @Override + public ByteBuf slice() { + return this.source.slice(); + } + +- @Override + public ByteBuf retainedSlice() { + return this.source.retainedSlice(); + } + +- @Override + public ByteBuf slice(int i, int j) { + return this.source.slice(i, j); + } + +- @Override + public ByteBuf retainedSlice(int i, int j) { + return this.source.retainedSlice(i, j); + } + +- @Override + public ByteBuf duplicate() { + return this.source.duplicate(); + } + +- @Override + public ByteBuf retainedDuplicate() { + return this.source.retainedDuplicate(); + } + +- @Override + public int nioBufferCount() { + return this.source.nioBufferCount(); + } + +- @Override + public ByteBuffer nioBuffer() { + return this.source.nioBuffer(); + } + +- @Override + public ByteBuffer nioBuffer(int i, int j) { + return this.source.nioBuffer(i, j); + } + +- @Override + public ByteBuffer internalNioBuffer(int i, int j) { + return this.source.internalNioBuffer(i, j); + } + +- @Override + public ByteBuffer[] nioBuffers() { + return this.source.nioBuffers(); + } + +- @Override + public ByteBuffer[] nioBuffers(int i, int j) { + return this.source.nioBuffers(i, j); + } + +- @Override + public boolean hasArray() { + return this.source.hasArray(); + } + +- @Override + public byte[] array() { + return this.source.array(); + } + +- @Override + public int arrayOffset() { + return this.source.arrayOffset(); + } + +- @Override + public boolean hasMemoryAddress() { + return this.source.hasMemoryAddress(); + } + +- @Override + public long memoryAddress() { + return this.source.memoryAddress(); + } + +- @Override + public String toString(Charset charset) { + return this.source.toString(charset); + } + +- @Override + public String toString(int i, int j, Charset charset) { + return this.source.toString(i, j, charset); + } + +- @Override + public int hashCode() { + return this.source.hashCode(); + } + +- @Override + public boolean equals(Object object) { + return this.source.equals(object); + } + +- @Override + public int compareTo(ByteBuf bytebuf) { + return this.source.compareTo(bytebuf); + } + +- @Override + public String toString() { + return this.source.toString(); + } + +- @Override + public FriendlyByteBuf retain(int i) { + this.source.retain(i); + return this; + } + +- @Override + public FriendlyByteBuf retain() { + this.source.retain(); + return this; + } + +- @Override + public FriendlyByteBuf touch() { + this.source.touch(); + return this; + } + +- @Override + public FriendlyByteBuf touch(Object object) { + this.source.touch(object); + return this; + } + +- @Override + public int refCnt() { + return this.source.refCnt(); + } + +- @Override + public boolean release() { + return this.source.release(); + } + +- @Override + public boolean release(int i) { + return this.source.release(i); + } + + @FunctionalInterface +- public interface Writer<T> extends BiConsumer<FriendlyByteBuf, T> { ++ public interface b<T> extends BiConsumer<FriendlyByteBuf, T> { + +- default FriendlyByteBuf.Writer<Optional<T>> asOptional() { +- return (friendlybytebuf, optional) -> { +- friendlybytebuf.writeOptional(optional, this); ++ default FriendlyByteBuf.b<Optional<T>> asOptional() { ++ return (packetdataserializer, optional) -> { ++ packetdataserializer.writeOptional(optional, this); + }; + } + } + + @FunctionalInterface +- public interface Reader<T> extends Function<FriendlyByteBuf, T> { ++ public interface a<T> extends Function<FriendlyByteBuf, T> { + +- default FriendlyByteBuf.Reader<Optional<T>> asOptional() { +- return (friendlybytebuf) -> { +- return friendlybytebuf.readOptional(this); ++ default FriendlyByteBuf.a<Optional<T>> asOptional() { ++ return (packetdataserializer) -> { ++ return packetdataserializer.readOptional(this); + }; + } + } diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/chat/Component.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/chat/Component.java.patch new file mode 100644 index 0000000000..41ce78732e --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/chat/Component.java.patch @@ -0,0 +1,304 @@ +--- a/net/minecraft/network/chat/Component.java ++++ b/net/minecraft/network/chat/Component.java +@@ -26,32 +26,45 @@ + import net.minecraft.Util; + import net.minecraft.network.chat.contents.DataSource; + import net.minecraft.network.chat.contents.KeybindContents; ++import net.minecraft.network.chat.contents.LiteralContents; + import net.minecraft.network.chat.contents.NbtContents; +-import net.minecraft.network.chat.contents.PlainTextContents; + import net.minecraft.network.chat.contents.ScoreContents; + import net.minecraft.network.chat.contents.SelectorContents; + import net.minecraft.network.chat.contents.TranslatableContents; + import net.minecraft.resources.ResourceLocation; + import net.minecraft.util.FormattedCharSequence; + import net.minecraft.world.level.ChunkPos; ++// CraftBukkit start ++import java.util.stream.Stream; ++// CraftBukkit end + +-public interface Component extends Message, FormattedText { ++public interface Component extends Message, FormattedText, Iterable<Component> { // CraftBukkit + ++ // CraftBukkit start ++ default Stream<Component> stream() { ++ return com.google.common.collect.Streams.concat(new Stream[]{Stream.of(this), this.getSiblings().stream().flatMap(Component::stream)}); ++ } ++ ++ @Override ++ default Iterator<Component> iterator() { ++ return this.stream().iterator(); ++ } ++ // CraftBukkit end ++ + Style getStyle(); + + ComponentContents getContents(); + + @Override +- @Override + default String getString() { + return FormattedText.super.getString(); + } + +- default String getString(int i) { ++ default String getString(int maxLength) { + StringBuilder stringbuilder = new StringBuilder(); + + this.visit((s) -> { +- int j = i - stringbuilder.length(); ++ int j = maxLength - stringbuilder.length(); + + if (j <= 0) { + return Component.STOP_ITERATION; +@@ -69,11 +82,11 @@ + default String tryCollapseToString() { + ComponentContents componentcontents = this.getContents(); + +- if (componentcontents instanceof PlainTextContents) { +- PlainTextContents plaintextcontents = (PlainTextContents) componentcontents; ++ if (componentcontents instanceof LiteralContents) { ++ LiteralContents literalcontents = (LiteralContents) componentcontents; + + if (this.getSiblings().isEmpty() && this.getStyle().isEmpty()) { +- return plaintextcontents.text(); ++ return literalcontents.text(); + } + } + +@@ -91,10 +104,9 @@ + FormattedCharSequence getVisualOrderText(); + + @Override +- @Override +- default <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> formattedtext_styledcontentconsumer, Style style) { +- Style style1 = this.getStyle().applyTo(style); +- Optional<T> optional = this.getContents().visit(formattedtext_styledcontentconsumer, style1); ++ default <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> acceptor, Style style) { ++ Style chatmodifier1 = this.getStyle().applyTo(style); ++ Optional<T> optional = this.getContents().visit(acceptor, chatmodifier1); + + if (optional.isPresent()) { + return optional; +@@ -108,9 +120,9 @@ + return Optional.empty(); + } + +- Component component = (Component) iterator.next(); ++ Component ichatbasecomponent = (Component) iterator.next(); + +- optional1 = component.visit(formattedtext_styledcontentconsumer, style1); ++ optional1 = ichatbasecomponent.visit(acceptor, chatmodifier1); + } while (!optional1.isPresent()); + + return optional1; +@@ -118,9 +130,8 @@ + } + + @Override +- @Override +- default <T> Optional<T> visit(FormattedText.ContentConsumer<T> formattedtext_contentconsumer) { +- Optional<T> optional = this.getContents().visit(formattedtext_contentconsumer); ++ default <T> Optional<T> visit(FormattedText.ContentConsumer<T> acceptor) { ++ Optional<T> optional = this.getContents().visit(acceptor); + + if (optional.isPresent()) { + return optional; +@@ -134,9 +145,9 @@ + return Optional.empty(); + } + +- Component component = (Component) iterator.next(); ++ Component ichatbasecomponent = (Component) iterator.next(); + +- optional1 = component.visit(formattedtext_contentconsumer); ++ optional1 = ichatbasecomponent.visit(acceptor); + } while (!optional1.isPresent()); + + return optional1; +@@ -150,9 +161,9 @@ + default List<Component> toFlatList(Style style) { + List<Component> list = Lists.newArrayList(); + +- this.visit((style1, s) -> { ++ this.visit((chatmodifier1, s) -> { + if (!s.isEmpty()) { +- list.add(literal(s).withStyle(style1)); ++ list.add(literal(s).withStyle(chatmodifier1)); + } + + return Optional.empty(); +@@ -160,31 +171,31 @@ + return list; + } + +- default boolean contains(Component component) { +- if (this.equals(component)) { ++ default boolean contains(Component other) { ++ if (this.equals(other)) { + return true; + } else { + List<Component> list = this.toFlatList(); +- List<Component> list1 = component.toFlatList(this.getStyle()); ++ List<Component> list1 = other.toFlatList(this.getStyle()); + + return Collections.indexOfSubList(list, list1) != -1; + } + } + +- static Component nullToEmpty(@Nullable String s) { +- return (Component) (s != null ? literal(s) : CommonComponents.EMPTY); ++ static Component nullToEmpty(@Nullable String text) { ++ return (Component) (text != null ? literal(text) : CommonComponents.EMPTY); + } + +- static MutableComponent literal(String s) { +- return MutableComponent.create(PlainTextContents.create(s)); ++ static MutableComponent literal(String text) { ++ return MutableComponent.create(LiteralContents.create(text)); + } + +- static MutableComponent translatable(String s) { +- return MutableComponent.create(new TranslatableContents(s, (String) null, TranslatableContents.NO_ARGS)); ++ static MutableComponent translatable(String key) { ++ return MutableComponent.create(new TranslatableContents(key, (String) null, TranslatableContents.NO_ARGS)); + } + +- static MutableComponent translatable(String s, Object... aobject) { +- return MutableComponent.create(new TranslatableContents(s, (String) null, aobject)); ++ static MutableComponent translatable(String key, Object... args) { ++ return MutableComponent.create(new TranslatableContents(key, (String) null, args)); + } + + static MutableComponent translatableEscape(String s, Object... aobject) { +@@ -199,32 +210,32 @@ + return translatable(s, aobject); + } + +- static MutableComponent translatableWithFallback(String s, @Nullable String s1) { +- return MutableComponent.create(new TranslatableContents(s, s1, TranslatableContents.NO_ARGS)); ++ static MutableComponent translatableWithFallback(String key, @Nullable String fallback) { ++ return MutableComponent.create(new TranslatableContents(key, fallback, TranslatableContents.NO_ARGS)); + } + +- static MutableComponent translatableWithFallback(String s, @Nullable String s1, Object... aobject) { +- return MutableComponent.create(new TranslatableContents(s, s1, aobject)); ++ static MutableComponent translatableWithFallback(String key, @Nullable String fallback, Object... args) { ++ return MutableComponent.create(new TranslatableContents(key, fallback, args)); + } + + static MutableComponent empty() { +- return MutableComponent.create(PlainTextContents.EMPTY); ++ return MutableComponent.create(LiteralContents.EMPTY); + } + +- static MutableComponent keybind(String s) { +- return MutableComponent.create(new KeybindContents(s)); ++ static MutableComponent keybind(String name) { ++ return MutableComponent.create(new KeybindContents(name)); + } + +- static MutableComponent nbt(String s, boolean flag, Optional<Component> optional, DataSource datasource) { +- return MutableComponent.create(new NbtContents(s, flag, optional, datasource)); ++ static MutableComponent nbt(String nbtPathPattern, boolean interpreting, Optional<Component> separator, DataSource dataSource) { ++ return MutableComponent.create(new NbtContents(nbtPathPattern, interpreting, separator, dataSource)); + } + +- static MutableComponent score(String s, String s1) { +- return MutableComponent.create(new ScoreContents(s, s1)); ++ static MutableComponent score(String name, String objective) { ++ return MutableComponent.create(new ScoreContents(name, objective)); + } + +- static MutableComponent selector(String s, Optional<Component> optional) { +- return MutableComponent.create(new SelectorContents(s, optional)); ++ static MutableComponent selector(String pattern, Optional<Component> separator) { ++ return MutableComponent.create(new SelectorContents(pattern, separator)); + } + + static Component translationArg(Date date) { +@@ -235,9 +246,9 @@ + Object object; + + if (message instanceof Component) { +- Component component = (Component) message; ++ Component ichatbasecomponent = (Component) message; + +- object = component; ++ object = ichatbasecomponent; + } else { + object = literal(message.getString()); + } +@@ -249,26 +260,24 @@ + return literal(uuid.toString()); + } + +- static Component translationArg(ResourceLocation resourcelocation) { +- return literal(resourcelocation.toString()); ++ static Component translationArg(ResourceLocation minecraftkey) { ++ return literal(minecraftkey.toString()); + } + +- static Component translationArg(ChunkPos chunkpos) { +- return literal(chunkpos.toString()); ++ static Component translationArg(ChunkPos chunkcoordintpair) { ++ return literal(chunkcoordintpair.toString()); + } + +- public static class SerializerAdapter implements JsonDeserializer<MutableComponent>, JsonSerializer<Component> { ++ public static class b implements JsonDeserializer<MutableComponent>, JsonSerializer<Component> { + +- public SerializerAdapter() {} ++ public b() {} + +- @Override + public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { + return Component.Serializer.deserialize(jsonelement); + } + +- @Override +- public JsonElement serialize(Component component, Type type, JsonSerializationContext jsonserializationcontext) { +- return Component.Serializer.serialize(component); ++ public JsonElement serialize(Component ichatbasecomponent, Type type, JsonSerializationContext jsonserializationcontext) { ++ return Component.Serializer.serialize(ichatbasecomponent); + } + } + +@@ -282,8 +291,8 @@ + return (MutableComponent) Util.getOrThrow(ComponentSerialization.CODEC.parse(JsonOps.INSTANCE, jsonelement), JsonParseException::new); + } + +- static JsonElement serialize(Component component) { +- return (JsonElement) Util.getOrThrow(ComponentSerialization.CODEC.encodeStart(JsonOps.INSTANCE, component), JsonParseException::new); ++ static JsonElement serialize(Component ichatbasecomponent) { ++ return (JsonElement) Util.getOrThrow(ComponentSerialization.CODEC.encodeStart(JsonOps.INSTANCE, ichatbasecomponent), JsonParseException::new); + } + + public static String toJson(Component component) { +@@ -295,20 +304,20 @@ + } + + @Nullable +- public static MutableComponent fromJson(String s) { +- JsonElement jsonelement = JsonParser.parseString(s); ++ public static MutableComponent fromJson(String json) { ++ JsonElement jsonelement = JsonParser.parseString(json); + + return jsonelement == null ? null : deserialize(jsonelement); + } + + @Nullable +- public static MutableComponent fromJson(@Nullable JsonElement jsonelement) { +- return jsonelement == null ? null : deserialize(jsonelement); ++ public static MutableComponent fromJson(@Nullable JsonElement json) { ++ return json == null ? null : deserialize(json); + } + + @Nullable +- public static MutableComponent fromJsonLenient(String s) { +- JsonReader jsonreader = new JsonReader(new StringReader(s)); ++ public static MutableComponent fromJsonLenient(String json) { ++ JsonReader jsonreader = new JsonReader(new StringReader(json)); + + jsonreader.setLenient(true); + JsonElement jsonelement = JsonParser.parseReader(jsonreader); diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/chat/TextColor.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/chat/TextColor.java.patch new file mode 100644 index 0000000000..643fcab5a1 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/chat/TextColor.java.patch @@ -0,0 +1,100 @@ +--- a/net/minecraft/network/chat/TextColor.java ++++ b/net/minecraft/network/chat/TextColor.java +@@ -16,25 +16,31 @@ + + private static final String CUSTOM_COLOR_PREFIX = "#"; + public static final Codec<TextColor> CODEC = Codec.STRING.comapFlatMap(TextColor::parseColor, TextColor::serialize); +- private static final Map<ChatFormatting, TextColor> LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(ChatFormatting.values()).filter(ChatFormatting::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (chatformatting) -> { +- return new TextColor(chatformatting.getColor(), chatformatting.getName()); ++ private static final Map<ChatFormatting, TextColor> LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(ChatFormatting.values()).filter(ChatFormatting::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> { ++ return new TextColor(enumchatformat.getColor(), enumchatformat.getName(), enumchatformat); // CraftBukkit + })); +- private static final Map<String, TextColor> NAMED_COLORS = (Map) TextColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((textcolor) -> { +- return textcolor.name; ++ private static final Map<String, TextColor> NAMED_COLORS = (Map) TextColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> { ++ return chathexcolor.name; + }, Function.identity())); + private final int value; + @Nullable +- private final String name; ++ public final String name; ++ // CraftBukkit start ++ @Nullable ++ public final ChatFormatting format; + +- private TextColor(int i, String s) { ++ private TextColor(int i, String s, ChatFormatting format) { + this.value = i & 16777215; + this.name = s; ++ this.format = format; + } + +- private TextColor(int i) { +- this.value = i & 16777215; ++ private TextColor(int value) { ++ this.value = value & 16777215; + this.name = null; ++ this.format = null; + } ++ // CraftBukkit end + + public int getValue() { + return this.value; +@@ -48,36 +54,33 @@ + return String.format(Locale.ROOT, "#%06X", this.value); + } + +- @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } else if (object != null && this.getClass() == object.getClass()) { +- TextColor textcolor = (TextColor) object; ++ TextColor chathexcolor = (TextColor) object; + +- return this.value == textcolor.value; ++ return this.value == chathexcolor.value; + } else { + return false; + } + } + +- @Override + public int hashCode() { + return Objects.hash(new Object[]{this.value, this.name}); + } + +- @Override + public String toString() { + return this.serialize(); + } + + @Nullable +- public static TextColor fromLegacyFormat(ChatFormatting chatformatting) { +- return (TextColor) TextColor.LEGACY_FORMAT_TO_COLOR.get(chatformatting); ++ public static TextColor fromLegacyFormat(ChatFormatting formatting) { ++ return (TextColor) TextColor.LEGACY_FORMAT_TO_COLOR.get(formatting); + } + +- public static TextColor fromRgb(int i) { +- return new TextColor(i); ++ public static TextColor fromRgb(int color) { ++ return new TextColor(color); + } + + public static DataResult<TextColor> parseColor(String s) { +@@ -94,11 +97,11 @@ + }); + } + } else { +- TextColor textcolor = (TextColor) TextColor.NAMED_COLORS.get(s); ++ TextColor chathexcolor = (TextColor) TextColor.NAMED_COLORS.get(s); + +- return textcolor == null ? DataResult.error(() -> { ++ return chathexcolor == null ? DataResult.error(() -> { + return "Invalid color name: " + s; +- }) : DataResult.success(textcolor, Lifecycle.stable()); ++ }) : DataResult.success(chathexcolor, Lifecycle.stable()); + } + } + } diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/PacketUtils.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/PacketUtils.java.patch new file mode 100644 index 0000000000..eae575f793 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/PacketUtils.java.patch @@ -0,0 +1,83 @@ +--- a/net/minecraft/network/protocol/PacketUtils.java ++++ b/net/minecraft/network/protocol/PacketUtils.java +@@ -4,10 +4,15 @@ + import net.minecraft.CrashReport; + import net.minecraft.ReportedException; + import net.minecraft.network.PacketListener; +-import net.minecraft.server.RunningOnDifferentThreadException; ++import net.minecraft.server.CancelledPacketHandleException; ++import org.slf4j.Logger; ++ ++// CraftBukkit start ++import net.minecraft.server.MinecraftServer; + import net.minecraft.server.level.ServerLevel; ++import net.minecraft.server.network.ServerCommonPacketListenerImpl; ++// CraftBukkit end + import net.minecraft.util.thread.BlockableEventLoop; +-import org.slf4j.Logger; + + public class PacketUtils { + +@@ -15,16 +20,17 @@ + + public PacketUtils() {} + +- public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T t0, ServerLevel serverlevel) throws RunningOnDifferentThreadException { +- ensureRunningOnSameThread(packet, t0, (BlockableEventLoop) serverlevel.getServer()); ++ public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T processor, ServerLevel level) throws CancelledPacketHandleException { ++ ensureRunningOnSameThread(packet, processor, (BlockableEventLoop) level.getServer()); + } + +- public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T t0, BlockableEventLoop<?> blockableeventloop) throws RunningOnDifferentThreadException { +- if (!blockableeventloop.isSameThread()) { +- blockableeventloop.executeIfPossible(() -> { +- if (t0.shouldHandleMessage(packet)) { ++ public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T processor, BlockableEventLoop<?> executor) throws CancelledPacketHandleException { ++ if (!executor.isSameThread()) { ++ executor.executeIfPossible(() -> { ++ if (MinecraftServer.getServer().hasStopped() || (processor instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) processor).processedDisconnect)) return; // CraftBukkit, MC-142590 ++ if (processor.shouldHandleMessage(packet)) { + try { +- packet.handle(t0); ++ packet.handle(processor); + } catch (Exception exception) { + label25: + { +@@ -36,7 +42,7 @@ + } + } + +- if (!t0.shouldPropagateHandlingExceptions()) { ++ if (!processor.shouldPropagateHandlingExceptions()) { + PacketUtils.LOGGER.error("Failed to handle packet {}, suppressing error", packet, exception); + return; + } +@@ -45,13 +51,13 @@ + if (exception instanceof ReportedException) { + ReportedException reportedexception1 = (ReportedException) exception; + +- t0.fillCrashReport(reportedexception1.getReport()); ++ processor.fillCrashReport(reportedexception1.getReport()); + throw exception; + } + + CrashReport crashreport = CrashReport.forThrowable(exception, "Main thread packet handler"); + +- t0.fillCrashReport(crashreport); ++ processor.fillCrashReport(crashreport); + throw new ReportedException(crashreport); + } + } else { +@@ -59,7 +65,11 @@ + } + + }); +- throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; ++ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD; ++ // CraftBukkit start - SPIGOT-5477, MC-142590 ++ } else if (MinecraftServer.getServer().hasStopped() || (processor instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) processor).processedDisconnect)) { ++ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD; ++ // CraftBukkit end + } + } + } diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch new file mode 100644 index 0000000000..7209c3be34 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch @@ -0,0 +1,67 @@ +--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java ++++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java +@@ -12,38 +12,47 @@ + public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet<ServerCommonPacketListener> { + + private static final int MAX_PAYLOAD_SIZE = 32767; +- private static final Map<ResourceLocation, FriendlyByteBuf.Reader<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.builder().put(BrandPayload.ID, BrandPayload::new).build(); ++ private static final Map<ResourceLocation, FriendlyByteBuf.a<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.<ResourceLocation, FriendlyByteBuf.a<? extends CustomPacketPayload>>builder().build(); // CraftBukkit - no special handling + +- public ServerboundCustomPayloadPacket(FriendlyByteBuf friendlybytebuf) { +- this(readPayload(friendlybytebuf.readResourceLocation(), friendlybytebuf)); ++ public ServerboundCustomPayloadPacket(FriendlyByteBuf packetdataserializer) { ++ this(readPayload(packetdataserializer.readResourceLocation(), packetdataserializer)); + } + +- private static CustomPacketPayload readPayload(ResourceLocation resourcelocation, FriendlyByteBuf friendlybytebuf) { +- FriendlyByteBuf.Reader<? extends CustomPacketPayload> friendlybytebuf_reader = (FriendlyByteBuf.Reader) ServerboundCustomPayloadPacket.KNOWN_TYPES.get(resourcelocation); ++ private static CustomPacketPayload readPayload(ResourceLocation minecraftkey, FriendlyByteBuf packetdataserializer) { ++ FriendlyByteBuf.a<? extends CustomPacketPayload> packetdataserializer_a = (FriendlyByteBuf.a) ServerboundCustomPayloadPacket.KNOWN_TYPES.get(minecraftkey); + +- return (CustomPacketPayload) (friendlybytebuf_reader != null ? (CustomPacketPayload) friendlybytebuf_reader.apply(friendlybytebuf) : readUnknownPayload(resourcelocation, friendlybytebuf)); ++ return (CustomPacketPayload) (packetdataserializer_a != null ? (CustomPacketPayload) packetdataserializer_a.apply(packetdataserializer) : readUnknownPayload(minecraftkey, packetdataserializer)); + } + +- private static DiscardedPayload readUnknownPayload(ResourceLocation resourcelocation, FriendlyByteBuf friendlybytebuf) { +- int i = friendlybytebuf.readableBytes(); ++ private static UnknownPayload readUnknownPayload(ResourceLocation minecraftkey, FriendlyByteBuf packetdataserializer) { // CraftBukkit ++ int i = packetdataserializer.readableBytes(); + + if (i >= 0 && i <= 32767) { +- friendlybytebuf.skipBytes(i); +- return new DiscardedPayload(resourcelocation); ++ // CraftBukkit start ++ return new UnknownPayload(minecraftkey, packetdataserializer.readBytes(i)); ++ // CraftBukkit end + } else { + throw new IllegalArgumentException("Payload may not be larger than 32767 bytes"); + } + } + + @Override +- @Override +- public void write(FriendlyByteBuf friendlybytebuf) { +- friendlybytebuf.writeResourceLocation(this.payload.id()); +- this.payload.write(friendlybytebuf); ++ public void write(FriendlyByteBuf buffer) { ++ buffer.writeResourceLocation(this.payload.id()); ++ this.payload.write(buffer); + } + +- @Override +- public void handle(ServerCommonPacketListener servercommonpacketlistener) { +- servercommonpacketlistener.handleCustomPayload(this); ++ public void handle(ServerCommonPacketListener handler) { ++ handler.handleCustomPayload(this); + } ++ ++ // CraftBukkit start ++ public record UnknownPayload(ResourceLocation id, io.netty.buffer.ByteBuf data) implements CustomPacketPayload { ++ ++ @Override ++ public void write(FriendlyByteBuf packetdataserializer) { ++ packetdataserializer.writeBytes(data); ++ } ++ } ++ // CraftBukkit end + } diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch new file mode 100644 index 0000000000..abca0f1fb1 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch @@ -0,0 +1,78 @@ +--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java +@@ -15,44 +15,44 @@ + private final int warningBlocks; + private final int warningTime; + +- public ClientboundInitializeBorderPacket(FriendlyByteBuf friendlybytebuf) { +- this.newCenterX = friendlybytebuf.readDouble(); +- this.newCenterZ = friendlybytebuf.readDouble(); +- this.oldSize = friendlybytebuf.readDouble(); +- this.newSize = friendlybytebuf.readDouble(); +- this.lerpTime = friendlybytebuf.readVarLong(); +- this.newAbsoluteMaxSize = friendlybytebuf.readVarInt(); +- this.warningBlocks = friendlybytebuf.readVarInt(); +- this.warningTime = friendlybytebuf.readVarInt(); ++ public ClientboundInitializeBorderPacket(FriendlyByteBuf buffer) { ++ this.newCenterX = buffer.readDouble(); ++ this.newCenterZ = buffer.readDouble(); ++ this.oldSize = buffer.readDouble(); ++ this.newSize = buffer.readDouble(); ++ this.lerpTime = buffer.readVarLong(); ++ this.newAbsoluteMaxSize = buffer.readVarInt(); ++ this.warningBlocks = buffer.readVarInt(); ++ this.warningTime = buffer.readVarInt(); + } + +- public ClientboundInitializeBorderPacket(WorldBorder worldborder) { +- this.newCenterX = worldborder.getCenterX(); +- this.newCenterZ = worldborder.getCenterZ(); +- this.oldSize = worldborder.getSize(); +- this.newSize = worldborder.getLerpTarget(); +- this.lerpTime = worldborder.getLerpRemainingTime(); +- this.newAbsoluteMaxSize = worldborder.getAbsoluteMaxSize(); +- this.warningBlocks = worldborder.getWarningBlocks(); +- this.warningTime = worldborder.getWarningTime(); ++ public ClientboundInitializeBorderPacket(WorldBorder worldBorder) { ++ // CraftBukkit start - multiply out nether border ++ this.newCenterX = worldBorder.getCenterX() * worldBorder.world.dimensionType().coordinateScale(); ++ this.newCenterZ = worldBorder.getCenterZ() * worldBorder.world.dimensionType().coordinateScale(); ++ // CraftBukkit end ++ this.oldSize = worldBorder.getSize(); ++ this.newSize = worldBorder.getLerpTarget(); ++ this.lerpTime = worldBorder.getLerpRemainingTime(); ++ this.newAbsoluteMaxSize = worldBorder.getAbsoluteMaxSize(); ++ this.warningBlocks = worldBorder.getWarningBlocks(); ++ this.warningTime = worldBorder.getWarningTime(); + } + + @Override +- @Override +- public void write(FriendlyByteBuf friendlybytebuf) { +- friendlybytebuf.writeDouble(this.newCenterX); +- friendlybytebuf.writeDouble(this.newCenterZ); +- friendlybytebuf.writeDouble(this.oldSize); +- friendlybytebuf.writeDouble(this.newSize); +- friendlybytebuf.writeVarLong(this.lerpTime); +- friendlybytebuf.writeVarInt(this.newAbsoluteMaxSize); +- friendlybytebuf.writeVarInt(this.warningBlocks); +- friendlybytebuf.writeVarInt(this.warningTime); ++ public void write(FriendlyByteBuf buffer) { ++ buffer.writeDouble(this.newCenterX); ++ buffer.writeDouble(this.newCenterZ); ++ buffer.writeDouble(this.oldSize); ++ buffer.writeDouble(this.newSize); ++ buffer.writeVarLong(this.lerpTime); ++ buffer.writeVarInt(this.newAbsoluteMaxSize); ++ buffer.writeVarInt(this.warningBlocks); ++ buffer.writeVarInt(this.warningTime); + } + +- @Override +- public void handle(ClientGamePacketListener clientgamepacketlistener) { +- clientgamepacketlistener.handleInitializeBorder(this); ++ public void handle(ClientGamePacketListener handler) { ++ handler.handleInitializeBorder(this); + } + + public double getNewCenterX() { diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch new file mode 100644 index 0000000000..35b491f95b --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch @@ -0,0 +1,109 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java +@@ -8,7 +8,7 @@ + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.protocol.Packet; + import net.minecraft.world.level.block.Block; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.chunk.LevelChunkSection; + + public class ClientboundSectionBlocksUpdatePacket implements Packet<ClientGamePacketListener> { +@@ -16,66 +16,72 @@ + private static final int POS_IN_SECTION_BITS = 12; + private final SectionPos sectionPos; + private final short[] positions; +- private final BlockState[] states; ++ private final IBlockData[] states; + +- public ClientboundSectionBlocksUpdatePacket(SectionPos sectionpos, ShortSet shortset, LevelChunkSection levelchunksection) { +- this.sectionPos = sectionpos; +- int i = shortset.size(); ++ public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section) { ++ this.sectionPos = sectionPos; ++ int i = positions.size(); + + this.positions = new short[i]; +- this.states = new BlockState[i]; ++ this.states = new IBlockData[i]; + int j = 0; + +- for (ShortIterator shortiterator = shortset.iterator(); shortiterator.hasNext(); ++j) { ++ for (ShortIterator shortiterator = positions.iterator(); shortiterator.hasNext(); ++j) { + short short0 = (Short) shortiterator.next(); + + this.positions[j] = short0; +- this.states[j] = levelchunksection.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 + } + + } + +- public ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf friendlybytebuf) { +- this.sectionPos = SectionPos.of(friendlybytebuf.readLong()); +- int i = friendlybytebuf.readVarInt(); ++ // CraftBukkit start - Add constructor ++ public ClientboundSectionBlocksUpdatePacket(SectionPos sectionposition, ShortSet shortset, IBlockData[] states) { ++ this.sectionPos = sectionposition; ++ this.positions = shortset.toShortArray(); ++ this.states = states; ++ } ++ // CraftBukkit end + ++ public ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf buffer) { ++ this.sectionPos = SectionPos.of(buffer.readLong()); ++ int i = buffer.readVarInt(); ++ + this.positions = new short[i]; +- this.states = new BlockState[i]; ++ this.states = new IBlockData[i]; + + for (int j = 0; j < i; ++j) { +- long k = friendlybytebuf.readVarLong(); ++ long k = buffer.readVarLong(); + + this.positions[j] = (short) ((int) (k & 4095L)); +- this.states[j] = (BlockState) Block.BLOCK_STATE_REGISTRY.byId((int) (k >>> 12)); ++ this.states[j] = (IBlockData) Block.BLOCK_STATE_REGISTRY.byId((int) (k >>> 12)); + } + + } + + @Override +- @Override +- public void write(FriendlyByteBuf friendlybytebuf) { +- friendlybytebuf.writeLong(this.sectionPos.asLong()); +- friendlybytebuf.writeVarInt(this.positions.length); ++ public void write(FriendlyByteBuf buffer) { ++ buffer.writeLong(this.sectionPos.asLong()); ++ buffer.writeVarInt(this.positions.length); + + for (int i = 0; i < this.positions.length; ++i) { +- friendlybytebuf.writeVarLong((long) Block.getId(this.states[i]) << 12 | (long) this.positions[i]); ++ buffer.writeVarLong((long) Block.getId(this.states[i]) << 12 | (long) this.positions[i]); + } + + } + +- @Override +- public void handle(ClientGamePacketListener clientgamepacketlistener) { +- clientgamepacketlistener.handleChunkBlocksUpdate(this); ++ public void handle(ClientGamePacketListener handler) { ++ handler.handleChunkBlocksUpdate(this); + } + +- public void runUpdates(BiConsumer<BlockPos, BlockState> biconsumer) { +- BlockPos.MutableBlockPos blockpos_mutableblockpos = new BlockPos.MutableBlockPos(); ++ public void runUpdates(BiConsumer<BlockPos, IBlockData> consumer) { ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + + for (int i = 0; i < this.positions.length; ++i) { + short short0 = this.positions[i]; + +- blockpos_mutableblockpos.set(this.sectionPos.relativeToBlockX(short0), this.sectionPos.relativeToBlockY(short0), this.sectionPos.relativeToBlockZ(short0)); +- biconsumer.accept(blockpos_mutableblockpos, this.states[i]); ++ blockposition_mutableblockposition.set(this.sectionPos.relativeToBlockX(short0), this.sectionPos.relativeToBlockY(short0), this.sectionPos.relativeToBlockZ(short0)); ++ consumer.accept(blockposition_mutableblockposition, this.states[i]); + } + + } diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch new file mode 100644 index 0000000000..5ac38655e0 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java +@@ -9,26 +9,26 @@ + private final double newCenterX; + private final double newCenterZ; + +- public ClientboundSetBorderCenterPacket(WorldBorder worldborder) { +- this.newCenterX = worldborder.getCenterX(); +- this.newCenterZ = worldborder.getCenterZ(); ++ public ClientboundSetBorderCenterPacket(WorldBorder worldBorder) { ++ // CraftBukkit start - multiply out nether border ++ this.newCenterX = worldBorder.getCenterX() * (worldBorder.world != null ? worldBorder.world.dimensionType().coordinateScale() : 1.0); ++ this.newCenterZ = worldBorder.getCenterZ() * (worldBorder.world != null ? worldBorder.world.dimensionType().coordinateScale() : 1.0); ++ // CraftBukkit end + } + +- public ClientboundSetBorderCenterPacket(FriendlyByteBuf friendlybytebuf) { +- this.newCenterX = friendlybytebuf.readDouble(); +- this.newCenterZ = friendlybytebuf.readDouble(); ++ public ClientboundSetBorderCenterPacket(FriendlyByteBuf buffer) { ++ this.newCenterX = buffer.readDouble(); ++ this.newCenterZ = buffer.readDouble(); + } + + @Override +- @Override +- public void write(FriendlyByteBuf friendlybytebuf) { +- friendlybytebuf.writeDouble(this.newCenterX); +- friendlybytebuf.writeDouble(this.newCenterZ); ++ public void write(FriendlyByteBuf buffer) { ++ buffer.writeDouble(this.newCenterX); ++ buffer.writeDouble(this.newCenterZ); + } + +- @Override +- public void handle(ClientGamePacketListener clientgamepacketlistener) { +- clientgamepacketlistener.handleSetBorderCenter(this); ++ public void handle(ClientGamePacketListener handler) { ++ handler.handleSetBorderCenter(this); + } + + public double getNewCenterZ() { diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch new file mode 100644 index 0000000000..0cdd79b9c8 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java +@@ -1,3 +1,4 @@ ++// mc-dev import + package net.minecraft.network.protocol.game; + + import net.minecraft.network.FriendlyByteBuf; +@@ -6,24 +7,21 @@ + + public record ClientboundSystemChatPacket(Component content, boolean overlay) implements Packet<ClientGamePacketListener> { + +- public ClientboundSystemChatPacket(FriendlyByteBuf friendlybytebuf) { +- this(friendlybytebuf.readComponentTrusted(), friendlybytebuf.readBoolean()); ++ public ClientboundSystemChatPacket(FriendlyByteBuf buffer) { ++ this(buffer.readComponentTrusted(), buffer.readBoolean()); + } + + @Override +- @Override +- public void write(FriendlyByteBuf friendlybytebuf) { +- friendlybytebuf.writeComponent(this.content); +- friendlybytebuf.writeBoolean(this.overlay); ++ public void write(FriendlyByteBuf buffer) { ++ buffer.writeComponent(this.content); ++ buffer.writeBoolean(this.overlay); + } + +- @Override +- public void handle(ClientGamePacketListener clientgamepacketlistener) { +- clientgamepacketlistener.handleSystemChat(this); ++ public void handle(ClientGamePacketListener handler) { ++ handler.handleSystemChat(this); + } + + @Override +- @Override + public boolean isSkippable() { + return true; + } diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch new file mode 100644 index 0000000000..b1f7aa6e0c --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java ++++ b/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java +@@ -1,42 +1,41 @@ ++// mc-dev import + package net.minecraft.network.protocol.game; + + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.protocol.Packet; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.phys.BlockHitResult; + + public class ServerboundUseItemOnPacket implements Packet<ServerGamePacketListener> { + + private final BlockHitResult blockHit; +- private final InteractionHand hand; ++ private final EnumHand hand; + private final int sequence; + +- public ServerboundUseItemOnPacket(InteractionHand interactionhand, BlockHitResult blockhitresult, int i) { +- this.hand = interactionhand; +- this.blockHit = blockhitresult; +- this.sequence = i; ++ public ServerboundUseItemOnPacket(EnumHand hand, BlockHitResult blockHit, int sequence) { ++ this.hand = hand; ++ this.blockHit = blockHit; ++ this.sequence = sequence; + } + +- public ServerboundUseItemOnPacket(FriendlyByteBuf friendlybytebuf) { +- this.hand = (InteractionHand) friendlybytebuf.readEnum(InteractionHand.class); +- this.blockHit = friendlybytebuf.readBlockHitResult(); +- this.sequence = friendlybytebuf.readVarInt(); ++ public ServerboundUseItemOnPacket(FriendlyByteBuf buffer) { ++ this.hand = (EnumHand) buffer.readEnum(EnumHand.class); ++ this.blockHit = buffer.readBlockHitResult(); ++ this.sequence = buffer.readVarInt(); + } + + @Override +- @Override +- public void write(FriendlyByteBuf friendlybytebuf) { +- friendlybytebuf.writeEnum(this.hand); +- friendlybytebuf.writeBlockHitResult(this.blockHit); +- friendlybytebuf.writeVarInt(this.sequence); ++ public void write(FriendlyByteBuf buffer) { ++ buffer.writeEnum(this.hand); ++ buffer.writeBlockHitResult(this.blockHit); ++ buffer.writeVarInt(this.sequence); + } + +- @Override +- public void handle(ServerGamePacketListener servergamepacketlistener) { +- servergamepacketlistener.handleUseItemOn(this); ++ public void handle(ServerGamePacketListener handler) { ++ handler.handleUseItemOn(this); + } + +- public InteractionHand getHand() { ++ public EnumHand getHand() { + return this.hand; + } + diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch new file mode 100644 index 0000000000..09f410f55b --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java ++++ b/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java +@@ -1,37 +1,36 @@ ++// mc-dev import + package net.minecraft.network.protocol.game; + + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.protocol.Packet; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + + public class ServerboundUseItemPacket implements Packet<ServerGamePacketListener> { + +- private final InteractionHand hand; ++ private final EnumHand hand; + private final int sequence; + +- public ServerboundUseItemPacket(InteractionHand interactionhand, int i) { +- this.hand = interactionhand; +- this.sequence = i; ++ public ServerboundUseItemPacket(EnumHand hand, int sequence) { ++ this.hand = hand; ++ this.sequence = sequence; + } + +- public ServerboundUseItemPacket(FriendlyByteBuf friendlybytebuf) { +- this.hand = (InteractionHand) friendlybytebuf.readEnum(InteractionHand.class); +- this.sequence = friendlybytebuf.readVarInt(); ++ public ServerboundUseItemPacket(FriendlyByteBuf buffer) { ++ this.hand = (EnumHand) buffer.readEnum(EnumHand.class); ++ this.sequence = buffer.readVarInt(); + } + + @Override +- @Override +- public void write(FriendlyByteBuf friendlybytebuf) { +- friendlybytebuf.writeEnum(this.hand); +- friendlybytebuf.writeVarInt(this.sequence); ++ public void write(FriendlyByteBuf buffer) { ++ buffer.writeEnum(this.hand); ++ buffer.writeVarInt(this.sequence); + } + +- @Override +- public void handle(ServerGamePacketListener servergamepacketlistener) { +- servergamepacketlistener.handleUseItem(this); ++ public void handle(ServerGamePacketListener handler) { ++ handler.handleUseItem(this); + } + +- public InteractionHand getHand() { ++ public EnumHand getHand() { + return this.hand; + } + diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch new file mode 100644 index 0000000000..5567cc06aa --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java ++++ b/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java +@@ -1,3 +1,4 @@ ++// mc-dev import + package net.minecraft.network.protocol.handshake; + + import net.minecraft.network.ConnectionProtocol; +@@ -8,26 +9,23 @@ + + private static final int MAX_HOST_LENGTH = 255; + +- public ClientIntentionPacket(FriendlyByteBuf friendlybytebuf) { +- this(friendlybytebuf.readVarInt(), friendlybytebuf.readUtf(255), friendlybytebuf.readUnsignedShort(), ClientIntent.byId(friendlybytebuf.readVarInt())); ++ public ClientIntentionPacket(FriendlyByteBuf buffer) { ++ this(buffer.readVarInt(), buffer.readUtf(255), buffer.readUnsignedShort(), ClientIntent.byId(buffer.readVarInt())); + } + + @Override +- @Override +- public void write(FriendlyByteBuf friendlybytebuf) { +- friendlybytebuf.writeVarInt(this.protocolVersion); +- friendlybytebuf.writeUtf(this.hostName); +- friendlybytebuf.writeShort(this.port); +- friendlybytebuf.writeVarInt(this.intention.id()); ++ public void write(FriendlyByteBuf buffer) { ++ buffer.writeVarInt(this.protocolVersion); ++ buffer.writeUtf(this.hostName); ++ buffer.writeShort(this.port); ++ buffer.writeVarInt(this.intention.id()); + } + +- @Override +- public void handle(ServerHandshakePacketListener serverhandshakepacketlistener) { +- serverhandshakepacketlistener.handleIntention(this); ++ public void handle(ServerHandshakePacketListener handler) { ++ handler.handleIntention(this); + } + + @Override +- @Override + public ConnectionProtocol nextProtocol() { + return this.intention.protocol(); + } diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/syncher/SynchedEntityData.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/syncher/SynchedEntityData.java.patch new file mode 100644 index 0000000000..b688b36479 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -0,0 +1,353 @@ +--- a/net/minecraft/network/syncher/SynchedEntityData.java ++++ b/net/minecraft/network/syncher/SynchedEntityData.java +@@ -20,6 +20,8 @@ + import net.minecraft.CrashReportCategory; + import net.minecraft.ReportedException; + import net.minecraft.network.FriendlyByteBuf; ++import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; ++import net.minecraft.server.level.ServerPlayer; + import net.minecraft.world.entity.Entity; + import org.apache.commons.lang3.ObjectUtils; + import org.slf4j.Logger; +@@ -38,13 +40,13 @@ + this.entity = entity; + } + +- public static <T> EntityDataAccessor<T> defineId(Class<? extends Entity> oclass, EntityDataSerializer<T> entitydataserializer) { ++ public static <T> EntityDataAccessor<T> defineId(Class<? extends Entity> clazz, EntityDataSerializer<T> serializer) { + if (SynchedEntityData.LOGGER.isDebugEnabled()) { + try { + Class<?> oclass1 = Class.forName(Thread.currentThread().getStackTrace()[2].getClassName()); + +- if (!oclass1.equals(oclass)) { +- SynchedEntityData.LOGGER.debug("defineId called for: {} from {}", new Object[]{oclass, oclass1, new RuntimeException()}); ++ if (!oclass1.equals(clazz)) { ++ SynchedEntityData.LOGGER.debug("defineId called for: {} from {}", new Object[]{clazz, oclass1, new RuntimeException()}); + } + } catch (ClassNotFoundException classnotfoundexception) { + ; +@@ -53,11 +55,11 @@ + + int i; + +- if (SynchedEntityData.ENTITY_ID_POOL.containsKey(oclass)) { +- i = SynchedEntityData.ENTITY_ID_POOL.getInt(oclass) + 1; ++ if (SynchedEntityData.ENTITY_ID_POOL.containsKey(clazz)) { ++ i = SynchedEntityData.ENTITY_ID_POOL.getInt(clazz) + 1; + } else { + int j = 0; +- Class oclass2 = oclass; ++ Class oclass2 = clazz; + + while (oclass2 != Entity.class) { + oclass2 = oclass2.getSuperclass(); +@@ -73,79 +75,86 @@ + if (i > 254) { + throw new IllegalArgumentException("Data value id is too big with " + i + "! (Max is 254)"); + } else { +- SynchedEntityData.ENTITY_ID_POOL.put(oclass, i); +- return entitydataserializer.createAccessor(i); ++ SynchedEntityData.ENTITY_ID_POOL.put(clazz, i); ++ return serializer.createAccessor(i); + } + } + +- public <T> void define(EntityDataAccessor<T> entitydataaccessor, T t0) { +- int i = entitydataaccessor.getId(); ++ public <T> void define(EntityDataAccessor<T> key, T value) { ++ int i = key.getId(); + + if (i > 254) { + throw new IllegalArgumentException("Data value id is too big with " + i + "! (Max is 254)"); + } else if (this.itemsById.containsKey(i)) { + throw new IllegalArgumentException("Duplicate id value for " + i + "!"); +- } else if (EntityDataSerializers.getSerializedId(entitydataaccessor.getSerializer()) < 0) { +- EntityDataSerializer entitydataserializer = entitydataaccessor.getSerializer(); ++ } else if (EntityDataSerializers.getSerializedId(key.getSerializer()) < 0) { ++ EntityDataSerializer datawatcherserializer = key.getSerializer(); + +- throw new IllegalArgumentException("Unregistered serializer " + entitydataserializer + " for " + i + "!"); ++ throw new IllegalArgumentException("Unregistered serializer " + datawatcherserializer + " for " + i + "!"); + } else { +- this.createDataItem(entitydataaccessor, t0); ++ this.createDataItem(key, value); + } + } + +- private <T> void createDataItem(EntityDataAccessor<T> entitydataaccessor, T t0) { +- SynchedEntityData.DataItem<T> synchedentitydata_dataitem = new SynchedEntityData.DataItem<>(entitydataaccessor, t0); ++ private <T> void createDataItem(EntityDataAccessor<T> key, T value) { ++ SynchedEntityData.DataItem<T> datawatcher_item = new SynchedEntityData.DataItem<>(key, value); + + this.lock.writeLock().lock(); +- this.itemsById.put(entitydataaccessor.getId(), synchedentitydata_dataitem); ++ this.itemsById.put(key.getId(), datawatcher_item); + this.lock.writeLock().unlock(); + } + +- public <T> boolean hasItem(EntityDataAccessor<T> entitydataaccessor) { +- return this.itemsById.containsKey(entitydataaccessor.getId()); ++ public <T> boolean hasItem(EntityDataAccessor<T> key) { ++ return this.itemsById.containsKey(key.getId()); + } + +- private <T> SynchedEntityData.DataItem<T> getItem(EntityDataAccessor<T> entitydataaccessor) { ++ private <T> SynchedEntityData.DataItem<T> getItem(EntityDataAccessor<T> key) { + this.lock.readLock().lock(); + +- SynchedEntityData.DataItem synchedentitydata_dataitem; ++ SynchedEntityData.DataItem datawatcher_item; + + try { +- synchedentitydata_dataitem = (SynchedEntityData.DataItem) this.itemsById.get(entitydataaccessor.getId()); ++ datawatcher_item = (SynchedEntityData.DataItem) this.itemsById.get(key.getId()); + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.forThrowable(throwable, "Getting synched entity data"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Synched entity data"); ++ CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Synched entity data"); + +- crashreportcategory.setDetail("Data ID", (Object) entitydataaccessor); ++ crashreportsystemdetails.setDetail("Data ID", (Object) key); + throw new ReportedException(crashreport); + } finally { + this.lock.readLock().unlock(); + } + +- return synchedentitydata_dataitem; ++ return datawatcher_item; + } + +- public <T> T get(EntityDataAccessor<T> entitydataaccessor) { +- return this.getItem(entitydataaccessor).getValue(); ++ public <T> T get(EntityDataAccessor<T> key) { ++ return this.getItem(key).getValue(); + } + +- public <T> void set(EntityDataAccessor<T> entitydataaccessor, T t0) { +- this.set(entitydataaccessor, t0, false); ++ public <T> void set(EntityDataAccessor<T> key, T value) { ++ this.set(key, value, false); + } + +- public <T> void set(EntityDataAccessor<T> entitydataaccessor, T t0, boolean flag) { +- SynchedEntityData.DataItem<T> synchedentitydata_dataitem = this.getItem(entitydataaccessor); ++ public <T> void set(EntityDataAccessor<T> key, T value, boolean force) { ++ SynchedEntityData.DataItem<T> datawatcher_item = this.getItem(key); + +- if (flag || ObjectUtils.notEqual(t0, synchedentitydata_dataitem.getValue())) { +- synchedentitydata_dataitem.setValue(t0); +- this.entity.onSyncedDataUpdated(entitydataaccessor); +- synchedentitydata_dataitem.setDirty(true); ++ if (force || ObjectUtils.notEqual(value, datawatcher_item.getValue())) { ++ datawatcher_item.setValue(value); ++ this.entity.onSyncedDataUpdated(key); ++ datawatcher_item.setDirty(true); + this.isDirty = true; + } + + } + ++ // CraftBukkit start - add method from above ++ public <T> void markDirty(EntityDataAccessor<T> datawatcherobject) { ++ this.getItem(datawatcherobject).setDirty(true); ++ this.isDirty = true; ++ } ++ // CraftBukkit end ++ + public boolean isDirty() { + return this.isDirty; + } +@@ -159,15 +168,15 @@ + ObjectIterator objectiterator = this.itemsById.values().iterator(); + + while (objectiterator.hasNext()) { +- SynchedEntityData.DataItem<?> synchedentitydata_dataitem = (SynchedEntityData.DataItem) objectiterator.next(); ++ SynchedEntityData.DataItem<?> datawatcher_item = (SynchedEntityData.DataItem) objectiterator.next(); + +- if (synchedentitydata_dataitem.isDirty()) { +- synchedentitydata_dataitem.setDirty(false); ++ if (datawatcher_item.isDirty()) { ++ datawatcher_item.setDirty(false); + if (list == null) { + list = new ArrayList(); + } + +- list.add(synchedentitydata_dataitem.value()); ++ list.add(datawatcher_item.value()); + } + } + +@@ -186,14 +195,14 @@ + ObjectIterator objectiterator = this.itemsById.values().iterator(); + + while (objectiterator.hasNext()) { +- SynchedEntityData.DataItem<?> synchedentitydata_dataitem = (SynchedEntityData.DataItem) objectiterator.next(); ++ SynchedEntityData.DataItem<?> datawatcher_item = (SynchedEntityData.DataItem) objectiterator.next(); + +- if (!synchedentitydata_dataitem.isSetToDefault()) { ++ if (!datawatcher_item.isSetToDefault()) { + if (list == null) { + list = new ArrayList(); + } + +- list.add(synchedentitydata_dataitem.value()); ++ list.add(datawatcher_item.value()); + } + } + +@@ -201,33 +210,33 @@ + return list; + } + +- public void assignValues(List<SynchedEntityData.DataValue<?>> list) { ++ public void assignValues(List<SynchedEntityData.DataValue<?>> entries) { + this.lock.writeLock().lock(); + + try { +- Iterator iterator = list.iterator(); ++ Iterator iterator = entries.iterator(); + + while (iterator.hasNext()) { +- SynchedEntityData.DataValue<?> synchedentitydata_datavalue = (SynchedEntityData.DataValue) iterator.next(); +- SynchedEntityData.DataItem<?> synchedentitydata_dataitem = (SynchedEntityData.DataItem) this.itemsById.get(synchedentitydata_datavalue.id); ++ SynchedEntityData.DataValue<?> datawatcher_b = (SynchedEntityData.DataValue) iterator.next(); ++ SynchedEntityData.DataItem<?> datawatcher_item = (SynchedEntityData.DataItem) this.itemsById.get(datawatcher_b.id); + +- if (synchedentitydata_dataitem != null) { +- this.assignValue(synchedentitydata_dataitem, synchedentitydata_datavalue); +- this.entity.onSyncedDataUpdated(synchedentitydata_dataitem.getAccessor()); ++ if (datawatcher_item != null) { ++ this.assignValue(datawatcher_item, datawatcher_b); ++ this.entity.onSyncedDataUpdated(datawatcher_item.getAccessor()); + } + } + } finally { + this.lock.writeLock().unlock(); + } + +- this.entity.onSyncedDataUpdated(list); ++ this.entity.onSyncedDataUpdated(entries); + } + +- private <T> void assignValue(SynchedEntityData.DataItem<T> synchedentitydata_dataitem, SynchedEntityData.DataValue<?> synchedentitydata_datavalue) { +- if (!Objects.equals(synchedentitydata_datavalue.serializer(), synchedentitydata_dataitem.accessor.getSerializer())) { +- throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", synchedentitydata_dataitem.accessor.getId(), this.entity, synchedentitydata_dataitem.value, synchedentitydata_dataitem.value.getClass(), synchedentitydata_datavalue.value, synchedentitydata_datavalue.value.getClass())); ++ private <T> void assignValue(SynchedEntityData.DataItem<T> target, SynchedEntityData.DataValue<?> entry) { ++ if (!Objects.equals(entry.serializer(), target.accessor.getSerializer())) { ++ throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", target.accessor.getId(), this.entity, target.value, target.value.getClass(), entry.value, entry.value.getClass())); + } else { +- synchedentitydata_dataitem.setValue(synchedentitydata_datavalue.value); ++ target.setValue((T) entry.value); // CraftBukkit - decompile error + } + } + +@@ -235,6 +244,18 @@ + return this.itemsById.isEmpty(); + } + ++ // CraftBukkit start ++ public void refresh(ServerPlayer to) { ++ if (!this.isEmpty()) { ++ List<SynchedEntityData.DataValue<?>> list = this.getNonDefaultValues(); ++ ++ if (list != null) { ++ to.connection.send(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); ++ } ++ } ++ } ++ // CraftBukkit end ++ + public static class DataItem<T> { + + final EntityDataAccessor<T> accessor; +@@ -242,18 +263,18 @@ + private final T initialValue; + private boolean dirty; + +- public DataItem(EntityDataAccessor<T> entitydataaccessor, T t0) { +- this.accessor = entitydataaccessor; +- this.initialValue = t0; +- this.value = t0; ++ public DataItem(EntityDataAccessor<T> accessor, T value) { ++ this.accessor = accessor; ++ this.initialValue = value; ++ this.value = value; + } + + public EntityDataAccessor<T> getAccessor() { + return this.accessor; + } + +- public void setValue(T t0) { +- this.value = t0; ++ public void setValue(T value) { ++ this.value = value; + } + + public T getValue() { +@@ -264,8 +285,8 @@ + return this.dirty; + } + +- public void setDirty(boolean flag) { +- this.dirty = flag; ++ public void setDirty(boolean dirty) { ++ this.dirty = dirty; + } + + public boolean isSetToDefault() { +@@ -277,39 +298,39 @@ + } + } + +- public static record DataValue<T> (int id, EntityDataSerializer<T> serializer, T value) { ++ public static record DataValue<T>(int id, EntityDataSerializer<T> serializer, T value) { // CraftBukkit - decompile error + +- public static <T> SynchedEntityData.DataValue<T> create(EntityDataAccessor<T> entitydataaccessor, T t0) { +- EntityDataSerializer<T> entitydataserializer = entitydataaccessor.getSerializer(); ++ public static <T> SynchedEntityData.DataValue<T> create(EntityDataAccessor<T> dataAccessor, T value) { ++ EntityDataSerializer<T> datawatcherserializer = dataAccessor.getSerializer(); + +- return new SynchedEntityData.DataValue<>(entitydataaccessor.getId(), entitydataserializer, entitydataserializer.copy(t0)); ++ return new SynchedEntityData.DataValue<>(dataAccessor.getId(), datawatcherserializer, datawatcherserializer.copy(value)); + } + +- public void write(FriendlyByteBuf friendlybytebuf) { ++ public void write(FriendlyByteBuf buffer) { + int i = EntityDataSerializers.getSerializedId(this.serializer); + + if (i < 0) { + throw new EncoderException("Unknown serializer type " + this.serializer); + } else { +- friendlybytebuf.writeByte(this.id); +- friendlybytebuf.writeVarInt(i); +- this.serializer.write(friendlybytebuf, this.value); ++ buffer.writeByte(this.id); ++ buffer.writeVarInt(i); ++ this.serializer.write(buffer, this.value); + } + } + +- public static SynchedEntityData.DataValue<?> read(FriendlyByteBuf friendlybytebuf, int i) { +- int j = friendlybytebuf.readVarInt(); +- EntityDataSerializer<?> entitydataserializer = EntityDataSerializers.getSerializer(j); ++ public static SynchedEntityData.DataValue<?> read(FriendlyByteBuf buffer, int id) { ++ int j = buffer.readVarInt(); ++ EntityDataSerializer<?> datawatcherserializer = EntityDataSerializers.getSerializer(j); + +- if (entitydataserializer == null) { ++ if (datawatcherserializer == null) { + throw new DecoderException("Unknown serializer type " + j); + } else { +- return read(friendlybytebuf, i, entitydataserializer); ++ return read(buffer, id, datawatcherserializer); + } + } + +- private static <T> SynchedEntityData.DataValue<T> read(FriendlyByteBuf friendlybytebuf, int i, EntityDataSerializer<T> entitydataserializer) { +- return new SynchedEntityData.DataValue<>(i, entitydataserializer, entitydataserializer.read(friendlybytebuf)); ++ private static <T> SynchedEntityData.DataValue<T> read(FriendlyByteBuf buffer, int id, EntityDataSerializer<T> serializer) { ++ return new SynchedEntityData.DataValue<>(id, serializer, serializer.read(buffer)); + } + } + } |