Пример #1
0
  @Override
  public void disconnectIDMismatch(
      MapDifference<Integer, ItemData> s, NetHandler toKill, INetworkManager mgr) {
    boolean criticalMismatch = !s.entriesOnlyOnLeft().isEmpty();
    for (Entry<Integer, ValueDifference<ItemData>> mismatch : s.entriesDiffering().entrySet()) {
      ValueDifference<ItemData> vd = mismatch.getValue();
      if (!vd.leftValue().mayDifferByOrdinal(vd.rightValue())) {
        criticalMismatch = true;
      }
    }

    if (!criticalMismatch) {
      // We'll carry on with this connection, and just log a message instead
      return;
    }
    // Nuke the connection
    ((NetClientHandler) toKill).func_72553_e();
    // Stop GuiConnecting
    GuiConnecting.forceTermination((GuiConnecting) client.field_71462_r);
    // pulse the network manager queue to clear cruft
    mgr.func_74428_b();
    // Nuke the world client
    client.func_71403_a((WorldClient) null);
    // Show error screen
    warnIDMismatch(s, false);
  }
Пример #2
0
  /**
   * 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)));
  }
Пример #3
0
  @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);
  }
  public void initializeConnectionToPlayer(
      INetworkManager par1INetworkManager, EntityPlayerMP par2EntityPlayerMP) {
    this.readPlayerDataFromFile(par2EntityPlayerMP);
    par2EntityPlayerMP.setWorld(
        this.mcServer.worldServerForDimension(par2EntityPlayerMP.dimension));
    par2EntityPlayerMP.theItemInWorldManager.setWorld((WorldServer) par2EntityPlayerMP.worldObj);
    String var3 = "local";

    if (par1INetworkManager.getSocketAddress() != null) {
      var3 = par1INetworkManager.getSocketAddress().toString();
    }

    logger.info(
        par2EntityPlayerMP.username
            + "["
            + var3
            + "] logged in with entity id "
            + par2EntityPlayerMP.entityId
            + " at ("
            + par2EntityPlayerMP.posX
            + ", "
            + par2EntityPlayerMP.posY
            + ", "
            + par2EntityPlayerMP.posZ
            + ")");
    WorldServer var4 = this.mcServer.worldServerForDimension(par2EntityPlayerMP.dimension);
    ChunkCoordinates var5 = var4.getSpawnPoint();
    this.func_72381_a(par2EntityPlayerMP, (EntityPlayerMP) null, var4);
    NetServerHandler var6 =
        new NetServerHandler(this.mcServer, par1INetworkManager, par2EntityPlayerMP);
    var6.sendPacketToPlayer(
        new Packet1Login(
            par2EntityPlayerMP.entityId,
            var4.getWorldInfo().getTerrainType(),
            par2EntityPlayerMP.theItemInWorldManager.getGameType(),
            var4.getWorldInfo().isHardcoreModeEnabled(),
            var4.provider.dimensionId,
            var4.difficultySetting,
            var4.getHeight(),
            this.getMaxPlayers()));
    var6.sendPacketToPlayer(new Packet6SpawnPosition(var5.posX, var5.posY, var5.posZ));
    var6.sendPacketToPlayer(new Packet202PlayerAbilities(par2EntityPlayerMP.capabilities));
    var6.sendPacketToPlayer(new Packet16BlockItemSwitch(par2EntityPlayerMP.inventory.currentItem));
    this.updateTimeAndWeatherForPlayer(par2EntityPlayerMP, var4);
    this.sendPacketToAllPlayers(
        new Packet3Chat("\u00a7e" + par2EntityPlayerMP.username + " joined the game."));
    this.playerLoggedIn(par2EntityPlayerMP);
    var6.setPlayerLocation(
        par2EntityPlayerMP.posX,
        par2EntityPlayerMP.posY,
        par2EntityPlayerMP.posZ,
        par2EntityPlayerMP.rotationYaw,
        par2EntityPlayerMP.rotationPitch);
    this.mcServer.getNetworkThread().addPlayer(var6);
    var6.sendPacketToPlayer(new Packet4UpdateTime(var4.getTotalWorldTime(), var4.getWorldTime()));

    if (this.mcServer.getTexturePack().length() > 0) {
      par2EntityPlayerMP.requestTexturePackLoad(
          this.mcServer.getTexturePack(), this.mcServer.textureSize());
    }

    Iterator var7 = par2EntityPlayerMP.getActivePotionEffects().iterator();

    while (var7.hasNext()) {
      PotionEffect var8 = (PotionEffect) var7.next();
      var6.sendPacketToPlayer(new Packet41EntityEffect(par2EntityPlayerMP.entityId, var8));
    }

    par2EntityPlayerMP.addSelfToInternalCraftingInventory();
  }