Move FMLHandshakeFilter into 1.12.2 project

This commit is contained in:
Jonas Herzig
2021-02-23 00:22:00 +01:00
parent 6094422792
commit 22d1048999
2 changed files with 30 additions and 31 deletions

View File

@@ -1,31 +1 @@
//#if MC<11400
//$$ package com.replaymod.recording.handler;
//$$
//$$ import io.netty.channel.ChannelHandlerContext;
//$$ import io.netty.channel.SimpleChannelInboundHandler;
//$$ import net.minecraftforge.fml.common.network.handshake.FMLHandshakeMessage;
//$$
//$$ /**
//$$ * Filters out all handshake packets that were sent for recording but must
//$$ * not actually be handled.
//$$ * This handler is only present when connected to the integrated server as
//$$ * otherwise all packets must be handled.
//$$ *
//$$ * When in single player, the game state packets must never be handled
//$$ * otherwise wired bugs related to semi-singletons can occur.
//$$ * See https://bugs.replaymod.com/show_bug.cgi?id=44
//$$ */
//$$ public class FMLHandshakeFilter extends SimpleChannelInboundHandler<FMLHandshakeMessage> {
//$$ @Override
//$$ protected void channelRead0(ChannelHandlerContext ctx, FMLHandshakeMessage msg) throws Exception {
//#if MC>=10800
//$$ if (!(msg instanceof FMLHandshakeMessage.RegistryData)) {
//#else
//$$ if (!(msg instanceof FMLHandshakeMessage.ModIdData)) {
//#endif
//$$ // Pass on everything but RegistryData messages
//$$ ctx.fireChannelRead(msg);
//$$ }
//$$ }
//$$ }
//#endif
// 1.12.2 and below

View File

@@ -0,0 +1,29 @@
package com.replaymod.recording.handler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import net.minecraftforge.fml.common.network.handshake.FMLHandshakeMessage;
/**
* Filters out all handshake packets that were sent for recording but must
* not actually be handled.
* This handler is only present when connected to the integrated server as
* otherwise all packets must be handled.
*
* When in single player, the game state packets must never be handled
* otherwise wired bugs related to semi-singletons can occur.
* See https://bugs.replaymod.com/show_bug.cgi?id=44
*/
public class FMLHandshakeFilter extends SimpleChannelInboundHandler<FMLHandshakeMessage> {
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLHandshakeMessage msg) throws Exception {
//#if MC>=10800
if (!(msg instanceof FMLHandshakeMessage.RegistryData)) {
//#else
//$$ if (!(msg instanceof FMLHandshakeMessage.ModIdData)) {
//#endif
// Pass on everything but RegistryData messages
ctx.fireChannelRead(msg);
}
}
}