Files
MinecraftForge/patches/minecraft/net/minecraft/network/Connection.java.patch
T
2023-06-12 15:09:50 -07:00

62 lines
2.3 KiB
Diff

--- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java
@@ -86,6 +_,7 @@
private boolean f_129479_;
@Nullable
private volatile Component f_290021_;
+ private java.util.function.Consumer<Connection> activationHandler;
public Connection(PacketFlow p_129482_) {
this.f_129466_ = p_129482_;
@@ -95,6 +_,7 @@
super.channelActive(p_129525_);
this.f_129468_ = p_129525_.channel();
this.f_129469_ = this.f_129468_.remoteAddress();
+ if (activationHandler != null) activationHandler.accept(this);
try {
this.m_129498_(ConnectionProtocol.HANDSHAKING);
@@ -111,8 +_,10 @@
public void m_129498_(ConnectionProtocol p_129499_) {
this.f_129468_.attr(f_129461_).set(p_129499_);
this.f_129468_.attr(BundlerInfo.f_263730_).set(p_129499_);
+ this.f_129468_.eventLoop().execute(()-> {
this.f_129468_.config().setAutoRead(true);
f_129465_.debug("Enabled auto read");
+ });
}
public void channelInactive(ChannelHandlerContext p_129527_) {
@@ -316,6 +_,8 @@
}
public static ChannelFuture m_290025_(InetSocketAddress p_290034_, boolean p_290035_, final Connection p_290031_) {
+ net.minecraftforge.network.DualStackUtils.checkIPv6(p_290034_.getAddress());
+ p_290031_.activationHandler = net.minecraftforge.network.NetworkHooks::registerClientLoginChannel;
Class<? extends SocketChannel> oclass;
LazyLoadedValue<? extends EventLoopGroup> lazyloadedvalue;
if (Epoll.isAvailable() && p_290035_) {
@@ -347,6 +_,7 @@
public static Connection m_129493_(SocketAddress p_129494_) {
final Connection connection = new Connection(PacketFlow.CLIENTBOUND);
+ connection.activationHandler = net.minecraftforge.network.NetworkHooks::registerClientLoginChannel;
(new Bootstrap()).group(f_129464_.m_13971_()).handler(new ChannelInitializer<Channel>() {
protected void initChannel(Channel p_129557_) {
ChannelPipeline channelpipeline = p_129557_.pipeline();
@@ -437,6 +_,14 @@
public float m_129543_() {
return this.f_129477_;
+ }
+
+ public Channel channel() {
+ return this.f_129468_;
+ }
+
+ public PacketFlow getDirection() {
+ return this.f_129466_;
}
static class PacketHolder {