/** * This packet is executed on the client to evaluate the server's mod list against the client * * @see cpw.mods.fml.common.network.FMLPacket#execute(INetworkManager, FMLNetworkHandler, * NetHandler, String) */ @Override public void execute( INetworkManager mgr, FMLNetworkHandler handler, NetHandler netHandler, String userName) { List<String> missingMods = Lists.newArrayList(); Map<String, String> modVersions = Maps.newHashMap(); Map<String, ModContainer> indexedModList = Maps.newHashMap(Loader.instance().getIndexedModList()); for (String m : sentModList) { ModContainer mc = indexedModList.get(m); if (mc == null) { missingMods.add(m); continue; } indexedModList.remove(m); modVersions.put(m, mc.getVersion()); } if (indexedModList.size() > 0) { for (Entry<String, ModContainer> e : indexedModList.entrySet()) { if (e.getValue().isNetworkMod()) { NetworkModHandler missingHandler = FMLNetworkHandler.instance().findNetworkModHandler(e.getValue()); if (missingHandler.requiresServerSide()) { // TODO : what should we do if a mod is marked "serverSideRequired"? Stop the // connection? FMLLog.warning( "The mod %s was not found on the server you connected to, but requested that the server side be present", e.getKey()); } } } } FMLLog.fine("The server has compatibility level %d", compatibilityLevel); FMLCommonHandler.instance().getSidedDelegate().setClientCompatibilityLevel(compatibilityLevel); mgr.func_74429_a( PacketDispatcher.getPacket( "FML", FMLPacket.makePacket(MOD_LIST_RESPONSE, modVersions, missingMods))); }
@Override public void execute( INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName) { Map<String, ModContainer> indexedModList = Maps.newHashMap(Loader.instance().getIndexedModList()); List<String> missingClientMods = Lists.newArrayList(); List<String> versionIncorrectMods = Lists.newArrayList(); for (String m : missingMods) { ModContainer mc = indexedModList.get(m); NetworkModHandler networkMod = handler.findNetworkModHandler(mc); if (networkMod.requiresClientSide()) { missingClientMods.add(m); } } for (Entry<String, String> modVersion : modVersions.entrySet()) { ModContainer mc = indexedModList.get(modVersion.getKey()); NetworkModHandler networkMod = handler.findNetworkModHandler(mc); if (!networkMod.acceptVersion(modVersion.getValue())) { versionIncorrectMods.add(modVersion.getKey()); } } Packet250CustomPayload pkt = new Packet250CustomPayload(); pkt.field_73630_a = "FML"; if (missingClientMods.size() > 0 || versionIncorrectMods.size() > 0) { pkt.field_73629_c = FMLPacket.makePacket(MOD_MISSING, missingClientMods, versionIncorrectMods); Logger.getLogger("Minecraft") .info( String.format( "User %s connection failed: missing %s, bad versions %s", userName, missingClientMods, versionIncorrectMods)); FMLLog.info( "User %s connection failed: missing %s, bad versions %s", userName, missingClientMods, versionIncorrectMods); // Mark this as bad FMLNetworkHandler.setHandlerState( (NetLoginHandler) netHandler, FMLNetworkHandler.MISSING_MODS_OR_VERSIONS); pkt.field_73628_b = pkt.field_73629_c.length; network.func_74429_a(pkt); } else { pkt.field_73629_c = FMLPacket.makePacket(MOD_IDENTIFIERS, netHandler); Logger.getLogger("Minecraft") .info(String.format("User %s connecting with mods %s", userName, modVersions.keySet())); FMLLog.info("User %s connecting with mods %s", userName, modVersions.keySet()); pkt.field_73628_b = pkt.field_73629_c.length; network.func_74429_a(pkt); NBTTagList itemList = new NBTTagList(); GameData.writeItemData(itemList); byte[][] registryPackets = FMLPacket.makePacketSet(MOD_IDMAP, itemList); for (int i = 0; i < registryPackets.length; i++) { network.func_74429_a(PacketDispatcher.getPacket("FML", registryPackets[i])); } } // reset the continuation flag - we have completed extra negotiation and the login should // complete now NetLoginHandler.func_72531_a((NetLoginHandler) netHandler, true); }