Fix replay initialization with login phase on 1.11.2 and below
While this commit also considerably simplifies/cleans the setup method, the actual fix is that the networkManager is now added to the channel pipeline with under the "packet_handler" key, whereas before it was unnamed causing issues when transitioning to the play state.
This commit is contained in:
@@ -705,13 +705,6 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
//#if MC>=10904
|
|
||||||
ctx.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).set(EnumConnectionState.PLAY);
|
|
||||||
//#else
|
|
||||||
//#if MC>=10800
|
|
||||||
//$$ ctx.attr(NetworkManager.attrKeyConnectionState).set(EnumConnectionState.PLAY);
|
|
||||||
//#endif
|
|
||||||
//#endif
|
|
||||||
super.channelActive(ctx);
|
super.channelActive(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ import net.minecraft.entity.EntityLivingBase;
|
|||||||
//$$ import org.lwjgl.opengl.Display;
|
//$$ import org.lwjgl.opengl.Display;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
|
//#else
|
||||||
|
//$$ import io.netty.channel.ChannelOutboundHandlerAdapter;
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#if MC<10904
|
//#if MC<10904
|
||||||
//$$ import de.johni0702.minecraft.gui.element.GuiLabel;
|
//$$ import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||||
//$$ import de.johni0702.minecraft.gui.popup.GuiInfoPopup;
|
//$$ import de.johni0702.minecraft.gui.popup.GuiInfoPopup;
|
||||||
@@ -69,9 +74,7 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
|||||||
//$$ import cpw.mods.fml.common.Loader;
|
//$$ import cpw.mods.fml.common.Loader;
|
||||||
//$$ import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
//$$ import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||||
//$$ import com.replaymod.replay.gui.screen.GuiOpeningReplay;
|
//$$ import com.replaymod.replay.gui.screen.GuiOpeningReplay;
|
||||||
//$$ import io.netty.channel.ChannelOutboundHandlerAdapter;
|
|
||||||
//$$ import net.minecraft.entity.EntityLivingBase;
|
//$$ import net.minecraft.entity.EntityLivingBase;
|
||||||
//$$ import net.minecraft.network.EnumConnectionState;
|
|
||||||
//$$
|
//$$
|
||||||
//$$ import java.net.InetSocketAddress;
|
//$$ import java.net.InetSocketAddress;
|
||||||
//$$ import java.net.SocketAddress;
|
//$$ import java.net.SocketAddress;
|
||||||
@@ -231,40 +234,6 @@ public class ReplayHandler {
|
|||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//#if MC>=11300
|
|
||||||
channel = new EmbeddedChannel();
|
|
||||||
|
|
||||||
channel.pipeline().addFirst("ReplayModReplay_replaySender", fullReplaySender);
|
|
||||||
channel.pipeline().addFirst("ReplayModReplay_quickReplaySender", quickReplaySender);
|
|
||||||
channel.pipeline().addLast("packet_handler", networkManager);
|
|
||||||
channel.pipeline().fireChannelActive();
|
|
||||||
|
|
||||||
networkManager.setNetHandler(new NetHandlerLoginClient(networkManager, mc, null, it -> {}));
|
|
||||||
//#if MC<11400
|
|
||||||
NetworkHooks.registerClientLoginChannel(networkManager);
|
|
||||||
//#endif
|
|
||||||
// FIXME make this work (with vanilla and mods) on all other versions again, now that login phase is included
|
|
||||||
// probably have to change some of the forge handshake calls
|
|
||||||
//#else
|
|
||||||
//$$ NetHandlerLoginClient netHandlerLoginClient =
|
|
||||||
//$$ new NetHandlerLoginClient(networkManager, mc, null);
|
|
||||||
//$$ networkManager.setNetHandler(netHandlerLoginClient);
|
|
||||||
//$$
|
|
||||||
//#if MC>=11200
|
|
||||||
//$$ channel = new EmbeddedChannel();
|
|
||||||
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", fullReplaySender);
|
|
||||||
//$$ channel.pipeline().addFirst("ReplayModReplay_quickReplaySender", quickReplaySender);
|
|
||||||
//$$ channel.pipeline().addLast("packet_handler", networkManager);
|
|
||||||
//$$ channel.pipeline().fireChannelActive();
|
|
||||||
//#else
|
|
||||||
//$$ channel = new EmbeddedChannel(networkManager);
|
|
||||||
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", fullReplaySender);
|
|
||||||
//#if MC>=10904
|
|
||||||
//$$ channel.pipeline().addFirst("ReplayModReplay_quickReplaySender", quickReplaySender);
|
|
||||||
//#endif
|
|
||||||
//$$ channel.pipeline().fireChannelActive();
|
|
||||||
//#endif
|
|
||||||
//#endif
|
|
||||||
//#else
|
//#else
|
||||||
//$$ NetworkManager networkManager = new NetworkManager(true) {
|
//$$ NetworkManager networkManager = new NetworkManager(true) {
|
||||||
//$$ @Override
|
//$$ @Override
|
||||||
@@ -285,16 +254,35 @@ public class ReplayHandler {
|
|||||||
//$$ t.printStackTrace();
|
//$$ t.printStackTrace();
|
||||||
//$$ }
|
//$$ }
|
||||||
//$$ };
|
//$$ };
|
||||||
//$$ networkManager.setNetHandler(new NetHandlerLoginClient(networkManager, mc, null));
|
|
||||||
//$$
|
|
||||||
//$$ mc.displayGuiScreen(new GuiOpeningReplay(networkManager));
|
//$$ mc.displayGuiScreen(new GuiOpeningReplay(networkManager));
|
||||||
//$$
|
//#endif
|
||||||
|
|
||||||
|
networkManager.setNetHandler(new NetHandlerLoginClient(
|
||||||
|
networkManager,
|
||||||
|
mc,
|
||||||
|
null
|
||||||
|
//#if MC>=11300
|
||||||
|
, it -> {}
|
||||||
|
//#endif
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
|
channel = new EmbeddedChannel();
|
||||||
|
//#else
|
||||||
//$$ ChannelOutboundHandlerAdapter dummyHandler = new ChannelOutboundHandlerAdapter();
|
//$$ ChannelOutboundHandlerAdapter dummyHandler = new ChannelOutboundHandlerAdapter();
|
||||||
//$$ channel = new EmbeddedChannel(dummyHandler);
|
//$$ channel = new EmbeddedChannel(dummyHandler);
|
||||||
//$$ channel.pipeline().remove(dummyHandler);
|
//$$ channel.pipeline().remove(dummyHandler);
|
||||||
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", fullReplaySender);
|
//#endif
|
||||||
//$$ channel.pipeline().addAfter("ReplayModReplay_replaySender", "packet_handler", networkManager);
|
//#if MC>=10904
|
||||||
//$$ channel.pipeline().fireChannelActive();
|
channel.pipeline().addLast("ReplayModReplay_quickReplaySender", quickReplaySender);
|
||||||
|
//#endif
|
||||||
|
channel.pipeline().addLast("ReplayModReplay_replaySender", fullReplaySender);
|
||||||
|
channel.pipeline().addLast("packet_handler", networkManager);
|
||||||
|
channel.pipeline().fireChannelActive();
|
||||||
|
|
||||||
|
//#if MC>=11300 && MC<11400
|
||||||
|
NetworkHooks.registerClientLoginChannel(networkManager);
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user