diff options
author | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
commit | bee74680e607c2e29b038329f62181238911cd83 (patch) | |
tree | 708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-vineflower/net/minecraft/network | |
parent | 0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff) | |
download | Paper-softspoon.tar.gz Paper-softspoon.zip |
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/network')
14 files changed, 4063 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/network/Connection.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/Connection.java.patch new file mode 100644 index 0000000000..a6d2bea9d7 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/Connection.java.patch @@ -0,0 +1,697 @@ +--- a/net/minecraft/network/Connection.java ++++ b/net/minecraft/network/Connection.java +@@ -9,6 +9,7 @@ + import io.netty.channel.ChannelException; + import io.netty.channel.ChannelFuture; + import io.netty.channel.ChannelFutureListener; ++import io.netty.channel.ChannelHandler; + import io.netty.channel.ChannelHandlerContext; + import io.netty.channel.ChannelInitializer; + import io.netty.channel.ChannelOption; +@@ -28,7 +29,6 @@ + import io.netty.handler.timeout.ReadTimeoutHandler; + import io.netty.handler.timeout.TimeoutException; + import io.netty.util.AttributeKey; +-import io.netty.util.concurrent.Future; + import java.net.InetSocketAddress; + import java.net.SocketAddress; + import java.util.Objects; +@@ -41,6 +41,7 @@ + import net.minecraft.SharedConstants; + import net.minecraft.Util; + import net.minecraft.network.chat.Component; ++import net.minecraft.network.chat.MutableComponent; + import net.minecraft.network.protocol.Packet; + import net.minecraft.network.protocol.PacketFlow; + import net.minecraft.network.protocol.common.ClientboundDisconnectPacket; +@@ -49,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; +@@ -58,27 +59,34 @@ + import org.slf4j.MarkerFactory; + + public class Connection extends SimpleChannelInboundHandler<Packet<?>> { ++ + private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F; + private static final Logger LOGGER = LogUtils.getLogger(); + public static final Marker ROOT_MARKER = MarkerFactory.getMarker("NETWORK"); +- public static final Marker PACKET_MARKER = Util.make(MarkerFactory.getMarker("NETWORK_PACKETS"), marker -> marker.add(ROOT_MARKER)); +- public static final Marker PACKET_RECEIVED_MARKER = Util.make(MarkerFactory.getMarker("PACKET_RECEIVED"), marker -> marker.add(PACKET_MARKER)); +- public static final Marker PACKET_SENT_MARKER = Util.make(MarkerFactory.getMarker("PACKET_SENT"), marker -> marker.add(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 Supplier<NioEventLoopGroup> NETWORK_WORKER_GROUP = Suppliers.memoize( +- () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Client IO #%d").setDaemon(true).build()) +- ); +- public static final Supplier<EpollEventLoopGroup> NETWORK_EPOLL_WORKER_GROUP = Suppliers.memoize( +- () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build()) +- ); +- public static final Supplier<DefaultEventLoopGroup> LOCAL_WORKER_GROUP = Suppliers.memoize( +- () -> new DefaultEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Local Client IO #%d").setDaemon(true).build()) +- ); ++ public static final Marker PACKET_MARKER = (Marker) Util.make(MarkerFactory.getMarker("NETWORK_PACKETS"), (marker) -> { ++ marker.add(Connection.ROOT_MARKER); ++ }); ++ public static final Marker PACKET_RECEIVED_MARKER = (Marker) Util.make(MarkerFactory.getMarker("PACKET_RECEIVED"), (marker) -> { ++ marker.add(Connection.PACKET_MARKER); ++ }); ++ 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.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()); ++ }); ++ public static final Supplier<EpollEventLoopGroup> NETWORK_EPOLL_WORKER_GROUP = Suppliers.memoize(() -> { ++ return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build()); ++ }); ++ public static final Supplier<DefaultEventLoopGroup> LOCAL_WORKER_GROUP = Suppliers.memoize(() -> { ++ return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).build()); ++ }); + 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 +@@ -97,92 +105,97 @@ + private volatile Component delayedDisconnect; + @Nullable + BandwidthDebugMonitor bandwidthDebugMonitor; ++ public String hostname = ""; // CraftBukkit - add field + + public Connection(PacketFlow receiving) { + this.receiving = receiving; + } + +- @Override +- public void channelActive(ChannelHandlerContext context) throws Exception { +- super.channelActive(context); +- this.channel = context.channel(); ++ public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { ++ super.channelActive(channelhandlercontext); ++ this.channel = channelhandlercontext.channel(); + this.address = this.channel.remoteAddress(); + if (this.delayedDisconnect != null) { + this.disconnect(this.delayedDisconnect); + } ++ + } + + public static void setInitialProtocolAttributes(Channel channel) { +- channel.attr(ATTRIBUTE_SERVERBOUND_PROTOCOL).set(ConnectionProtocol.HANDSHAKING.codec(PacketFlow.SERVERBOUND)); +- channel.attr(ATTRIBUTE_CLIENTBOUND_PROTOCOL).set(ConnectionProtocol.HANDSHAKING.codec(PacketFlow.CLIENTBOUND)); ++ channel.attr(Connection.ATTRIBUTE_SERVERBOUND_PROTOCOL).set(ConnectionProtocol.HANDSHAKING.codec(PacketFlow.SERVERBOUND)); ++ channel.attr(Connection.ATTRIBUTE_CLIENTBOUND_PROTOCOL).set(ConnectionProtocol.HANDSHAKING.codec(PacketFlow.CLIENTBOUND)); + } + +- @Override +- public void channelInactive(ChannelHandlerContext context) { ++ public void channelInactive(ChannelHandlerContext channelhandlercontext) { + this.disconnect(Component.translatable("disconnect.endOfStream")); + } + +- @Override +- public void exceptionCaught(ChannelHandlerContext context, Throwable exception) { +- if (exception instanceof SkipPacketException) { +- LOGGER.debug("Skipping packet due to errors", exception.getCause()); ++ public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) { ++ if (throwable instanceof SkipPacketException) { ++ Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause()); + } else { + boolean flag = !this.handlingFault; ++ + this.handlingFault = true; + if (this.channel.isOpen()) { +- if (exception instanceof TimeoutException) { +- LOGGER.debug("Timeout", exception); ++ if (throwable instanceof TimeoutException) { ++ Connection.LOGGER.debug("Timeout", throwable); + this.disconnect(Component.translatable("disconnect.timeout")); + } else { +- Component component = Component.translatable("disconnect.genericReason", "Internal Exception: " + exception); ++ MutableComponent ichatmutablecomponent = Component.translatable("disconnect.genericReason", "Internal Exception: " + throwable); ++ + if (flag) { +- LOGGER.debug("Failed to sent packet", exception); ++ Connection.LOGGER.debug("Failed to sent packet", throwable); + if (this.getSending() == PacketFlow.CLIENTBOUND) { +- ConnectionProtocol connectionProtocol = this.channel.attr(ATTRIBUTE_CLIENTBOUND_PROTOCOL).get().protocol(); +- Packet<?> packet = (Packet<?>)(connectionProtocol == ConnectionProtocol.LOGIN +- ? new ClientboundLoginDisconnectPacket(component) +- : new ClientboundDisconnectPacket(component)); +- this.send(packet, PacketSendListener.thenRun(() -> this.disconnect(component))); ++ 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(ichatmutablecomponent); ++ })); + } else { +- this.disconnect(component); ++ this.disconnect(ichatmutablecomponent); + } + + this.setReadOnly(); + } else { +- LOGGER.debug("Double fault", exception); +- this.disconnect(component); ++ Connection.LOGGER.debug("Double fault", throwable); ++ this.disconnect(ichatmutablecomponent); + } + } ++ + } + } + } + +- @Override + protected void channelRead0(ChannelHandlerContext context, Packet<?> packet) { + if (this.channel.isOpen()) { +- PacketListener packetListener = this.packetListener; +- if (packetListener == null) { ++ PacketListener packetlistener = this.packetListener; ++ ++ if (packetlistener == null) { + throw new IllegalStateException("Received a packet before the packet listener was initialized"); + } else { +- if (packetListener.shouldHandleMessage(packet)) { ++ if (packetlistener.shouldHandleMessage(packet)) { + try { +- genericsFtw(packet, packetListener); +- } catch (RunningOnDifferentThreadException var5) { +- } catch (RejectedExecutionException var6) { ++ genericsFtw(packet, packetlistener); ++ } catch (CancelledPacketHandleException cancelledpackethandleexception) { ++ ; ++ } catch (RejectedExecutionException rejectedexecutionexception) { + this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); +- } catch (ClassCastException var7) { +- LOGGER.error("Received {} that couldn't be processed", packet.getClass(), var7); ++ } catch (ClassCastException classcastexception) { ++ Connection.LOGGER.error("Received {} that couldn't be processed", packet.getClass(), classcastexception); + this.disconnect(Component.translatable("multiplayer.disconnect.invalid_packet")); + } + +- this.receivedPackets++; ++ ++this.receivedPackets; + } ++ + } + } + } + + private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) { +- packet.handle((T)listener); ++ packet.handle((T) listener); // CraftBukkit - decompile error + } + + public void suspendInboundAfterProtocolChange() { +@@ -194,22 +207,17 @@ + } + + public void setListener(PacketListener handler) { +- Validate.notNull(handler, "packetListener"); +- PacketFlow packetFlow = handler.flow(); +- if (packetFlow != this.receiving) { +- throw new IllegalStateException("Trying to set listener for wrong side: connection is " + this.receiving + ", but listener is " + packetFlow); ++ Validate.notNull(handler, "packetListener", new Object[0]); ++ PacketFlow enumprotocoldirection = handler.flow(); ++ ++ 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 = handler.protocol(); +- ConnectionProtocol connectionProtocol1 = this.channel.attr(getProtocolKey(packetFlow)).get().protocol(); +- if (connectionProtocol1 != connectionProtocol) { +- throw new IllegalStateException( +- "Trying to set listener for protocol " +- + connectionProtocol.id() +- + ", but current " +- + packetFlow +- + " protocol is " +- + connectionProtocol1.id() +- ); ++ ConnectionProtocol enumprotocol = handler.protocol(); ++ ConnectionProtocol enumprotocol1 = ((ConnectionProtocol.a) this.channel.attr(getProtocolKey(enumprotocoldirection)).get()).protocol(); ++ ++ if (enumprotocol1 != enumprotocol) { ++ throw new IllegalStateException("Trying to set listener for protocol " + enumprotocol.id() + ", but current " + enumprotocoldirection + " protocol is " + enumprotocol1.id()); + } else { + this.packetListener = handler; + this.disconnectListener = null; +@@ -217,54 +225,55 @@ + } + } + +- public void setListenerForServerboundHandshake(PacketListener packetListener) { ++ public void setListenerForServerboundHandshake(PacketListener packetlistener) { + if (this.packetListener != null) { + throw new IllegalStateException("Listener already set"); +- } else if (this.receiving == PacketFlow.SERVERBOUND +- && packetListener.flow() == PacketFlow.SERVERBOUND +- && packetListener.protocol() == ConnectionProtocol.HANDSHAKING) { +- this.packetListener = packetListener; ++ } else if (this.receiving == PacketFlow.SERVERBOUND && packetlistener.flow() == PacketFlow.SERVERBOUND && packetlistener.protocol() == ConnectionProtocol.HANDSHAKING) { ++ this.packetListener = packetlistener; + } else { + throw new IllegalStateException("Invalid initial listener"); + } + } + +- public void initiateServerboundStatusConnection(String string, int i, ClientStatusPacketListener clientStatusPacketListener) { +- this.initiateServerboundConnection(string, i, clientStatusPacketListener, ClientIntent.STATUS); ++ public void initiateServerboundStatusConnection(String s, int i, ClientStatusPacketListener packetstatusoutlistener) { ++ this.initiateServerboundConnection(s, i, packetstatusoutlistener, ClientIntent.STATUS); + } + +- public void initiateServerboundPlayConnection(String string, int i, ClientLoginPacketListener clientLoginPacketListener) { +- this.initiateServerboundConnection(string, i, clientLoginPacketListener, ClientIntent.LOGIN); ++ public void initiateServerboundPlayConnection(String s, int i, ClientLoginPacketListener packetloginoutlistener) { ++ this.initiateServerboundConnection(s, i, packetloginoutlistener, ClientIntent.LOGIN); + } + +- private void initiateServerboundConnection(String string, int i, PacketListener packetListener, ClientIntent clientIntent) { +- this.disconnectListener = packetListener; +- this.runOnceConnected(connection -> { +- connection.setClientboundProtocolAfterHandshake(clientIntent); +- this.setListener(packetListener); +- connection.sendPacket(new ClientIntentionPacket(SharedConstants.getCurrentVersion().getProtocolVersion(), string, i, clientIntent), null, true); ++ private void initiateServerboundConnection(String s, int i, PacketListener packetlistener, ClientIntent clientintent) { ++ this.disconnectListener = packetlistener; ++ this.runOnceConnected((networkmanager) -> { ++ networkmanager.setClientboundProtocolAfterHandshake(clientintent); ++ this.setListener(packetlistener); ++ networkmanager.sendPacket(new ClientIntentionPacket(SharedConstants.getCurrentVersion().getProtocolVersion(), s, i, clientintent), (PacketSendListener) null, true); + }); + } + +- public void setClientboundProtocolAfterHandshake(ClientIntent clientIntent) { +- this.channel.attr(ATTRIBUTE_CLIENTBOUND_PROTOCOL).set(clientIntent.protocol().codec(PacketFlow.CLIENTBOUND)); ++ public void setClientboundProtocolAfterHandshake(ClientIntent clientintent) { ++ this.channel.attr(Connection.ATTRIBUTE_CLIENTBOUND_PROTOCOL).set(clientintent.protocol().codec(PacketFlow.CLIENTBOUND)); + } + + public void send(Packet<?> packet) { +- this.send(packet, null); ++ this.send(packet, (PacketSendListener) null); + } + + public void send(Packet<?> packet, @Nullable PacketSendListener sendListener) { + this.send(packet, sendListener, true); + } + +- public void send(Packet<?> packet, @Nullable PacketSendListener packetSendListener, boolean flag) { ++ public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, boolean flag) { + if (this.isConnected()) { + this.flushQueue(); +- this.sendPacket(packet, packetSendListener, flag); ++ this.sendPacket(packet, packetsendlistener, flag); + } else { +- this.pendingActions.add(connection -> connection.sendPacket(packet, packetSendListener, flag)); ++ this.pendingActions.add((networkmanager) -> { ++ networkmanager.sendPacket(packet, packetsendlistener, flag); ++ }); + } ++ + } + + public void runOnceConnected(Consumer<Connection> consumer) { +@@ -274,34 +283,42 @@ + } else { + this.pendingActions.add(consumer); + } ++ + } + +- private void sendPacket(Packet<?> packet, @Nullable PacketSendListener packetSendListener, boolean flag) { +- this.sentPackets++; ++ private void sendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, boolean flag) { ++ ++this.sentPackets; + if (this.channel.eventLoop().inEventLoop()) { +- this.doSendPacket(packet, packetSendListener, flag); ++ this.doSendPacket(packet, packetsendlistener, flag); + } else { +- this.channel.eventLoop().execute(() -> this.doSendPacket(packet, packetSendListener, flag)); ++ this.channel.eventLoop().execute(() -> { ++ this.doSendPacket(packet, packetsendlistener, flag); ++ }); + } ++ + } + +- private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener packetSendListener, boolean flag) { +- ChannelFuture channelFuture = flag ? this.channel.writeAndFlush(packet) : this.channel.write(packet); +- if (packetSendListener != null) { +- channelFuture.addListener(future -> { ++ private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, boolean flag) { ++ ChannelFuture channelfuture = flag ? this.channel.writeAndFlush(packet) : this.channel.write(packet); ++ ++ if (packetsendlistener != null) { ++ channelfuture.addListener((future) -> { + if (future.isSuccess()) { +- packetSendListener.onSuccess(); ++ packetsendlistener.onSuccess(); + } else { +- Packet<?> packet1 = packetSendListener.onFailure(); ++ Packet<?> packet1 = packetsendlistener.onFailure(); ++ + if (packet1 != null) { +- ChannelFuture channelFuture1 = this.channel.writeAndFlush(packet1); +- channelFuture1.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); ++ ChannelFuture channelfuture1 = this.channel.writeAndFlush(packet1); ++ ++ channelfuture1.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + } ++ + }); + } + +- channelFuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); ++ channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + + public void flushChannel() { +@@ -310,38 +327,60 @@ + } else { + this.pendingActions.add(Connection::flush); + } ++ + } + + private void flush() { + if (this.channel.eventLoop().inEventLoop()) { + this.channel.flush(); + } else { +- this.channel.eventLoop().execute(() -> this.channel.flush()); ++ this.channel.eventLoop().execute(() -> { ++ this.channel.flush(); ++ }); + } ++ + } + +- private static AttributeKey<ConnectionProtocol.CodecData<?>> getProtocolKey(PacketFlow packetFlow) { +- return switch (packetFlow) { +- case CLIENTBOUND -> ATTRIBUTE_CLIENTBOUND_PROTOCOL; +- case SERVERBOUND -> ATTRIBUTE_SERVERBOUND_PROTOCOL; +- }; ++ private static AttributeKey<ConnectionProtocol.a<?>> getProtocolKey(PacketFlow enumprotocoldirection) { ++ AttributeKey attributekey; ++ ++ switch (enumprotocoldirection) { ++ case CLIENTBOUND: ++ attributekey = Connection.ATTRIBUTE_CLIENTBOUND_PROTOCOL; ++ break; ++ case SERVERBOUND: ++ attributekey = Connection.ATTRIBUTE_SERVERBOUND_PROTOCOL; ++ break; ++ default: ++ throw new IncompatibleClassChangeError(); ++ } ++ ++ return attributekey; + } + + private void flushQueue() { + if (this.channel != null && this.channel.isOpen()) { ++ Queue queue = this.pendingActions; ++ + synchronized (this.pendingActions) { +- Consumer<Connection> consumer; +- while ((consumer = this.pendingActions.poll()) != null) { ++ Consumer consumer; ++ ++ while ((consumer = (Consumer) this.pendingActions.poll()) != null) { + consumer.accept(this); + } ++ + } + } + } + + public void tick() { + this.flushQueue(); +- if (this.packetListener instanceof TickablePacketListener tickablePacketListener) { +- tickablePacketListener.tick(); ++ PacketListener packetlistener = this.packetListener; ++ ++ if (packetlistener instanceof TickablePacketListener) { ++ TickablePacketListener tickablepacketlistener = (TickablePacketListener) packetlistener; ++ ++ tickablepacketlistener.tick(); + } + + if (!this.isConnected() && !this.disconnectionHandled) { +@@ -359,11 +398,12 @@ + if (this.bandwidthDebugMonitor != null) { + this.bandwidthDebugMonitor.tick(); + } ++ + } + + protected void tickSecond() { +- this.averageSentPackets = Mth.lerp(0.75F, (float)this.sentPackets, this.averageSentPackets); +- this.averageReceivedPackets = Mth.lerp(0.75F, (float)this.receivedPackets, this.averageReceivedPackets); ++ this.averageSentPackets = Mth.lerp(0.75F, (float) this.sentPackets, this.averageSentPackets); ++ this.averageReceivedPackets = Mth.lerp(0.75F, (float) this.receivedPackets, this.averageReceivedPackets); + this.sentPackets = 0; + this.receivedPackets = 0; + } +@@ -373,11 +413,7 @@ + } + + public String getLoggableAddress(boolean flag) { +- if (this.address == null) { +- return "local"; +- } else { +- return flag ? this.address.toString() : "IP hidden"; +- } ++ return this.address == null ? "local" : (flag ? this.address.toString() : "IP hidden"); + } + + public void disconnect(Component message) { +@@ -386,9 +422,10 @@ + } + + if (this.isConnected()) { +- this.channel.close().awaitUninterruptibly(); ++ this.channel.close(); // We can't wait as this may be called from an event loop. + this.disconnectedReason = message; + } ++ + } + + public boolean isMemoryConnection() { +@@ -403,84 +440,86 @@ + return this.receiving.getOpposite(); + } + +- public static Connection connectToServer(InetSocketAddress inetSocketAddress, boolean flag, @Nullable SampleLogger sampleLogger) { +- Connection connection = new Connection(PacketFlow.CLIENTBOUND); +- if (sampleLogger != null) { +- connection.setBandwidthLogger(sampleLogger); ++ public static Connection connectToServer(InetSocketAddress inetsocketaddress, boolean flag, @Nullable SampleLogger samplelogger) { ++ Connection networkmanager = new Connection(PacketFlow.CLIENTBOUND); ++ ++ if (samplelogger != null) { ++ networkmanager.setBandwidthLogger(samplelogger); + } + +- ChannelFuture channelFuture = connect(inetSocketAddress, flag, connection); +- channelFuture.syncUninterruptibly(); +- return connection; ++ ChannelFuture channelfuture = connect(inetsocketaddress, flag, networkmanager); ++ ++ channelfuture.syncUninterruptibly(); ++ return networkmanager; + } + + public static ChannelFuture connect(InetSocketAddress address, boolean useEpollIfAvailable, final Connection connection) { +- Class<? extends SocketChannel> clazz; +- EventLoopGroup eventLoopGroup; ++ Class oclass; ++ EventLoopGroup eventloopgroup; ++ + if (Epoll.isAvailable() && useEpollIfAvailable) { +- clazz = EpollSocketChannel.class; +- eventLoopGroup = NETWORK_EPOLL_WORKER_GROUP.get(); ++ oclass = EpollSocketChannel.class; ++ eventloopgroup = (EventLoopGroup) Connection.NETWORK_EPOLL_WORKER_GROUP.get(); + } else { +- clazz = NioSocketChannel.class; +- eventLoopGroup = NETWORK_WORKER_GROUP.get(); ++ oclass = NioSocketChannel.class; ++ eventloopgroup = (EventLoopGroup) Connection.NETWORK_WORKER_GROUP.get(); + } + +- return new Bootstrap().group(eventLoopGroup).handler(new ChannelInitializer<Channel>() { +- @Override ++ return ((Bootstrap) ((Bootstrap) ((Bootstrap) (new Bootstrap()).group(eventloopgroup)).handler(new ChannelInitializer<Channel>() { + protected void initChannel(Channel channel) { + Connection.setInitialProtocolAttributes(channel); + + try { + channel.config().setOption(ChannelOption.TCP_NODELAY, true); +- } catch (ChannelException var3) { ++ } catch (ChannelException channelexception) { ++ ; + } + +- ChannelPipeline channelPipeline = channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30)); +- Connection.configureSerialization(channelPipeline, PacketFlow.CLIENTBOUND, connection.bandwidthDebugMonitor); +- connection.configurePacketHandler(channelPipeline); ++ ChannelPipeline channelpipeline = channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30)); ++ ++ Connection.configureSerialization(channelpipeline, PacketFlow.CLIENTBOUND, connection.bandwidthDebugMonitor); ++ connection.configurePacketHandler(channelpipeline); + } +- }).channel(clazz).connect(address.getAddress(), address.getPort()); ++ })).channel(oclass)).connect(address.getAddress(), address.getPort()); + } + +- public static void configureSerialization(ChannelPipeline channelPipeline, PacketFlow packetFlow, @Nullable BandwidthDebugMonitor bandwidthDebugMonitor) { +- PacketFlow opposite = packetFlow.getOpposite(); +- AttributeKey<ConnectionProtocol.CodecData<?>> protocolKey = getProtocolKey(packetFlow); +- AttributeKey<ConnectionProtocol.CodecData<?>> protocolKey1 = getProtocolKey(opposite); +- channelPipeline.addLast("splitter", new Varint21FrameDecoder(bandwidthDebugMonitor)) +- .addLast("decoder", new PacketDecoder(protocolKey)) +- .addLast("prepender", new Varint21LengthFieldPrepender()) +- .addLast("encoder", new PacketEncoder(protocolKey1)) +- .addLast("unbundler", new PacketBundleUnpacker(protocolKey1)) +- .addLast("bundler", new PacketBundlePacker(protocolKey)); ++ 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)); + } + +- public void configurePacketHandler(ChannelPipeline channelPipeline) { +- channelPipeline.addLast(new FlowControlHandler()).addLast("packet_handler", this); ++ public void configurePacketHandler(ChannelPipeline channelpipeline) { ++ channelpipeline.addLast(new ChannelHandler[]{new FlowControlHandler()}).addLast("packet_handler", this); + } + +- private static void configureInMemoryPacketValidation(ChannelPipeline channelPipeline, PacketFlow packetFlow) { +- PacketFlow opposite = packetFlow.getOpposite(); +- AttributeKey<ConnectionProtocol.CodecData<?>> protocolKey = getProtocolKey(packetFlow); +- AttributeKey<ConnectionProtocol.CodecData<?>> protocolKey1 = getProtocolKey(opposite); +- channelPipeline.addLast("validator", new PacketFlowValidator(protocolKey, protocolKey1)); ++ 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 address) { +- final Connection connection = new Connection(PacketFlow.CLIENTBOUND); +- new Bootstrap().group(LOCAL_WORKER_GROUP.get()).handler(new ChannelInitializer<Channel>() { +- @Override ++ final Connection networkmanager = new Connection(PacketFlow.CLIENTBOUND); ++ ++ ((Bootstrap) ((Bootstrap) ((Bootstrap) (new Bootstrap()).group((EventLoopGroup) Connection.LOCAL_WORKER_GROUP.get())).handler(new ChannelInitializer<Channel>() { + protected void initChannel(Channel channel) { + Connection.setInitialProtocolAttributes(channel); +- ChannelPipeline channelPipeline = channel.pipeline(); +- Connection.configureInMemoryPacketValidation(channelPipeline, PacketFlow.CLIENTBOUND); +- connection.configurePacketHandler(channelPipeline); ++ ChannelPipeline channelpipeline = channel.pipeline(); ++ ++ Connection.configureInMemoryPipeline(channelpipeline, PacketFlow.CLIENTBOUND); ++ networkmanager.configurePacketHandler(channelpipeline); + } +- }).channel(LocalChannel.class).connect(address).syncUninterruptibly(); +- return connection; ++ })).channel(LocalChannel.class)).connect(address).syncUninterruptibly(); ++ return networkmanager; + } + + public void setEncryptionKey(Cipher decryptingCipher, Cipher encryptingCipher) { +@@ -515,18 +554,19 @@ + if (this.channel != null) { + this.channel.config().setAutoRead(false); + } ++ + } + + 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(threshold, validateDecompressed); ++ ((CompressionDecoder) this.channel.pipeline().get("decompress")).setThreshold(threshold, validateDecompressed); + } else { + 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(threshold); ++ ((CompressionEncoder) this.channel.pipeline().get("compress")).setThreshold(threshold); + } else { + this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(threshold)); + } +@@ -539,22 +579,26 @@ + this.channel.pipeline().remove("compress"); + } + } ++ + } + + public void handleDisconnection() { + if (this.channel != null && !this.channel.isOpen()) { + if (this.disconnectionHandled) { +- LOGGER.warn("handleDisconnection() called twice"); ++ Connection.LOGGER.warn("handleDisconnection() called twice"); + } else { + this.disconnectionHandled = true; +- PacketListener packetListener = this.getPacketListener(); +- PacketListener packetListener1 = packetListener != null ? packetListener : this.disconnectListener; +- if (packetListener1 != null) { +- Component component = Objects.requireNonNullElseGet( +- this.getDisconnectedReason(), () -> Component.translatable("multiplayer.disconnect.generic") +- ); +- packetListener1.onDisconnect(component); ++ PacketListener packetlistener = this.getPacketListener(); ++ PacketListener packetlistener1 = packetlistener != null ? packetlistener : this.disconnectListener; ++ ++ if (packetlistener1 != null) { ++ Component ichatbasecomponent = (Component) Objects.requireNonNullElseGet(this.getDisconnectedReason(), () -> { ++ return Component.translatable("multiplayer.disconnect.generic"); ++ }); ++ ++ packetlistener1.onDisconnect(ichatbasecomponent); + } ++ + } + } + } +@@ -567,7 +611,7 @@ + return this.averageSentPackets; + } + +- public void setBandwidthLogger(SampleLogger sampleLogger) { +- this.bandwidthDebugMonitor = new BandwidthDebugMonitor(sampleLogger); ++ public void setBandwidthLogger(SampleLogger samplelogger) { ++ this.bandwidthDebugMonitor = new BandwidthDebugMonitor(samplelogger); + } + } diff --git a/patch-remap/mache-vineflower/net/minecraft/network/FriendlyByteBuf.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/FriendlyByteBuf.java.patch new file mode 100644 index 0000000000..dc2a12e244 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/FriendlyByteBuf.java.patch @@ -0,0 +1,2067 @@ +--- a/net/minecraft/network/FriendlyByteBuf.java ++++ b/net/minecraft/network/FriendlyByteBuf.java +@@ -37,6 +37,7 @@ + import java.util.Collection; + import java.util.Date; + import java.util.EnumSet; ++import java.util.Iterator; + import java.util.List; + import java.util.Map; + import java.util.Optional; +@@ -80,7 +81,10 @@ + 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; + private final ByteBuf source; + public static final short MAX_STRING_LENGTH = 32767; +@@ -94,74 +98,97 @@ + this.source = source; + } + ++ /** @deprecated */ + @Deprecated +- public <T> T readWithCodecTrusted(DynamicOps<Tag> dynamicOps, Codec<T> codec) { +- return this.readWithCodec(dynamicOps, codec, NbtAccounter.unlimitedHeap()); ++ public <T> T readWithCodecTrusted(DynamicOps<Tag> dynamicops, Codec<T> codec) { ++ return this.readWithCodec(dynamicops, codec, NbtAccounter.unlimitedHeap()); + } + ++ /** @deprecated */ + @Deprecated +- public <T> T readWithCodec(DynamicOps<Tag> dynamicOps, Codec<T> codec, NbtAccounter nbtAccounter) { +- Tag nbt = this.readNbt(nbtAccounter); +- return Util.getOrThrow(codec.parse(dynamicOps, nbt), string -> new DecoderException("Failed to decode: " + string + " " + nbt)); ++ public <T> T readWithCodec(DynamicOps<Tag> dynamicops, Codec<T> codec, NbtAccounter nbtreadlimiter) { ++ Tag nbtbase = this.readNbt(nbtreadlimiter); ++ ++ 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 object) { +- Tag tag = Util.getOrThrow(codec.encodeStart(dynamicOps, object), string -> new EncoderException("Failed to encode: " + string + " " + object)); +- this.writeNbt(tag); ++ public <T> FriendlyByteBuf writeWithCodec(DynamicOps<Tag> dynamicops, Codec<T> codec, T t0) { ++ Tag nbtbase = (Tag) Util.getOrThrow(codec.encodeStart(dynamicops, t0), (s) -> { ++ return new EncoderException("Failed to encode: " + s + " " + t0); ++ }); ++ ++ this.writeNbt(nbtbase); + return this; + } + + public <T> T readJsonWithCodec(Codec<T> codec) { +- JsonElement jsonElement = GsonHelper.fromJson(GSON, this.readUtf(), JsonElement.class); +- DataResult<T> dataResult = codec.parse(JsonOps.INSTANCE, jsonElement); +- return Util.getOrThrow(dataResult, string -> new DecoderException("Failed to decode json: " + string)); ++ JsonElement jsonelement = (JsonElement) GsonHelper.fromJson(FriendlyByteBuf.GSON, this.readUtf(), JsonElement.class); ++ DataResult<T> dataresult = codec.parse(JsonOps.INSTANCE, jsonelement); ++ ++ return Util.getOrThrow(dataresult, (s) -> { ++ return new DecoderException("Failed to decode json: " + s); ++ }); + } + + public <T> void writeJsonWithCodec(Codec<T> codec, T value) { +- DataResult<JsonElement> dataResult = codec.encodeStart(JsonOps.INSTANCE, value); +- this.writeUtf(GSON.toJson(Util.getOrThrow(dataResult, string -> new EncoderException("Failed to encode: " + string + " " + 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 + " " + value); ++ }))); + } + + public <T> void writeId(IdMap<T> idMap, T value) { +- int id = idMap.getId(value); +- if (id == -1) { ++ int i = idMap.getId(value); ++ ++ if (i == -1) { + throw new IllegalArgumentException("Can't find id for '" + value + "' in map " + idMap); + } else { +- this.writeVarInt(id); ++ this.writeVarInt(i); + } + } + +- public <T> void writeId(IdMap<Holder<T>> idMap, Holder<T> value, FriendlyByteBuf.Writer<T> writer) { ++ public <T> void writeId(IdMap<Holder<T>> idMap, Holder<T> value, FriendlyByteBuf.b<T> writer) { + switch (value.kind()) { + case REFERENCE: +- int id = idMap.getId(value); +- if (id == -1) { +- throw new IllegalArgumentException("Can't find id for '" + value.value() + "' in map " + idMap); ++ int i = idMap.getId(value); ++ ++ if (i == -1) { ++ Object object = value.value(); ++ ++ throw new IllegalArgumentException("Can't find id for '" + object + "' in map " + idMap); + } + +- this.writeVarInt(id + 1); ++ this.writeVarInt(i + 1); + break; + case DIRECT: + this.writeVarInt(0); + writer.accept(this, value.value()); + } ++ + } + + @Nullable + public <T> T readById(IdMap<T> idMap) { +- int varInt = this.readVarInt(); +- return idMap.byId(varInt); ++ int i = this.readVarInt(); ++ ++ return idMap.byId(i); + } + +- public <T> Holder<T> readById(IdMap<Holder<T>> idMap, FriendlyByteBuf.Reader<T> reader) { +- int varInt = this.readVarInt(); +- if (varInt == 0) { ++ public <T> Holder<T> readById(IdMap<Holder<T>> idMap, FriendlyByteBuf.a<T> reader) { ++ int i = this.readVarInt(); ++ ++ if (i == 0) { + return Holder.direct(reader.apply(this)); + } else { +- Holder<T> holder = idMap.byId(varInt - 1); ++ Holder<T> holder = (Holder) idMap.byId(i - 1); ++ + if (holder == null) { +- throw new IllegalArgumentException("Can't find element with id " + varInt); ++ throw new IllegalArgumentException("Can't find element with id " + i); + } else { + return holder; + } +@@ -169,150 +196,158 @@ + } + + public static <T> IntFunction<T> limitValue(IntFunction<T> function, int limit) { +- return i -> { +- if (i > limit) { +- throw new DecoderException("Value " + i + " is larger than limit " + limit); ++ return (j) -> { ++ if (j > limit) { ++ throw new DecoderException("Value " + j + " is larger than limit " + limit); + } else { +- return function.apply(i); ++ return function.apply(j); + } + }; + } + +- public <T, C extends Collection<T>> C readCollection(IntFunction<C> collectionFactory, FriendlyByteBuf.Reader<T> elementReader) { +- int varInt = this.readVarInt(); +- C collection = (C)collectionFactory.apply(varInt); ++ public <T, C extends Collection<T>> C readCollection(IntFunction<C> collectionFactory, FriendlyByteBuf.a<T> elementReader) { ++ int i = this.readVarInt(); ++ C c0 = collectionFactory.apply(i); // CraftBukkit - decompile error + +- for (int i = 0; i < varInt; i++) { +- collection.add(elementReader.apply(this)); ++ for (int j = 0; j < i; ++j) { ++ c0.add(elementReader.apply(this)); + } + +- return collection; ++ return c0; + } + +- public <T> void writeCollection(Collection<T> collection, FriendlyByteBuf.Writer<T> elementWriter) { ++ public <T> void writeCollection(Collection<T> collection, FriendlyByteBuf.b<T> elementWriter) { + this.writeVarInt(collection.size()); ++ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error + +- for (T object : collection) { +- elementWriter.accept(this, object); ++ while (iterator.hasNext()) { ++ T t0 = iterator.next(); ++ ++ elementWriter.accept(this, t0); + } ++ + } + +- public <T> List<T> readList(FriendlyByteBuf.Reader<T> elementReader) { +- return this.readCollection(Lists::newArrayListWithCapacity, elementReader); ++ public <T> List<T> readList(FriendlyByteBuf.a<T> elementReader) { ++ return (List) this.readCollection(Lists::newArrayListWithCapacity, elementReader); + } + + public IntList readIntIdList() { +- int varInt = this.readVarInt(); +- IntList list = new IntArrayList(); ++ int i = this.readVarInt(); ++ IntArrayList intarraylist = new IntArrayList(); + +- for (int i = 0; i < varInt; i++) { +- list.add(this.readVarInt()); ++ for (int j = 0; j < i; ++j) { ++ intarraylist.add(this.readVarInt()); + } + +- return list; ++ return intarraylist; + } + + public void writeIntIdList(IntList itIdList) { + this.writeVarInt(itIdList.size()); +- itIdList.forEach(this::writeVarInt); ++ itIdList.forEach((java.util.function.IntConsumer) this::writeVarInt); // CraftBukkit - decompile error + } + +- public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> mapFactory, FriendlyByteBuf.Reader<K> keyReader, FriendlyByteBuf.Reader<V> valueReader) { +- int varInt = this.readVarInt(); +- M map = (M)mapFactory.apply(varInt); ++ 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 = mapFactory.apply(i); // CraftBukkit - decompile error + +- for (int i = 0; i < varInt; i++) { +- K object = keyReader.apply(this); +- V object1 = valueReader.apply(this); +- map.put(object, object1); ++ for (int j = 0; j < i; ++j) { ++ K k0 = keyReader.apply(this); ++ V v0 = valueReader.apply(this); ++ ++ m0.put(k0, v0); + } + +- return map; ++ return m0; + } + +- public <K, V> Map<K, V> readMap(FriendlyByteBuf.Reader<K> keyReader, FriendlyByteBuf.Reader<V> valueReader) { ++ 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> keyWriter, FriendlyByteBuf.Writer<V> valueWriter) { ++ 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) -> { +- keyWriter.accept(this, (K)object); +- valueWriter.accept(this, (V)object1); ++ keyWriter.accept(this, object); ++ valueWriter.accept(this, object1); + }); + } + + public void readWithCount(Consumer<FriendlyByteBuf> reader) { +- int varInt = this.readVarInt(); ++ int i = this.readVarInt(); + +- for (int i = 0; i < varInt; i++) { ++ for (int j = 0; j < i; ++j) { + reader.accept(this); + } ++ + } + + public <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumSet, Class<E> enumClass) { +- E[] enums = (E[])enumClass.getEnumConstants(); +- BitSet bitSet = new BitSet(enums.length); ++ E[] ae = enumClass.getEnumConstants(); // CraftBukkit - decompile error ++ BitSet bitset = new BitSet(ae.length); + +- for (int i = 0; i < enums.length; i++) { +- bitSet.set(i, enumSet.contains(enums[i])); ++ for (int i = 0; i < ae.length; ++i) { ++ bitset.set(i, enumSet.contains(ae[i])); + } + +- this.writeFixedBitSet(bitSet, enums.length); ++ this.writeFixedBitSet(bitset, ae.length); + } + + public <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> enumClass) { +- E[] enums = (E[])enumClass.getEnumConstants(); +- BitSet fixedBitSet = this.readFixedBitSet(enums.length); +- EnumSet<E> set = EnumSet.noneOf(enumClass); ++ E[] ae = enumClass.getEnumConstants(); // CraftBukkit - decompile error ++ BitSet bitset = this.readFixedBitSet(ae.length); ++ EnumSet<E> enumset = EnumSet.noneOf(enumClass); + +- for (int i = 0; i < enums.length; i++) { +- if (fixedBitSet.get(i)) { +- set.add(enums[i]); ++ for (int i = 0; i < ae.length; ++i) { ++ if (bitset.get(i)) { ++ enumset.add(ae[i]); + } + } + +- return set; ++ return enumset; + } + +- public <T> void writeOptional(Optional<T> optional, FriendlyByteBuf.Writer<T> writer) { ++ public <T> void writeOptional(Optional<T> optional, FriendlyByteBuf.b<T> writer) { + if (optional.isPresent()) { + this.writeBoolean(true); + writer.accept(this, optional.get()); + } else { + this.writeBoolean(false); + } ++ + } + +- public <T> Optional<T> readOptional(FriendlyByteBuf.Reader<T> reader) { ++ 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> reader) { ++ public <T> T readNullable(FriendlyByteBuf.a<T> reader) { + return this.readBoolean() ? reader.apply(this) : null; + } + +- public <T> void writeNullable(@Nullable T value, FriendlyByteBuf.Writer<T> writer) { ++ public <T> void writeNullable(@Nullable T value, FriendlyByteBuf.b<T> writer) { + if (value != null) { + this.writeBoolean(true); + writer.accept(this, value); + } else { + this.writeBoolean(false); + } ++ + } + +- public <L, R> void writeEither(Either<L, R> value, FriendlyByteBuf.Writer<L> leftWriter, FriendlyByteBuf.Writer<R> rightWriter) { +- value.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); +- leftWriter.accept(this, (L)object); +- }).ifRight(object -> { ++ leftWriter.accept(this, object); ++ }).ifRight((object) -> { + this.writeBoolean(false); +- rightWriter.accept(this, (R)object); ++ rightWriter.accept(this, object); + }); + } + +- public <L, R> Either<L, R> readEither(FriendlyByteBuf.Reader<L> leftReader, FriendlyByteBuf.Reader<R> rightReader) { ++ 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)); + } + +@@ -327,21 +362,27 @@ + } + + public byte[] readByteArray(int maxLength) { +- int varInt = this.readVarInt(); +- if (varInt > maxLength) { +- throw new DecoderException("ByteArray with size " + varInt + " is bigger than allowed " + maxLength); ++ int j = this.readVarInt(); ++ ++ if (j > maxLength) { ++ throw new DecoderException("ByteArray with size " + j + " is bigger than allowed " + maxLength); + } else { +- byte[] bytes = new byte[varInt]; +- this.readBytes(bytes); +- return bytes; ++ byte[] abyte = new byte[j]; ++ ++ this.readBytes(abyte); ++ return abyte; + } + } + + public FriendlyByteBuf writeVarIntArray(int[] array) { + this.writeVarInt(array.length); ++ int[] aint1 = array; ++ int i = array.length; + +- for (int i : array) { +- this.writeVarInt(i); ++ for (int j = 0; j < i; ++j) { ++ int k = aint1[j]; ++ ++ this.writeVarInt(k); + } + + return this; +@@ -352,32 +393,37 @@ + } + + public int[] readVarIntArray(int maxLength) { +- int varInt = this.readVarInt(); +- if (varInt > maxLength) { +- throw new DecoderException("VarIntArray with size " + varInt + " is bigger than allowed " + maxLength); ++ int j = this.readVarInt(); ++ ++ if (j > maxLength) { ++ throw new DecoderException("VarIntArray with size " + j + " is bigger than allowed " + maxLength); + } else { +- int[] ints = new int[varInt]; ++ int[] aint = new int[j]; + +- for (int i = 0; i < ints.length; i++) { +- ints[i] = this.readVarInt(); ++ for (int k = 0; k < aint.length; ++k) { ++ aint[k] = this.readVarInt(); + } + +- return ints; ++ return aint; + } + } + + public FriendlyByteBuf writeLongArray(long[] array) { + this.writeVarInt(array.length); ++ long[] along1 = array; ++ int i = array.length; + +- for (long l : array) { +- this.writeLong(l); ++ for (int j = 0; j < i; ++j) { ++ long k = along1[j]; ++ ++ this.writeLong(k); + } + + return this; + } + + public long[] readLongArray() { +- return this.readLongArray(null); ++ return this.readLongArray((long[]) null); + } + + public long[] readLongArray(@Nullable long[] array) { +@@ -385,17 +431,18 @@ + } + + public long[] readLongArray(@Nullable long[] array, int maxLength) { +- int varInt = this.readVarInt(); +- if (array == null || array.length != varInt) { +- if (varInt > maxLength) { +- throw new DecoderException("LongArray with size " + varInt + " is bigger than allowed " + maxLength); ++ int j = this.readVarInt(); ++ ++ if (array == null || array.length != j) { ++ if (j > maxLength) { ++ throw new DecoderException("LongArray with size " + j + " is bigger than allowed " + maxLength); + } + +- array = new long[varInt]; ++ array = new long[j]; + } + +- for (int i = 0; i < array.length; i++) { +- array[i] = this.readLong(); ++ for (int k = 0; k < array.length; ++k) { ++ array[k] = this.readLong(); + } + + return array; +@@ -429,9 +476,10 @@ + } + + public GlobalPos readGlobalPos() { +- ResourceKey<Level> resourceKey = this.readResourceKey(Registries.DIMENSION); +- BlockPos blockPos = this.readBlockPos(); +- return GlobalPos.of(resourceKey, blockPos); ++ ResourceKey<Level> resourcekey = this.readResourceKey(Registries.DIMENSION); ++ BlockPos blockposition = this.readBlockPos(); ++ ++ return GlobalPos.of(resourcekey, blockposition); + } + + public void writeGlobalPos(GlobalPos pos) { +@@ -464,18 +512,18 @@ + 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() { +- return this.readWithCodec(NbtOps.INSTANCE, ComponentSerialization.CODEC, NbtAccounter.create(2097152L)); ++ return (Component) this.readWithCodec(NbtOps.INSTANCE, ComponentSerialization.CODEC, NbtAccounter.create(2097152L)); + } + + public Component readComponentTrusted() { +- return this.readWithCodecTrusted(NbtOps.INSTANCE, ComponentSerialization.CODEC); ++ return (Component) this.readWithCodecTrusted(NbtOps.INSTANCE, ComponentSerialization.CODEC); + } + + public FriendlyByteBuf writeComponent(Component component) { +@@ -483,20 +531,22 @@ + } + + public <T extends Enum<T>> T readEnum(Class<T> enumClass) { +- return enumClass.getEnumConstants()[this.readVarInt()]; ++ return ((T[]) enumClass.getEnumConstants())[this.readVarInt()]; // CraftBukkit - fix decompile error + } + + public FriendlyByteBuf writeEnum(Enum<?> value) { + return this.writeVarInt(value.ordinal()); + } + +- public <T> T readById(IntFunction<T> intFunction) { +- int varInt = this.readVarInt(); +- return intFunction.apply(varInt); ++ public <T> T readById(IntFunction<T> intfunction) { ++ int i = this.readVarInt(); ++ ++ return intfunction.apply(i); + } + +- public <T> FriendlyByteBuf writeById(ToIntFunction<T> toIntFunction, T object) { +- int i = toIntFunction.applyAsInt(object); ++ public <T> FriendlyByteBuf writeById(ToIntFunction<T> tointfunction, T t0) { ++ int i = tointfunction.applyAsInt(t0); ++ + return this.writeVarInt(i); + } + +@@ -528,53 +578,57 @@ + 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, new ByteBufOutputStream(this)); ++ NbtIo.writeAnyTag((Tag) nbtbase, new ByteBufOutputStream(this)); + return this; +- } catch (IOException var3) { +- throw new EncoderException(var3); ++ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception ++ throw new EncoderException(ioexception); + } + } + + @Nullable + public CompoundTag readNbt() { +- Tag nbt = this.readNbt(NbtAccounter.create(2097152L)); +- if (nbt != null && !(nbt instanceof CompoundTag)) { +- throw new DecoderException("Not a compound tag: " + nbt); ++ Tag nbtbase = this.readNbt(NbtAccounter.create(2097152L)); ++ ++ if (nbtbase != null && !(nbtbase instanceof CompoundTag)) { ++ throw new DecoderException("Not a compound tag: " + nbtbase); + } else { +- return (CompoundTag)nbt; ++ return (CompoundTag) nbtbase; + } + } + + @Nullable +- public Tag readNbt(NbtAccounter nbtAccounter) { ++ public Tag readNbt(NbtAccounter nbtreadlimiter) { + try { +- Tag anyTag = NbtIo.readAnyTag(new ByteBufInputStream(this), nbtAccounter); +- return anyTag.getId() == 0 ? null : anyTag; +- } catch (IOException var3) { +- throw new EncoderException(var3); ++ Tag nbtbase = NbtIo.readAnyTag(new ByteBufInputStream(this), nbtreadlimiter); ++ ++ return nbtbase.getId() == 0 ? null : nbtbase; ++ } catch (IOException ioexception) { ++ throw new EncoderException(ioexception); + } + } + + public FriendlyByteBuf writeItem(ItemStack stack) { +- if (stack.isEmpty()) { ++ if (stack.isEmpty() || stack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() + this.writeBoolean(false); + } else { + this.writeBoolean(true); + Item item = stack.getItem(); ++ + this.writeId(BuiltInRegistries.ITEM, item); + this.writeByte(stack.getCount()); +- CompoundTag compoundTag = null; ++ CompoundTag nbttagcompound = null; ++ + if (item.canBeDepleted() || item.shouldOverrideMultiplayerNbt()) { +- compoundTag = stack.getTag(); ++ nbttagcompound = stack.getTag(); + } + +- this.writeNbt(compoundTag); ++ this.writeNbt(nbttagcompound); + } + + return this; +@@ -584,11 +638,17 @@ + if (!this.readBoolean()) { + return ItemStack.EMPTY; + } else { +- Item item = this.readById(BuiltInRegistries.ITEM); +- int _byte = this.readByte(); +- ItemStack itemStack = new ItemStack(item, _byte); +- itemStack.setTag(this.readNbt()); +- return itemStack; ++ Item item = (Item) this.readById((IdMap) BuiltInRegistries.ITEM); ++ byte b0 = this.readByte(); ++ 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; + } + } + +@@ -619,8 +679,9 @@ + } + + public <T> ResourceKey<T> readResourceKey(ResourceKey<? extends Registry<T>> registryKey) { +- ResourceLocation resourceLocation = this.readResourceLocation(); +- return ResourceKey.create(registryKey, resourceLocation); ++ ResourceLocation minecraftkey = this.readResourceLocation(); ++ ++ return ResourceKey.create(registryKey, minecraftkey); + } + + public void writeResourceKey(ResourceKey<?> resourceKey) { +@@ -628,8 +689,9 @@ + } + + public <T> ResourceKey<? extends Registry<T>> readRegistryKey() { +- ResourceLocation resourceLocation = this.readResourceLocation(); +- return ResourceKey.createRegistryKey(resourceLocation); ++ ResourceLocation minecraftkey = this.readResourceLocation(); ++ ++ return ResourceKey.createRegistryKey(minecraftkey); + } + + public Date readDate() { +@@ -652,8 +714,8 @@ + public PublicKey readPublicKey() { + try { + return Crypt.byteToPublicKey(this.readByteArray(512)); +- } catch (CryptException var2) { +- throw new DecoderException("Malformed public key bytes", var2); ++ } catch (CryptException cryptographyexception) { ++ throw new DecoderException("Malformed public key bytes", cryptographyexception); + } + } + +@@ -663,28 +725,26 @@ + } + + public BlockHitResult readBlockHitResult() { +- BlockPos blockPos = this.readBlockPos(); +- Direction direction = this.readEnum(Direction.class); +- float _float = this.readFloat(); +- float _float1 = this.readFloat(); +- float _float2 = this.readFloat(); +- boolean _boolean = this.readBoolean(); +- return new BlockHitResult( +- new Vec3((double)blockPos.getX() + (double)_float, (double)blockPos.getY() + (double)_float1, (double)blockPos.getZ() + (double)_float2), +- direction, +- blockPos, +- _boolean +- ); ++ 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) blockposition.getX() + (double) f, (double) blockposition.getY() + (double) f1, (double) blockposition.getZ() + (double) f2), enumdirection, blockposition, flag); + } + + public void writeBlockHitResult(BlockHitResult result) { +- BlockPos blockPos = result.getBlockPos(); +- this.writeBlockPos(blockPos); ++ BlockPos blockposition = result.getBlockPos(); ++ ++ this.writeBlockPos(blockposition); + this.writeEnum(result.getDirection()); +- Vec3 location = result.getLocation(); +- this.writeFloat((float)(location.x - (double)blockPos.getX())); +- this.writeFloat((float)(location.y - (double)blockPos.getY())); +- this.writeFloat((float)(location.z - (double)blockPos.getZ())); ++ Vec3 vec3d = result.getLocation(); ++ ++ 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()); + } + +@@ -697,26 +757,31 @@ + } + + public BitSet readFixedBitSet(int size) { +- byte[] bytes = new byte[Mth.positiveCeilDiv(size, 8)]; +- this.readBytes(bytes); +- return BitSet.valueOf(bytes); ++ byte[] abyte = new byte[Mth.positiveCeilDiv(size, 8)]; ++ ++ this.readBytes(abyte); ++ return BitSet.valueOf(abyte); + } + + public void writeFixedBitSet(BitSet bitSet, int size) { + if (bitSet.length() > size) { +- throw new EncoderException("BitSet is larger than expected size (" + bitSet.length() + ">" + size + ")"); ++ int j = bitSet.length(); ++ ++ throw new EncoderException("BitSet is larger than expected size (" + j + ">" + size + ")"); + } else { +- byte[] bytes = bitSet.toByteArray(); +- this.writeBytes(Arrays.copyOf(bytes, Mth.positiveCeilDiv(size, 8))); ++ byte[] abyte = bitSet.toByteArray(); ++ ++ this.writeBytes(Arrays.copyOf(abyte, Mth.positiveCeilDiv(size, 8))); + } + } + + public GameProfile readGameProfile() { +- UUID uUID = this.readUUID(); +- String utf = this.readUtf(16); +- GameProfile gameProfile = new GameProfile(uUID, utf); +- gameProfile.getProperties().putAll(this.readGameProfileProperties()); +- return gameProfile; ++ UUID uuid = this.readUUID(); ++ String s = this.readUtf(16); ++ GameProfile gameprofile = new GameProfile(uuid, s); ++ ++ gameprofile.getProperties().putAll(this.readGameProfileProperties()); ++ return gameprofile; + } + + public void writeGameProfile(GameProfile gameProfile) { +@@ -726,12 +791,14 @@ + } + + public PropertyMap readGameProfileProperties() { +- PropertyMap propertyMap = new PropertyMap(); +- this.readWithCount(friendlyByteBuf -> { ++ PropertyMap propertymap = new PropertyMap(); ++ ++ this.readWithCount((packetdataserializer) -> { + Property property = this.readProperty(); +- propertyMap.put(property.name(), property); ++ ++ propertymap.put(property.name(), property); + }); +- return propertyMap; ++ return propertymap; + } + + public void writeGameProfileProperties(PropertyMap gameProfileProperties) { +@@ -739,10 +806,11 @@ + } + + public Property readProperty() { +- String utf = this.readUtf(); +- String utf1 = this.readUtf(); +- String string = this.readNullable(FriendlyByteBuf::readUtf); +- return new Property(utf, utf1, string); ++ String s = this.readUtf(); ++ String s1 = this.readUtf(); ++ String s2 = (String) this.readNullable(FriendlyByteBuf::readUtf); ++ ++ return new Property(s, s1, s2); + } + + public void writeProperty(Property property) { +@@ -751,1013 +819,834 @@ + 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 newCapacity) { +- this.source.capacity(newCapacity); ++ 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 endianness) { +- return this.source.order(endianness); ++ 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 readerIndex) { +- this.source.readerIndex(readerIndex); ++ public FriendlyByteBuf readerIndex(int i) { ++ this.source.readerIndex(i); + return this; + } + +- @Override + public int writerIndex() { + return this.source.writerIndex(); + } + +- @Override +- public FriendlyByteBuf writerIndex(int writerIndex) { +- this.source.writerIndex(writerIndex); ++ public FriendlyByteBuf writerIndex(int i) { ++ this.source.writerIndex(i); + return this; + } + +- @Override +- public FriendlyByteBuf setIndex(int readerIndex, int writerIndex) { +- this.source.setIndex(readerIndex, writerIndex); ++ 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 size) { +- return this.source.isReadable(size); ++ public boolean isReadable(int i) { ++ return this.source.isReadable(i); + } + +- @Override + public boolean isWritable() { + return this.source.isWritable(); + } + +- @Override +- public boolean isWritable(int size) { +- return this.source.isWritable(size); ++ 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 size) { +- this.source.ensureWritable(size); ++ public FriendlyByteBuf ensureWritable(int i) { ++ this.source.ensureWritable(i); + return this; + } + +- @Override +- public int ensureWritable(int size, boolean force) { +- return this.source.ensureWritable(size, force); ++ public int ensureWritable(int i, boolean flag) { ++ return this.source.ensureWritable(i, flag); + } + +- @Override +- public boolean getBoolean(int index) { +- return this.source.getBoolean(index); ++ public boolean getBoolean(int i) { ++ return this.source.getBoolean(i); + } + +- @Override +- public byte getByte(int index) { +- return this.source.getByte(index); ++ public byte getByte(int i) { ++ return this.source.getByte(i); + } + +- @Override +- public short getUnsignedByte(int index) { +- return this.source.getUnsignedByte(index); ++ public short getUnsignedByte(int i) { ++ return this.source.getUnsignedByte(i); + } + +- @Override +- public short getShort(int index) { +- return this.source.getShort(index); ++ public short getShort(int i) { ++ return this.source.getShort(i); + } + +- @Override +- public short getShortLE(int index) { +- return this.source.getShortLE(index); ++ public short getShortLE(int i) { ++ return this.source.getShortLE(i); + } + +- @Override +- public int getUnsignedShort(int index) { +- return this.source.getUnsignedShort(index); ++ public int getUnsignedShort(int i) { ++ return this.source.getUnsignedShort(i); + } + +- @Override +- public int getUnsignedShortLE(int index) { +- return this.source.getUnsignedShortLE(index); ++ public int getUnsignedShortLE(int i) { ++ return this.source.getUnsignedShortLE(i); + } + +- @Override +- public int getMedium(int index) { +- return this.source.getMedium(index); ++ public int getMedium(int i) { ++ return this.source.getMedium(i); + } + +- @Override +- public int getMediumLE(int index) { +- return this.source.getMediumLE(index); ++ public int getMediumLE(int i) { ++ return this.source.getMediumLE(i); + } + +- @Override +- public int getUnsignedMedium(int index) { +- return this.source.getUnsignedMedium(index); ++ public int getUnsignedMedium(int i) { ++ return this.source.getUnsignedMedium(i); + } + +- @Override +- public int getUnsignedMediumLE(int index) { +- return this.source.getUnsignedMediumLE(index); ++ public int getUnsignedMediumLE(int i) { ++ return this.source.getUnsignedMediumLE(i); + } + +- @Override +- public int getInt(int index) { +- return this.source.getInt(index); ++ public int getInt(int i) { ++ return this.source.getInt(i); + } + +- @Override +- public int getIntLE(int index) { +- return this.source.getIntLE(index); ++ public int getIntLE(int i) { ++ return this.source.getIntLE(i); + } + +- @Override +- public long getUnsignedInt(int index) { +- return this.source.getUnsignedInt(index); ++ public long getUnsignedInt(int i) { ++ return this.source.getUnsignedInt(i); + } + +- @Override +- public long getUnsignedIntLE(int index) { +- return this.source.getUnsignedIntLE(index); ++ public long getUnsignedIntLE(int i) { ++ return this.source.getUnsignedIntLE(i); + } + +- @Override +- public long getLong(int index) { +- return this.source.getLong(index); ++ public long getLong(int i) { ++ return this.source.getLong(i); + } + +- @Override +- public long getLongLE(int index) { +- return this.source.getLongLE(index); ++ public long getLongLE(int i) { ++ return this.source.getLongLE(i); + } + +- @Override +- public char getChar(int index) { +- return this.source.getChar(index); ++ public char getChar(int i) { ++ return this.source.getChar(i); + } + +- @Override +- public float getFloat(int index) { +- return this.source.getFloat(index); ++ public float getFloat(int i) { ++ return this.source.getFloat(i); + } + +- @Override +- public double getDouble(int index) { +- return this.source.getDouble(index); ++ public double getDouble(int i) { ++ return this.source.getDouble(i); + } + +- @Override +- public FriendlyByteBuf getBytes(int index, ByteBuf destination) { +- this.source.getBytes(index, destination); ++ public FriendlyByteBuf getBytes(int i, ByteBuf bytebuf) { ++ this.source.getBytes(i, bytebuf); + return this; + } + +- @Override +- public FriendlyByteBuf getBytes(int index, ByteBuf destination, int length) { +- this.source.getBytes(index, destination, length); ++ public FriendlyByteBuf getBytes(int i, ByteBuf bytebuf, int j) { ++ this.source.getBytes(i, bytebuf, j); + return this; + } + +- @Override +- public FriendlyByteBuf getBytes(int index, ByteBuf destination, int destinationIndex, int length) { +- this.source.getBytes(index, destination, destinationIndex, length); ++ 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 index, byte[] destination) { +- this.source.getBytes(index, destination); ++ public FriendlyByteBuf getBytes(int i, byte[] abyte) { ++ this.source.getBytes(i, abyte); + return this; + } + +- @Override +- public FriendlyByteBuf getBytes(int index, byte[] destination, int destinationIndex, int length) { +- this.source.getBytes(index, destination, destinationIndex, length); ++ 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 index, ByteBuffer destination) { +- this.source.getBytes(index, destination); ++ public FriendlyByteBuf getBytes(int i, ByteBuffer bytebuffer) { ++ this.source.getBytes(i, bytebuffer); + return this; + } + +- @Override +- public FriendlyByteBuf getBytes(int index, OutputStream out, int length) throws IOException { +- this.source.getBytes(index, out, length); ++ public FriendlyByteBuf getBytes(int i, OutputStream outputstream, int j) throws IOException { ++ this.source.getBytes(i, outputstream, j); + return this; + } + +- @Override +- public int getBytes(int index, GatheringByteChannel out, int length) throws IOException { +- return this.source.getBytes(index, out, length); ++ public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) throws IOException { ++ return this.source.getBytes(i, gatheringbytechannel, j); + } + +- @Override +- public int getBytes(int index, FileChannel out, long position, int length) throws IOException { +- return this.source.getBytes(index, out, position, length); ++ 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 index, int length, Charset charset) { +- return this.source.getCharSequence(index, length, charset); ++ public CharSequence getCharSequence(int i, int j, Charset charset) { ++ return this.source.getCharSequence(i, j, charset); + } + +- @Override +- public FriendlyByteBuf setBoolean(int index, boolean value) { +- this.source.setBoolean(index, value); ++ public FriendlyByteBuf setBoolean(int i, boolean flag) { ++ this.source.setBoolean(i, flag); + return this; + } + +- @Override +- public FriendlyByteBuf setByte(int index, int value) { +- this.source.setByte(index, value); ++ public FriendlyByteBuf setByte(int i, int j) { ++ this.source.setByte(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setShort(int index, int value) { +- this.source.setShort(index, value); ++ public FriendlyByteBuf setShort(int i, int j) { ++ this.source.setShort(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setShortLE(int index, int value) { +- this.source.setShortLE(index, value); ++ public FriendlyByteBuf setShortLE(int i, int j) { ++ this.source.setShortLE(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setMedium(int index, int value) { +- this.source.setMedium(index, value); ++ public FriendlyByteBuf setMedium(int i, int j) { ++ this.source.setMedium(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setMediumLE(int index, int value) { +- this.source.setMediumLE(index, value); ++ public FriendlyByteBuf setMediumLE(int i, int j) { ++ this.source.setMediumLE(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setInt(int index, int value) { +- this.source.setInt(index, value); ++ public FriendlyByteBuf setInt(int i, int j) { ++ this.source.setInt(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setIntLE(int index, int value) { +- this.source.setIntLE(index, value); ++ public FriendlyByteBuf setIntLE(int i, int j) { ++ this.source.setIntLE(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setLong(int index, long value) { +- this.source.setLong(index, value); ++ public FriendlyByteBuf setLong(int i, long j) { ++ this.source.setLong(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setLongLE(int index, long value) { +- this.source.setLongLE(index, value); ++ public FriendlyByteBuf setLongLE(int i, long j) { ++ this.source.setLongLE(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setChar(int index, int value) { +- this.source.setChar(index, value); ++ public FriendlyByteBuf setChar(int i, int j) { ++ this.source.setChar(i, j); + return this; + } + +- @Override +- public FriendlyByteBuf setFloat(int index, float value) { +- this.source.setFloat(index, value); ++ public FriendlyByteBuf setFloat(int i, float f) { ++ this.source.setFloat(i, f); + return this; + } + +- @Override +- public FriendlyByteBuf setDouble(int index, double value) { +- this.source.setDouble(index, value); ++ public FriendlyByteBuf setDouble(int i, double d0) { ++ this.source.setDouble(i, d0); + return this; + } + +- @Override +- public FriendlyByteBuf setBytes(int index, ByteBuf source) { +- this.source.setBytes(index, source); ++ public FriendlyByteBuf setBytes(int i, ByteBuf bytebuf) { ++ this.source.setBytes(i, bytebuf); + return this; + } + +- @Override +- public FriendlyByteBuf setBytes(int index, ByteBuf source, int length) { +- this.source.setBytes(index, source, length); ++ public FriendlyByteBuf setBytes(int i, ByteBuf bytebuf, int j) { ++ this.source.setBytes(i, bytebuf, j); + return this; + } + +- @Override +- public FriendlyByteBuf setBytes(int index, ByteBuf source, int sourceIndex, int length) { +- this.source.setBytes(index, source, sourceIndex, length); ++ 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 index, byte[] source) { +- this.source.setBytes(index, source); ++ public FriendlyByteBuf setBytes(int i, byte[] abyte) { ++ this.source.setBytes(i, abyte); + return this; + } + +- @Override +- public FriendlyByteBuf setBytes(int index, byte[] source, int sourceIndex, int length) { +- this.source.setBytes(index, source, sourceIndex, length); ++ 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 index, ByteBuffer source) { +- this.source.setBytes(index, source); ++ public FriendlyByteBuf setBytes(int i, ByteBuffer bytebuffer) { ++ this.source.setBytes(i, bytebuffer); + return this; + } + +- @Override +- public int setBytes(int index, InputStream in, int length) throws IOException { +- return this.source.setBytes(index, in, length); ++ public int setBytes(int i, InputStream inputstream, int j) throws IOException { ++ return this.source.setBytes(i, inputstream, j); + } + +- @Override +- public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException { +- return this.source.setBytes(index, in, length); ++ public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) throws IOException { ++ return this.source.setBytes(i, scatteringbytechannel, j); + } + +- @Override +- public int setBytes(int index, FileChannel in, long position, int length) throws IOException { +- return this.source.setBytes(index, in, position, length); ++ 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 index, int length) { +- this.source.setZero(index, length); ++ public FriendlyByteBuf setZero(int i, int j) { ++ this.source.setZero(i, j); + return this; + } + +- @Override +- public int setCharSequence(int index, CharSequence charSequence, Charset charset) { +- return this.source.setCharSequence(index, charSequence, charset); ++ 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 length) { +- return this.source.readBytes(length); ++ public ByteBuf readBytes(int i) { ++ return this.source.readBytes(i); + } + +- @Override +- public ByteBuf readSlice(int length) { +- return this.source.readSlice(length); ++ public ByteBuf readSlice(int i) { ++ return this.source.readSlice(i); + } + +- @Override +- public ByteBuf readRetainedSlice(int length) { +- return this.source.readRetainedSlice(length); ++ public ByteBuf readRetainedSlice(int i) { ++ return this.source.readRetainedSlice(i); + } + +- @Override +- public FriendlyByteBuf readBytes(ByteBuf destination) { +- this.source.readBytes(destination); ++ public FriendlyByteBuf readBytes(ByteBuf bytebuf) { ++ this.source.readBytes(bytebuf); + return this; + } + +- @Override +- public FriendlyByteBuf readBytes(ByteBuf destination, int length) { +- this.source.readBytes(destination, length); ++ public FriendlyByteBuf readBytes(ByteBuf bytebuf, int i) { ++ this.source.readBytes(bytebuf, i); + return this; + } + +- @Override +- public FriendlyByteBuf readBytes(ByteBuf destination, int destinationIndex, int length) { +- this.source.readBytes(destination, destinationIndex, length); ++ public FriendlyByteBuf readBytes(ByteBuf bytebuf, int i, int j) { ++ this.source.readBytes(bytebuf, i, j); + return this; + } + +- @Override +- public FriendlyByteBuf readBytes(byte[] destination) { +- this.source.readBytes(destination); ++ public FriendlyByteBuf readBytes(byte[] abyte) { ++ this.source.readBytes(abyte); + return this; + } + +- @Override +- public FriendlyByteBuf readBytes(byte[] destination, int destinationIndex, int length) { +- this.source.readBytes(destination, destinationIndex, length); ++ public FriendlyByteBuf readBytes(byte[] abyte, int i, int j) { ++ this.source.readBytes(abyte, i, j); + return this; + } + +- @Override +- public FriendlyByteBuf readBytes(ByteBuffer destination) { +- this.source.readBytes(destination); ++ public FriendlyByteBuf readBytes(ByteBuffer bytebuffer) { ++ this.source.readBytes(bytebuffer); + return this; + } + +- @Override +- public FriendlyByteBuf readBytes(OutputStream out, int length) throws IOException { +- this.source.readBytes(out, length); ++ public FriendlyByteBuf readBytes(OutputStream outputstream, int i) throws IOException { ++ this.source.readBytes(outputstream, i); + return this; + } + +- @Override +- public int readBytes(GatheringByteChannel out, int length) throws IOException { +- return this.source.readBytes(out, length); ++ public int readBytes(GatheringByteChannel gatheringbytechannel, int i) throws IOException { ++ return this.source.readBytes(gatheringbytechannel, i); + } + +- @Override +- public CharSequence readCharSequence(int length, Charset charset) { +- return this.source.readCharSequence(length, charset); ++ public CharSequence readCharSequence(int i, Charset charset) { ++ return this.source.readCharSequence(i, charset); + } + +- @Override +- public int readBytes(FileChannel out, long position, int length) throws IOException { +- return this.source.readBytes(out, position, length); ++ public int readBytes(FileChannel filechannel, long i, int j) throws IOException { ++ return this.source.readBytes(filechannel, i, j); + } + +- @Override +- public FriendlyByteBuf skipBytes(int length) { +- this.source.skipBytes(length); ++ public FriendlyByteBuf skipBytes(int i) { ++ this.source.skipBytes(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeBoolean(boolean value) { +- this.source.writeBoolean(value); ++ public FriendlyByteBuf writeBoolean(boolean flag) { ++ this.source.writeBoolean(flag); + return this; + } + +- @Override +- public FriendlyByteBuf writeByte(int value) { +- this.source.writeByte(value); ++ public FriendlyByteBuf writeByte(int i) { ++ this.source.writeByte(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeShort(int value) { +- this.source.writeShort(value); ++ public FriendlyByteBuf writeShort(int i) { ++ this.source.writeShort(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeShortLE(int value) { +- this.source.writeShortLE(value); ++ public FriendlyByteBuf writeShortLE(int i) { ++ this.source.writeShortLE(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeMedium(int value) { +- this.source.writeMedium(value); ++ public FriendlyByteBuf writeMedium(int i) { ++ this.source.writeMedium(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeMediumLE(int value) { +- this.source.writeMediumLE(value); ++ public FriendlyByteBuf writeMediumLE(int i) { ++ this.source.writeMediumLE(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeInt(int value) { +- this.source.writeInt(value); ++ public FriendlyByteBuf writeInt(int i) { ++ this.source.writeInt(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeIntLE(int value) { +- this.source.writeIntLE(value); ++ public FriendlyByteBuf writeIntLE(int i) { ++ this.source.writeIntLE(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeLong(long value) { +- this.source.writeLong(value); ++ public FriendlyByteBuf writeLong(long i) { ++ this.source.writeLong(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeLongLE(long value) { +- this.source.writeLongLE(value); ++ public FriendlyByteBuf writeLongLE(long i) { ++ this.source.writeLongLE(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeChar(int value) { +- this.source.writeChar(value); ++ public FriendlyByteBuf writeChar(int i) { ++ this.source.writeChar(i); + return this; + } + +- @Override +- public FriendlyByteBuf writeFloat(float value) { +- this.source.writeFloat(value); ++ public FriendlyByteBuf writeFloat(float f) { ++ this.source.writeFloat(f); + return this; + } + +- @Override +- public FriendlyByteBuf writeDouble(double value) { +- this.source.writeDouble(value); ++ public FriendlyByteBuf writeDouble(double d0) { ++ this.source.writeDouble(d0); + return this; + } + +- @Override +- public FriendlyByteBuf writeBytes(ByteBuf source) { +- this.source.writeBytes(source); ++ public FriendlyByteBuf writeBytes(ByteBuf bytebuf) { ++ this.source.writeBytes(bytebuf); + return this; + } + +- @Override +- public FriendlyByteBuf writeBytes(ByteBuf source, int length) { +- this.source.writeBytes(source, length); ++ public FriendlyByteBuf writeBytes(ByteBuf bytebuf, int i) { ++ this.source.writeBytes(bytebuf, i); + return this; + } + +- @Override +- public FriendlyByteBuf writeBytes(ByteBuf source, int sourceIndex, int length) { +- this.source.writeBytes(source, sourceIndex, length); ++ public FriendlyByteBuf writeBytes(ByteBuf bytebuf, int i, int j) { ++ this.source.writeBytes(bytebuf, i, j); + return this; + } + +- @Override +- public FriendlyByteBuf writeBytes(byte[] source) { +- this.source.writeBytes(source); ++ public FriendlyByteBuf writeBytes(byte[] abyte) { ++ this.source.writeBytes(abyte); + return this; + } + +- @Override +- public FriendlyByteBuf writeBytes(byte[] source, int sourceIndex, int length) { +- this.source.writeBytes(source, sourceIndex, length); ++ public FriendlyByteBuf writeBytes(byte[] abyte, int i, int j) { ++ this.source.writeBytes(abyte, i, j); + return this; + } + +- @Override +- public FriendlyByteBuf writeBytes(ByteBuffer source) { +- this.source.writeBytes(source); ++ public FriendlyByteBuf writeBytes(ByteBuffer bytebuffer) { ++ this.source.writeBytes(bytebuffer); + return this; + } + +- @Override +- public int writeBytes(InputStream in, int length) throws IOException { +- return this.source.writeBytes(in, length); ++ public int writeBytes(InputStream inputstream, int i) throws IOException { ++ return this.source.writeBytes(inputstream, i); + } + +- @Override +- public int writeBytes(ScatteringByteChannel in, int length) throws IOException { +- return this.source.writeBytes(in, length); ++ public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) throws IOException { ++ return this.source.writeBytes(scatteringbytechannel, i); + } + +- @Override +- public int writeBytes(FileChannel in, long position, int length) throws IOException { +- return this.source.writeBytes(in, position, length); ++ public int writeBytes(FileChannel filechannel, long i, int j) throws IOException { ++ return this.source.writeBytes(filechannel, i, j); + } + +- @Override +- public FriendlyByteBuf writeZero(int length) { +- this.source.writeZero(length); ++ 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); ++ public int writeCharSequence(CharSequence charsequence, Charset charset) { ++ return this.source.writeCharSequence(charsequence, charset); + } + +- @Override +- public int indexOf(int fromIndex, int toIndex, byte value) { +- return this.source.indexOf(fromIndex, toIndex, value); ++ public int indexOf(int i, int j, byte b0) { ++ return this.source.indexOf(i, j, b0); + } + +- @Override +- public int bytesBefore(byte value) { +- return this.source.bytesBefore(value); ++ public int bytesBefore(byte b0) { ++ return this.source.bytesBefore(b0); + } + +- @Override +- public int bytesBefore(int length, byte value) { +- return this.source.bytesBefore(length, value); ++ public int bytesBefore(int i, byte b0) { ++ return this.source.bytesBefore(i, b0); + } + +- @Override +- public int bytesBefore(int index, int length, byte value) { +- return this.source.bytesBefore(index, length, value); ++ public int bytesBefore(int i, int j, byte b0) { ++ return this.source.bytesBefore(i, j, b0); + } + +- @Override +- public int forEachByte(ByteProcessor processor) { +- return this.source.forEachByte(processor); ++ public int forEachByte(ByteProcessor byteprocessor) { ++ return this.source.forEachByte(byteprocessor); + } + +- @Override +- public int forEachByte(int index, int length, ByteProcessor processor) { +- return this.source.forEachByte(index, length, processor); ++ public int forEachByte(int i, int j, ByteProcessor byteprocessor) { ++ return this.source.forEachByte(i, j, byteprocessor); + } + +- @Override +- public int forEachByteDesc(ByteProcessor processor) { +- return this.source.forEachByteDesc(processor); ++ public int forEachByteDesc(ByteProcessor byteprocessor) { ++ return this.source.forEachByteDesc(byteprocessor); + } + +- @Override +- public int forEachByteDesc(int index, int length, ByteProcessor processor) { +- return this.source.forEachByteDesc(index, length, processor); ++ 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 index, int length) { +- return this.source.copy(index, length); ++ 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 index, int length) { +- return this.source.slice(index, length); ++ public ByteBuf slice(int i, int j) { ++ return this.source.slice(i, j); + } + +- @Override +- public ByteBuf retainedSlice(int index, int length) { +- return this.source.retainedSlice(index, length); ++ 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 index, int length) { +- return this.source.nioBuffer(index, length); ++ public ByteBuffer nioBuffer(int i, int j) { ++ return this.source.nioBuffer(i, j); + } + +- @Override +- public ByteBuffer internalNioBuffer(int index, int length) { +- return this.source.internalNioBuffer(index, length); ++ 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 index, int length) { +- return this.source.nioBuffers(index, length); ++ 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 index, int length, Charset charset) { +- return this.source.toString(index, length, charset); ++ 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 other) { +- return this.source.equals(other); ++ public boolean equals(Object object) { ++ return this.source.equals(object); + } + +- @Override +- public int compareTo(ByteBuf other) { +- return this.source.compareTo(other); ++ public int compareTo(ByteBuf bytebuf) { ++ return this.source.compareTo(bytebuf); + } + +- @Override + public String toString() { + return this.source.toString(); + } + +- @Override +- public FriendlyByteBuf retain(int increment) { +- this.source.retain(increment); ++ 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 hint) { +- this.source.touch(hint); ++ 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 decrement) { +- return this.source.release(decrement); ++ public boolean release(int i) { ++ return this.source.release(i); + } + + @FunctionalInterface +- public interface Reader<T> extends Function<FriendlyByteBuf, T> { +- default FriendlyByteBuf.Reader<Optional<T>> asOptional() { +- return friendlyByteBuf -> friendlyByteBuf.readOptional(this); ++ public interface b<T> extends BiConsumer<FriendlyByteBuf, T> { ++ ++ default FriendlyByteBuf.b<Optional<T>> asOptional() { ++ return (packetdataserializer, optional) -> { ++ packetdataserializer.writeOptional(optional, this); ++ }; + } + } + + @FunctionalInterface +- public interface Writer<T> extends BiConsumer<FriendlyByteBuf, T> { +- default FriendlyByteBuf.Writer<Optional<T>> asOptional() { +- return (friendlyByteBuf, optional) -> friendlyByteBuf.writeOptional(optional, this); ++ public interface a<T> extends Function<FriendlyByteBuf, T> { ++ ++ default FriendlyByteBuf.a<Optional<T>> asOptional() { ++ return (packetdataserializer) -> { ++ return packetdataserializer.readOptional(this); ++ }; + } + } + } diff --git a/patch-remap/mache-vineflower/net/minecraft/network/chat/Component.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/chat/Component.java.patch new file mode 100644 index 0000000000..cdb34a0911 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/chat/Component.java.patch @@ -0,0 +1,347 @@ +--- a/net/minecraft/network/chat/Component.java ++++ b/net/minecraft/network/chat/Component.java +@@ -18,6 +18,7 @@ + import java.util.ArrayList; + import java.util.Collections; + import java.util.Date; ++import java.util.Iterator; + import java.util.List; + import java.util.Optional; + import java.util.UUID; +@@ -25,16 +26,31 @@ + 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(); +@@ -45,25 +61,33 @@ + } + + default String getString(int maxLength) { +- StringBuilder stringBuilder = new StringBuilder(); +- this.visit(content -> { +- int i = maxLength - stringBuilder.length(); +- if (i <= 0) { +- return STOP_ITERATION; ++ StringBuilder stringbuilder = new StringBuilder(); ++ ++ this.visit((s) -> { ++ int j = maxLength - stringbuilder.length(); ++ ++ if (j <= 0) { ++ return Component.STOP_ITERATION; + } else { +- stringBuilder.append(content.length() <= i ? content : content.substring(0, i)); ++ stringbuilder.append(s.length() <= j ? s : s.substring(0, j)); + return Optional.empty(); + } + }); +- return stringBuilder.toString(); ++ return stringbuilder.toString(); + } + + List<Component> getSiblings(); + + @Nullable + default String tryCollapseToString() { +- if (this.getContents() instanceof PlainTextContents plainTextContents && this.getSiblings().isEmpty() && this.getStyle().isEmpty()) { +- return plainTextContents.text(); ++ ComponentContents componentcontents = this.getContents(); ++ ++ if (componentcontents instanceof LiteralContents) { ++ LiteralContents literalcontents = (LiteralContents) componentcontents; ++ ++ if (this.getSiblings().isEmpty() && this.getStyle().isEmpty()) { ++ return literalcontents.text(); ++ } + } + + return null; +@@ -74,43 +98,59 @@ + } + + default MutableComponent copy() { +- return new MutableComponent(this.getContents(), new ArrayList<>(this.getSiblings()), this.getStyle()); ++ return new MutableComponent(this.getContents(), new ArrayList(this.getSiblings()), this.getStyle()); + } + + FormattedCharSequence getVisualOrderText(); + + @Override + default <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> acceptor, Style style) { +- Style style1 = this.getStyle().applyTo(style); +- Optional<T> optional = this.getContents().visit(acceptor, style1); ++ Style chatmodifier1 = this.getStyle().applyTo(style); ++ Optional<T> optional = this.getContents().visit(acceptor, chatmodifier1); ++ + if (optional.isPresent()) { + return optional; + } else { +- for (Component component : this.getSiblings()) { +- Optional<T> optional1 = component.visit(acceptor, style1); +- if (optional1.isPresent()) { +- return optional1; ++ Iterator iterator = this.getSiblings().iterator(); ++ ++ Optional optional1; ++ ++ do { ++ if (!iterator.hasNext()) { ++ return Optional.empty(); + } +- } + +- return Optional.empty(); ++ Component ichatbasecomponent = (Component) iterator.next(); ++ ++ optional1 = ichatbasecomponent.visit(acceptor, chatmodifier1); ++ } while (!optional1.isPresent()); ++ ++ return optional1; + } + } + + @Override + default <T> Optional<T> visit(FormattedText.ContentConsumer<T> acceptor) { + Optional<T> optional = this.getContents().visit(acceptor); ++ + if (optional.isPresent()) { + return optional; + } else { +- for (Component component : this.getSiblings()) { +- Optional<T> optional1 = component.visit(acceptor); +- if (optional1.isPresent()) { +- return optional1; ++ Iterator iterator = this.getSiblings().iterator(); ++ ++ Optional optional1; ++ ++ do { ++ if (!iterator.hasNext()) { ++ return Optional.empty(); + } +- } + +- return Optional.empty(); ++ Component ichatbasecomponent = (Component) iterator.next(); ++ ++ optional1 = ichatbasecomponent.visit(acceptor); ++ } while (!optional1.isPresent()); ++ ++ return optional1; + } + } + +@@ -120,9 +160,10 @@ + + default List<Component> toFlatList(Style style) { + List<Component> list = Lists.newArrayList(); +- this.visit((style1, content) -> { +- if (!content.isEmpty()) { +- list.add(literal(content).withStyle(style1)); ++ ++ this.visit((chatmodifier1, s) -> { ++ if (!s.isEmpty()) { ++ list.add(literal(s).withStyle(chatmodifier1)); + } + + return Optional.empty(); +@@ -136,35 +177,37 @@ + } else { + List<Component> list = this.toFlatList(); + List<Component> list1 = other.toFlatList(this.getStyle()); ++ + return Collections.indexOfSubList(list, list1) != -1; + } + } + + static Component nullToEmpty(@Nullable String text) { +- return (Component)(text != null ? literal(text) : CommonComponents.EMPTY); ++ return (Component) (text != null ? literal(text) : CommonComponents.EMPTY); + } + + static MutableComponent literal(String text) { +- return MutableComponent.create(PlainTextContents.create(text)); ++ return MutableComponent.create(LiteralContents.create(text)); + } + + static MutableComponent translatable(String key) { +- return MutableComponent.create(new TranslatableContents(key, null, TranslatableContents.NO_ARGS)); ++ return MutableComponent.create(new TranslatableContents(key, (String) null, TranslatableContents.NO_ARGS)); + } + + static MutableComponent translatable(String key, Object... args) { +- return MutableComponent.create(new TranslatableContents(key, null, args)); ++ return MutableComponent.create(new TranslatableContents(key, (String) null, args)); + } + +- static MutableComponent translatableEscape(String string, Object... objects) { +- for (int i = 0; i < objects.length; i++) { +- Object object = objects[i]; ++ static MutableComponent translatableEscape(String s, Object... aobject) { ++ for (int i = 0; i < aobject.length; ++i) { ++ Object object = aobject[i]; ++ + if (!TranslatableContents.isAllowedPrimitiveArgument(object) && !(object instanceof Component)) { +- objects[i] = String.valueOf(object); ++ aobject[i] = String.valueOf(object); + } + } + +- return translatable(string, objects); ++ return translatable(s, aobject); + } + + static MutableComponent translatableWithFallback(String key, @Nullable String fallback) { +@@ -176,7 +219,7 @@ + } + + static MutableComponent empty() { +- return MutableComponent.create(PlainTextContents.EMPTY); ++ return MutableComponent.create(LiteralContents.EMPTY); + } + + static MutableComponent keybind(String name) { +@@ -200,37 +243,60 @@ + } + + static Component translationArg(Message message) { +- return (Component)(message instanceof Component component ? component : literal(message.getString())); ++ Object object; ++ ++ if (message instanceof Component) { ++ Component ichatbasecomponent = (Component) message; ++ ++ object = ichatbasecomponent; ++ } else { ++ object = literal(message.getString()); ++ } ++ ++ return (Component) object; + } + +- static Component translationArg(UUID uUID) { +- return literal(uUID.toString()); ++ static Component translationArg(UUID uuid) { ++ 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 Serializer { +- private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().create(); ++ public static class b implements JsonDeserializer<MutableComponent>, JsonSerializer<Component> { + +- private Serializer() { ++ public b() {} ++ ++ public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { ++ return Component.Serializer.deserialize(jsonelement); + } + +- static MutableComponent deserialize(JsonElement jsonElement) { +- return (MutableComponent)Util.getOrThrow(ComponentSerialization.CODEC.parse(JsonOps.INSTANCE, jsonElement), JsonParseException::new); ++ public JsonElement serialize(Component ichatbasecomponent, Type type, JsonSerializationContext jsonserializationcontext) { ++ return Component.Serializer.serialize(ichatbasecomponent); + } ++ } + +- static JsonElement serialize(Component component) { +- return Util.getOrThrow(ComponentSerialization.CODEC.encodeStart(JsonOps.INSTANCE, component), JsonParseException::new); ++ public static class Serializer { ++ ++ private static final Gson GSON = (new GsonBuilder()).disableHtmlEscaping().create(); ++ ++ private Serializer() {} ++ ++ static MutableComponent deserialize(JsonElement jsonelement) { ++ return (MutableComponent) Util.getOrThrow(ComponentSerialization.CODEC.parse(JsonOps.INSTANCE, jsonelement), 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) { +- return GSON.toJson(serialize(component)); ++ return Component.Serializer.GSON.toJson(serialize(component)); + } + + public static JsonElement toJsonTree(Component component) { +@@ -239,8 +305,9 @@ + + @Nullable + public static MutableComponent fromJson(String json) { +- JsonElement jsonElement = JsonParser.parseString(json); +- return jsonElement == null ? null : deserialize(jsonElement); ++ JsonElement jsonelement = JsonParser.parseString(json); ++ ++ return jsonelement == null ? null : deserialize(jsonelement); + } + + @Nullable +@@ -250,22 +317,12 @@ + + @Nullable + public static MutableComponent fromJsonLenient(String json) { +- JsonReader jsonReader = new JsonReader(new StringReader(json)); +- jsonReader.setLenient(true); +- JsonElement jsonElement = JsonParser.parseReader(jsonReader); +- return jsonElement == null ? null : deserialize(jsonElement); +- } +- } ++ JsonReader jsonreader = new JsonReader(new StringReader(json)); + +- public static class SerializerAdapter implements JsonDeserializer<MutableComponent>, JsonSerializer<Component> { +- @Override +- public MutableComponent deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { +- return Component.Serializer.deserialize(jsonElement); +- } ++ jsonreader.setLenient(true); ++ JsonElement jsonelement = JsonParser.parseReader(jsonreader); + +- @Override +- public JsonElement serialize(Component component, Type type, JsonSerializationContext jsonSerializationContext) { +- return Component.Serializer.serialize(component); ++ return jsonelement == null ? null : deserialize(jsonelement); + } + } + } diff --git a/patch-remap/mache-vineflower/net/minecraft/network/chat/TextColor.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/chat/TextColor.java.patch new file mode 100644 index 0000000000..0a26692999 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/chat/TextColor.java.patch @@ -0,0 +1,122 @@ +--- a/net/minecraft/network/chat/TextColor.java ++++ b/net/minecraft/network/chat/TextColor.java +@@ -13,27 +13,34 @@ + import net.minecraft.ChatFormatting; + + public final class TextColor { ++ + 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 = Stream.of(ChatFormatting.values()) +- .filter(ChatFormatting::isColor) +- .collect(ImmutableMap.toImmutableMap(Function.identity(), chatFormatting -> new TextColor(chatFormatting.getColor(), chatFormatting.getName()))); +- private static final Map<String, TextColor> NAMED_COLORS = LEGACY_FORMAT_TO_COLOR.values() +- .stream() +- .collect(ImmutableMap.toImmutableMap(textColor -> textColor.name, Function.identity())); ++ 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((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 value, String name) { +- this.value = value & 16777215; +- this.name = name; ++ private TextColor(int i, String s, ChatFormatting format) { ++ this.value = i & 16777215; ++ this.name = s; ++ this.format = format; + } + + private TextColor(int value) { + this.value = value & 16777215; + this.name = null; ++ this.format = null; + } ++ // CraftBukkit end + + public int getValue() { + return this.value; +@@ -47,50 +54,54 @@ + return String.format(Locale.ROOT, "#%06X", this.value); + } + +- @Override +- public boolean equals(Object other) { +- if (this == other) { ++ public boolean equals(Object object) { ++ if (this == object) { + return true; +- } else if (other != null && this.getClass() == other.getClass()) { +- TextColor textColor = (TextColor)other; +- return this.value == textColor.value; ++ } else if (object != null && this.getClass() == object.getClass()) { ++ TextColor chathexcolor = (TextColor) object; ++ ++ return this.value == chathexcolor.value; + } else { + return false; + } + } + +- @Override + public int hashCode() { +- return Objects.hash(this.value, this.name); ++ return Objects.hash(new Object[]{this.value, this.name}); + } + +- @Override + public String toString() { + return this.serialize(); + } + + @Nullable + public static TextColor fromLegacyFormat(ChatFormatting formatting) { +- return LEGACY_FORMAT_TO_COLOR.get(formatting); ++ return (TextColor) TextColor.LEGACY_FORMAT_TO_COLOR.get(formatting); + } + + public static TextColor fromRgb(int color) { + return new TextColor(color); + } + +- public static DataResult<TextColor> parseColor(String string) { +- if (string.startsWith("#")) { ++ public static DataResult<TextColor> parseColor(String s) { ++ if (s.startsWith("#")) { + try { +- int i = Integer.parseInt(string.substring(1), 16); +- return i >= 0 && i <= 16777215 +- ? DataResult.success(fromRgb(i), Lifecycle.stable()) +- : DataResult.error(() -> "Color value out of range: " + string); +- } catch (NumberFormatException var2) { +- return DataResult.error(() -> "Invalid color value: " + string); ++ int i = Integer.parseInt(s.substring(1), 16); ++ ++ return i >= 0 && i <= 16777215 ? DataResult.success(fromRgb(i), Lifecycle.stable()) : DataResult.error(() -> { ++ return "Color value out of range: " + s; ++ }); ++ } catch (NumberFormatException numberformatexception) { ++ return DataResult.error(() -> { ++ return "Invalid color value: " + s; ++ }); + } + } else { +- TextColor textColor = NAMED_COLORS.get(string); +- return textColor == null ? DataResult.error(() -> "Invalid color name: " + string) : DataResult.success(textColor, Lifecycle.stable()); ++ TextColor chathexcolor = (TextColor) TextColor.NAMED_COLORS.get(s); ++ ++ return chathexcolor == null ? DataResult.error(() -> { ++ return "Invalid color name: " + s; ++ }) : DataResult.success(chathexcolor, Lifecycle.stable()); + } + } + } diff --git a/patch-remap/mache-vineflower/net/minecraft/network/protocol/PacketUtils.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/PacketUtils.java.patch new file mode 100644 index 0000000000..bcdb7c2578 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/PacketUtils.java.patch @@ -0,0 +1,101 @@ +--- a/net/minecraft/network/protocol/PacketUtils.java ++++ b/net/minecraft/network/protocol/PacketUtils.java +@@ -4,46 +4,72 @@ + 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 { ++ + private static final Logger LOGGER = LogUtils.getLogger(); + +- public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T processor, ServerLevel level) throws RunningOnDifferentThreadException { +- ensureRunningOnSameThread(packet, processor, level.getServer()); ++ public PacketUtils() {} ++ ++ 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 processor, BlockableEventLoop<?> executor) throws RunningOnDifferentThreadException { ++ public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T processor, BlockableEventLoop<?> executor) throws CancelledPacketHandleException { + if (!executor.isSameThread()) { +- executor.executeIfPossible( +- () -> { +- if (processor.shouldHandleMessage(packet)) { +- try { +- packet.handle(processor); +- } catch (Exception var6) { +- if (var6 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError +- || processor.shouldPropagateHandlingExceptions()) { +- if (var6 instanceof ReportedException reportedException1) { +- processor.fillCrashReport(reportedException1.getReport()); +- throw var6; ++ executor.executeIfPossible(() -> { ++ if (MinecraftServer.getServer().hasStopped() || (processor instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) processor).processedDisconnect)) return; // CraftBukkit, MC-142590 ++ if (processor.shouldHandleMessage(packet)) { ++ try { ++ packet.handle(processor); ++ } catch (Exception exception) { ++ label25: ++ { ++ if (exception instanceof ReportedException) { ++ ReportedException reportedexception = (ReportedException) exception; ++ ++ if (reportedexception.getCause() instanceof OutOfMemoryError) { ++ break label25; + } +- +- CrashReport crashReport = CrashReport.forThrowable(var6, "Main thread packet handler"); +- processor.fillCrashReport(crashReport); +- throw new ReportedException(crashReport); + } +- +- LOGGER.error("Failed to handle packet {}, suppressing error", packet, var6); ++ ++ if (!processor.shouldPropagateHandlingExceptions()) { ++ PacketUtils.LOGGER.error("Failed to handle packet {}, suppressing error", packet, exception); ++ return; ++ } + } +- } else { +- LOGGER.debug("Ignoring packet due to disconnection: {}", packet); ++ ++ if (exception instanceof ReportedException) { ++ ReportedException reportedexception1 = (ReportedException) exception; ++ ++ processor.fillCrashReport(reportedexception1.getReport()); ++ throw exception; ++ } ++ ++ CrashReport crashreport = CrashReport.forThrowable(exception, "Main thread packet handler"); ++ ++ processor.fillCrashReport(crashreport); ++ throw new ReportedException(crashreport); + } ++ } else { ++ PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: {}", packet); + } +- ); +- 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-vineflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch new file mode 100644 index 0000000000..ae35fedaf7 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java ++++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java +@@ -10,27 +10,27 @@ + import net.minecraft.resources.ResourceLocation; + + 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.<ResourceLocation, FriendlyByteBuf.Reader<? extends CustomPacketPayload>>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> reader = KNOWN_TYPES.get(resourceLocation); +- return (CustomPacketPayload)(reader != null ? reader.apply(friendlyByteBuf) : readUnknownPayload(resourceLocation, friendlyByteBuf)); ++ private static CustomPacketPayload readPayload(ResourceLocation minecraftkey, FriendlyByteBuf packetdataserializer) { ++ FriendlyByteBuf.a<? extends CustomPacketPayload> packetdataserializer_a = (FriendlyByteBuf.a) ServerboundCustomPayloadPacket.KNOWN_TYPES.get(minecraftkey); ++ ++ 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"); + } +@@ -42,8 +42,17 @@ + this.payload.write(buffer); + } + +- @Override + 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-vineflower/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch new file mode 100644 index 0000000000..1143697c4a --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java +@@ -5,6 +5,7 @@ + import net.minecraft.world.level.border.WorldBorder; + + public class ClientboundInitializeBorderPacket implements Packet<ClientGamePacketListener> { ++ + private final double newCenterX; + private final double newCenterZ; + private final double oldSize; +@@ -26,8 +27,10 @@ + } + + public ClientboundInitializeBorderPacket(WorldBorder worldBorder) { +- this.newCenterX = worldBorder.getCenterX(); +- this.newCenterZ = worldBorder.getCenterZ(); ++ // 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(); +@@ -48,7 +51,6 @@ + buffer.writeVarInt(this.warningTime); + } + +- @Override + public void handle(ClientGamePacketListener handler) { + handler.handleInitializeBorder(this); + } diff --git a/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch new file mode 100644 index 0000000000..0ff164615d --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch @@ -0,0 +1,117 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java +@@ -1,5 +1,6 @@ + package net.minecraft.network.protocol.game; + ++import it.unimi.dsi.fastutil.shorts.ShortIterator; + import it.unimi.dsi.fastutil.shorts.ShortSet; + import java.util.function.BiConsumer; + import net.minecraft.core.BlockPos; +@@ -7,40 +8,55 @@ + 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> { ++ + 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 positions, LevelChunkSection section) { + this.sectionPos = sectionPos; +- int size = positions.size(); +- this.positions = new short[size]; +- this.states = new BlockState[size]; +- int i = 0; ++ int i = positions.size(); + +- for (short s : positions) { +- this.positions[i] = s; +- this.states[i] = section.getBlockState(SectionPos.sectionRelativeX(s), SectionPos.sectionRelativeY(s), SectionPos.sectionRelativeZ(s)); +- i++; ++ this.positions = new short[i]; ++ this.states = new IBlockData[i]; ++ int j = 0; ++ ++ for (ShortIterator shortiterator = positions.iterator(); shortiterator.hasNext(); ++j) { ++ short short0 = (Short) shortiterator.next(); ++ ++ this.positions[j] = 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 + } ++ + } + ++ // 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 varInt = buffer.readVarInt(); +- this.positions = new short[varInt]; +- this.states = new BlockState[varInt]; ++ int i = buffer.readVarInt(); + +- for (int i = 0; i < varInt; i++) { +- long varLong = buffer.readVarLong(); +- this.positions[i] = (short)((int)(varLong & 4095L)); +- this.states[i] = Block.BLOCK_STATE_REGISTRY.byId((int)(varLong >>> 12)); ++ this.positions = new short[i]; ++ this.states = new IBlockData[i]; ++ ++ for (int j = 0; j < i; ++j) { ++ long k = buffer.readVarLong(); ++ ++ this.positions[j] = (short) ((int) (k & 4095L)); ++ this.states[j] = (IBlockData) Block.BLOCK_STATE_REGISTRY.byId((int) (k >>> 12)); + } ++ + } + + @Override +@@ -48,23 +64,25 @@ + buffer.writeLong(this.sectionPos.asLong()); + buffer.writeVarInt(this.positions.length); + +- for (int i = 0; i < this.positions.length; i++) { +- buffer.writeVarLong((long)Block.getId(this.states[i]) << 12 | (long)this.positions[i]); ++ for (int i = 0; i < this.positions.length; ++i) { ++ buffer.writeVarLong((long) Block.getId(this.states[i]) << 12 | (long) this.positions[i]); + } ++ + } + +- @Override + public void handle(ClientGamePacketListener handler) { + handler.handleChunkBlocksUpdate(this); + } + +- public void runUpdates(BiConsumer<BlockPos, BlockState> consumer) { +- BlockPos.MutableBlockPos 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 s = this.positions[i]; +- mutableBlockPos.set(this.sectionPos.relativeToBlockX(s), this.sectionPos.relativeToBlockY(s), this.sectionPos.relativeToBlockZ(s)); +- consumer.accept(mutableBlockPos, this.states[i]); ++ for (int i = 0; i < this.positions.length; ++i) { ++ short short0 = this.positions[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-vineflower/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch new file mode 100644 index 0000000000..0470cad420 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java +@@ -5,12 +5,15 @@ + import net.minecraft.world.level.border.WorldBorder; + + public class ClientboundSetBorderCenterPacket implements Packet<ClientGamePacketListener> { ++ + private final double newCenterX; + private final double newCenterZ; + + public ClientboundSetBorderCenterPacket(WorldBorder worldBorder) { +- this.newCenterX = worldBorder.getCenterX(); +- this.newCenterZ = worldBorder.getCenterZ(); ++ // 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 buffer) { +@@ -24,7 +27,6 @@ + buffer.writeDouble(this.newCenterZ); + } + +- @Override + public void handle(ClientGamePacketListener handler) { + handler.handleSetBorderCenter(this); + } diff --git a/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch new file mode 100644 index 0000000000..53212e50fa --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch @@ -0,0 +1,23 @@ +--- 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; +@@ -5,6 +6,7 @@ + import net.minecraft.network.protocol.Packet; + + public record ClientboundSystemChatPacket(Component content, boolean overlay) implements Packet<ClientGamePacketListener> { ++ + public ClientboundSystemChatPacket(FriendlyByteBuf buffer) { + this(buffer.readComponentTrusted(), buffer.readBoolean()); + } +@@ -15,7 +17,6 @@ + buffer.writeBoolean(this.overlay); + } + +- @Override + public void handle(ClientGamePacketListener handler) { + handler.handleSystemChat(this); + } diff --git a/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch new file mode 100644 index 0000000000..d49deb4a55 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java ++++ b/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java +@@ -1,23 +1,25 @@ ++// 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 hand, BlockHitResult blockHit, int sequence) { ++ public ServerboundUseItemOnPacket(EnumHand hand, BlockHitResult blockHit, int sequence) { + this.hand = hand; + this.blockHit = blockHit; + this.sequence = sequence; + } + + public ServerboundUseItemOnPacket(FriendlyByteBuf buffer) { +- this.hand = buffer.readEnum(InteractionHand.class); ++ this.hand = (EnumHand) buffer.readEnum(EnumHand.class); + this.blockHit = buffer.readBlockHitResult(); + this.sequence = buffer.readVarInt(); + } +@@ -29,12 +31,11 @@ + buffer.writeVarInt(this.sequence); + } + +- @Override + public void handle(ServerGamePacketListener handler) { + handler.handleUseItemOn(this); + } + +- public InteractionHand getHand() { ++ public EnumHand getHand() { + return this.hand; + } + diff --git a/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch new file mode 100644 index 0000000000..db097997e2 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java ++++ b/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java +@@ -1,20 +1,22 @@ ++// 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 hand, int sequence) { ++ public ServerboundUseItemPacket(EnumHand hand, int sequence) { + this.hand = hand; + this.sequence = sequence; + } + + public ServerboundUseItemPacket(FriendlyByteBuf buffer) { +- this.hand = buffer.readEnum(InteractionHand.class); ++ this.hand = (EnumHand) buffer.readEnum(EnumHand.class); + this.sequence = buffer.readVarInt(); + } + +@@ -24,12 +26,11 @@ + buffer.writeVarInt(this.sequence); + } + +- @Override + public void handle(ServerGamePacketListener handler) { + handler.handleUseItem(this); + } + +- public InteractionHand getHand() { ++ public EnumHand getHand() { + return this.hand; + } + diff --git a/patch-remap/mache-vineflower/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch new file mode 100644 index 0000000000..879d7c0cbf --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch @@ -0,0 +1,33 @@ +--- 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; +@@ -5,16 +6,9 @@ + import net.minecraft.network.protocol.Packet; + + public record ClientIntentionPacket(int protocolVersion, String hostName, int port, ClientIntent intention) implements Packet<ServerHandshakePacketListener> { ++ + private static final int MAX_HOST_LENGTH = 255; + +- @Deprecated +- public ClientIntentionPacket(int protocolVersion, String hostName, int port, ClientIntent intention) { +- this.protocolVersion = protocolVersion; +- this.hostName = hostName; +- this.port = port; +- this.intention = intention; +- } +- + public ClientIntentionPacket(FriendlyByteBuf buffer) { + this(buffer.readVarInt(), buffer.readUtf(255), buffer.readUnsignedShort(), ClientIntent.byId(buffer.readVarInt())); + } +@@ -27,7 +21,6 @@ + buffer.writeVarInt(this.intention.id()); + } + +- @Override + public void handle(ServerHandshakePacketListener handler) { + handler.handleIntention(this); + } diff --git a/patch-remap/mache-vineflower/net/minecraft/network/syncher/SynchedEntityData.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/syncher/SynchedEntityData.java.patch new file mode 100644 index 0000000000..6071a786aa --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -0,0 +1,345 @@ +--- a/net/minecraft/network/syncher/SynchedEntityData.java ++++ b/net/minecraft/network/syncher/SynchedEntityData.java +@@ -7,7 +7,9 @@ + import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + import it.unimi.dsi.fastutil.objects.Object2IntMap; + import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; ++import it.unimi.dsi.fastutil.objects.ObjectIterator; + import java.util.ArrayList; ++import java.util.Iterator; + import java.util.List; + import java.util.Locale; + import java.util.Objects; +@@ -18,16 +20,19 @@ + 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; + + public class SynchedEntityData { ++ + private static final Logger LOGGER = LogUtils.getLogger(); +- private static final Object2IntMap<Class<? extends Entity>> ENTITY_ID_POOL = new Object2IntOpenHashMap<>(); ++ private static final Object2IntMap<Class<? extends Entity>> ENTITY_ID_POOL = new Object2IntOpenHashMap(); + private static final int MAX_ID_VALUE = 254; + private final Entity entity; +- private final Int2ObjectMap<SynchedEntityData.DataItem<?>> itemsById = new Int2ObjectOpenHashMap<>(); ++ private final Int2ObjectMap<SynchedEntityData.DataItem<?>> itemsById = new Int2ObjectOpenHashMap(); + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + private boolean isDirty; + +@@ -36,59 +41,66 @@ + } + + public static <T> EntityDataAccessor<T> defineId(Class<? extends Entity> clazz, EntityDataSerializer<T> serializer) { +- if (LOGGER.isDebugEnabled()) { ++ if (SynchedEntityData.LOGGER.isDebugEnabled()) { + try { +- Class<?> clazz1 = Class.forName(Thread.currentThread().getStackTrace()[2].getClassName()); +- if (!clazz1.equals(clazz)) { +- LOGGER.debug("defineId called for: {} from {}", clazz, clazz1, new RuntimeException()); ++ Class<?> oclass1 = Class.forName(Thread.currentThread().getStackTrace()[2].getClassName()); ++ ++ if (!oclass1.equals(clazz)) { ++ SynchedEntityData.LOGGER.debug("defineId called for: {} from {}", new Object[]{clazz, oclass1, new RuntimeException()}); + } +- } catch (ClassNotFoundException var5) { ++ } catch (ClassNotFoundException classnotfoundexception) { ++ ; + } + } + + int i; +- if (ENTITY_ID_POOL.containsKey(clazz)) { +- i = ENTITY_ID_POOL.getInt(clazz) + 1; ++ ++ if (SynchedEntityData.ENTITY_ID_POOL.containsKey(clazz)) { ++ i = SynchedEntityData.ENTITY_ID_POOL.getInt(clazz) + 1; + } else { +- int i1 = 0; +- Class<?> clazz2 = clazz; ++ int j = 0; ++ Class oclass2 = clazz; + +- while (clazz2 != Entity.class) { +- clazz2 = clazz2.getSuperclass(); +- if (ENTITY_ID_POOL.containsKey(clazz2)) { +- i1 = ENTITY_ID_POOL.getInt(clazz2) + 1; ++ while (oclass2 != Entity.class) { ++ oclass2 = oclass2.getSuperclass(); ++ if (SynchedEntityData.ENTITY_ID_POOL.containsKey(oclass2)) { ++ j = SynchedEntityData.ENTITY_ID_POOL.getInt(oclass2) + 1; + break; + } + } + +- i = i1; ++ i = j; + } + + if (i > 254) { + throw new IllegalArgumentException("Data value id is too big with " + i + "! (Max is 254)"); + } else { +- ENTITY_ID_POOL.put(clazz, i); ++ SynchedEntityData.ENTITY_ID_POOL.put(clazz, i); + return serializer.createAccessor(i); + } + } + + public <T> void define(EntityDataAccessor<T> key, T value) { +- int id = key.getId(); +- if (id > 254) { +- throw new IllegalArgumentException("Data value id is too big with " + id + "! (Max is 254)"); +- } else if (this.itemsById.containsKey(id)) { +- throw new IllegalArgumentException("Duplicate id value for " + id + "!"); ++ 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(key.getSerializer()) < 0) { +- throw new IllegalArgumentException("Unregistered serializer " + key.getSerializer() + " for " + id + "!"); ++ EntityDataSerializer datawatcherserializer = key.getSerializer(); ++ ++ throw new IllegalArgumentException("Unregistered serializer " + datawatcherserializer + " for " + i + "!"); + } else { + this.createDataItem(key, value); + } + } + + private <T> void createDataItem(EntityDataAccessor<T> key, T value) { +- SynchedEntityData.DataItem<T> dataItem = new SynchedEntityData.DataItem<>(key, value); ++ SynchedEntityData.DataItem<T> datawatcher_item = new SynchedEntityData.DataItem<>(key, value); ++ + this.lock.writeLock().lock(); +- this.itemsById.put(key.getId(), dataItem); ++ this.itemsById.put(key.getId(), datawatcher_item); + this.lock.writeLock().unlock(); + } + +@@ -99,19 +111,21 @@ + private <T> SynchedEntityData.DataItem<T> getItem(EntityDataAccessor<T> key) { + this.lock.readLock().lock(); + +- SynchedEntityData.DataItem<T> dataItem; ++ SynchedEntityData.DataItem datawatcher_item; ++ + try { +- dataItem = (SynchedEntityData.DataItem<T>)this.itemsById.get(key.getId()); +- } catch (Throwable var9) { +- CrashReport crashReport = CrashReport.forThrowable(var9, "Getting synched entity data"); +- CrashReportCategory crashReportCategory = crashReport.addCategory("Synched entity data"); +- crashReportCategory.setDetail("Data ID", key); +- throw new ReportedException(crashReport); ++ datawatcher_item = (SynchedEntityData.DataItem) this.itemsById.get(key.getId()); ++ } catch (Throwable throwable) { ++ CrashReport crashreport = CrashReport.forThrowable(throwable, "Getting synched entity data"); ++ CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Synched entity data"); ++ ++ crashreportsystemdetails.setDetail("Data ID", (Object) key); ++ throw new ReportedException(crashreport); + } finally { + this.lock.readLock().unlock(); + } + +- return dataItem; ++ return datawatcher_item; + } + + public <T> T get(EntityDataAccessor<T> key) { +@@ -123,15 +137,24 @@ + } + + public <T> void set(EntityDataAccessor<T> key, T value, boolean force) { +- SynchedEntityData.DataItem<T> item = this.getItem(key); +- if (force || ObjectUtils.notEqual(value, item.getValue())) { +- item.setValue(value); ++ SynchedEntityData.DataItem<T> datawatcher_item = this.getItem(key); ++ ++ if (force || ObjectUtils.notEqual(value, datawatcher_item.getValue())) { ++ datawatcher_item.setValue(value); + this.entity.onSyncedDataUpdated(key); +- item.setDirty(true); ++ 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; + } +@@ -139,17 +162,21 @@ + @Nullable + public List<SynchedEntityData.DataValue<?>> packDirty() { + List<SynchedEntityData.DataValue<?>> list = null; ++ + if (this.isDirty) { + this.lock.readLock().lock(); ++ ObjectIterator objectiterator = this.itemsById.values().iterator(); + +- for (SynchedEntityData.DataItem<?> dataItem : this.itemsById.values()) { +- if (dataItem.isDirty()) { +- dataItem.setDirty(false); ++ while (objectiterator.hasNext()) { ++ SynchedEntityData.DataItem<?> datawatcher_item = (SynchedEntityData.DataItem) objectiterator.next(); ++ ++ if (datawatcher_item.isDirty()) { ++ datawatcher_item.setDirty(false); + if (list == null) { +- list = new ArrayList<>(); ++ list = new ArrayList(); + } + +- list.add(dataItem.value()); ++ list.add(datawatcher_item.value()); + } + } + +@@ -163,15 +190,19 @@ + @Nullable + public List<SynchedEntityData.DataValue<?>> getNonDefaultValues() { + List<SynchedEntityData.DataValue<?>> list = null; ++ + this.lock.readLock().lock(); ++ ObjectIterator objectiterator = this.itemsById.values().iterator(); + +- for (SynchedEntityData.DataItem<?> dataItem : this.itemsById.values()) { +- if (!dataItem.isSetToDefault()) { ++ while (objectiterator.hasNext()) { ++ SynchedEntityData.DataItem<?> datawatcher_item = (SynchedEntityData.DataItem) objectiterator.next(); ++ ++ if (!datawatcher_item.isSetToDefault()) { + if (list == null) { +- list = new ArrayList<>(); ++ list = new ArrayList(); + } + +- list.add(dataItem.value()); ++ list.add(datawatcher_item.value()); + } + } + +@@ -183,11 +214,15 @@ + this.lock.writeLock().lock(); + + try { +- for (SynchedEntityData.DataValue<?> dataValue : entries) { +- SynchedEntityData.DataItem<?> dataItem = this.itemsById.get(dataValue.id); +- if (dataItem != null) { +- this.assignValue(dataItem, dataValue); +- this.entity.onSyncedDataUpdated(dataItem.getAccessor()); ++ Iterator iterator = entries.iterator(); ++ ++ while (iterator.hasNext()) { ++ SynchedEntityData.DataValue<?> datawatcher_b = (SynchedEntityData.DataValue) iterator.next(); ++ SynchedEntityData.DataItem<?> datawatcher_item = (SynchedEntityData.DataItem) this.itemsById.get(datawatcher_b.id); ++ ++ if (datawatcher_item != null) { ++ this.assignValue(datawatcher_item, datawatcher_b); ++ this.entity.onSyncedDataUpdated(datawatcher_item.getAccessor()); + } + } + } finally { +@@ -199,20 +234,9 @@ + + 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() +- ) +- ); ++ 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 { +- target.setValue((T)entry.value); ++ target.setValue((T) entry.value); // CraftBukkit - decompile error + } + } + +@@ -220,7 +244,20 @@ + 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; + T value; + private final T initialValue; +@@ -261,30 +298,34 @@ + } + } + +- 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> dataAccessor, T value) { +- EntityDataSerializer<T> serializer = dataAccessor.getSerializer(); +- return new SynchedEntityData.DataValue<>(dataAccessor.getId(), serializer, serializer.copy(value)); ++ EntityDataSerializer<T> datawatcherserializer = dataAccessor.getSerializer(); ++ ++ return new SynchedEntityData.DataValue<>(dataAccessor.getId(), datawatcherserializer, datawatcherserializer.copy(value)); + } + + public void write(FriendlyByteBuf buffer) { +- int serializedId = EntityDataSerializers.getSerializedId(this.serializer); +- if (serializedId < 0) { ++ int i = EntityDataSerializers.getSerializedId(this.serializer); ++ ++ if (i < 0) { + throw new EncoderException("Unknown serializer type " + this.serializer); + } else { + buffer.writeByte(this.id); +- buffer.writeVarInt(serializedId); ++ buffer.writeVarInt(i); + this.serializer.write(buffer, this.value); + } + } + + public static SynchedEntityData.DataValue<?> read(FriendlyByteBuf buffer, int id) { +- int varInt = buffer.readVarInt(); +- EntityDataSerializer<?> serializer = EntityDataSerializers.getSerializer(varInt); +- if (serializer == null) { +- throw new DecoderException("Unknown serializer type " + varInt); ++ int j = buffer.readVarInt(); ++ EntityDataSerializer<?> datawatcherserializer = EntityDataSerializers.getSerializer(j); ++ ++ if (datawatcherserializer == null) { ++ throw new DecoderException("Unknown serializer type " + j); + } else { +- return read(buffer, id, serializer); ++ return read(buffer, id, datawatcherserializer); + } + } + |