Fix some ClassCastExceptions incorrectly being logged in FML handshake. (#4972)
This commit is contained in:
parent
19de6cf97e
commit
80724a52d3
2 changed files with 17 additions and 17 deletions
|
@ -129,7 +129,7 @@ enum FMLHandshakeClientState implements IHandshakeState<FMLHandshakeClientState>
|
|||
WAITINGSERVERCOMPLETE
|
||||
{
|
||||
@Override
|
||||
public void accept(final ChannelHandlerContext ctx, final FMLHandshakeMessage msg, final Consumer<? super FMLHandshakeClientState> cons)
|
||||
public void accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg, Consumer<? super FMLHandshakeClientState> cons)
|
||||
{
|
||||
FMLHandshakeMessage.RegistryData pkt = (FMLHandshakeMessage.RegistryData)msg;
|
||||
Map<ResourceLocation, ForgeRegistry.Snapshot> snap = ctx.channel().attr(NetworkDispatcher.FML_GAMEDATA_SNAPSHOT).get();
|
||||
|
@ -156,9 +156,7 @@ enum FMLHandshakeClientState implements IHandshakeState<FMLHandshakeClientState>
|
|||
|
||||
//Do the remapping on the Client's thread in case things are reset while the client is running. We stall the network thread until this is finished which can cause the IO thread to time out... Not sure if we can do anything about that.
|
||||
final Map<ResourceLocation, ForgeRegistry.Snapshot> snap_f = snap;
|
||||
Futures.getUnchecked(Minecraft.getMinecraft().addScheduledTask(() ->
|
||||
{
|
||||
Multimap<ResourceLocation, ResourceLocation> locallyMissing = GameData.injectSnapshot(snap_f, false, false);
|
||||
Multimap<ResourceLocation, ResourceLocation> locallyMissing = Futures.getUnchecked(Minecraft.getMinecraft().addScheduledTask(() -> GameData.injectSnapshot(snap_f, false, false)));
|
||||
if (!locallyMissing.isEmpty())
|
||||
{
|
||||
cons.accept(ERROR);
|
||||
|
@ -170,7 +168,6 @@ enum FMLHandshakeClientState implements IHandshakeState<FMLHandshakeClientState>
|
|||
}
|
||||
cons.accept(PENDINGCOMPLETE);
|
||||
ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}));
|
||||
}
|
||||
},
|
||||
PENDINGCOMPLETE
|
||||
|
|
|
@ -28,14 +28,16 @@ import io.netty.util.AttributeKey;
|
|||
public class HandshakeMessageHandler<S extends Enum<S> & IHandshakeState<S>> extends SimpleChannelInboundHandler<FMLHandshakeMessage> {
|
||||
private static final AttributeKey<IHandshakeState<?>> STATE = AttributeKey.valueOf("fml:handshake-state");
|
||||
private final AttributeKey<S> fmlHandshakeState;
|
||||
private S initialState;
|
||||
private Class<S> stateType;
|
||||
private final S initialState;
|
||||
private final S errorState;
|
||||
private final Class<S> stateType;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public HandshakeMessageHandler(Class<S> stateType)
|
||||
{
|
||||
fmlHandshakeState = (AttributeKey<S>) ((Object)STATE);
|
||||
initialState = Enum.valueOf(stateType, "START");
|
||||
errorState = Enum.valueOf(stateType, "ERROR");
|
||||
this.stateType = stateType;
|
||||
}
|
||||
@Override
|
||||
|
@ -71,6 +73,7 @@ public class HandshakeMessageHandler<S extends Enum<S> & IHandshakeState<S>> ext
|
|||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
||||
{
|
||||
FMLLog.log.error("HandshakeMessageHandler exception", cause);
|
||||
ctx.channel().attr(fmlHandshakeState).set(errorState);
|
||||
super.exceptionCaught(ctx, cause);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue