Exemplo n.º 1
0
 @Override
 public byte[] generatePacket(Object... data) {
   ByteArrayDataOutput dat = ByteStreams.newDataOutput();
   Set<ModContainer> activeMods = FMLNetworkHandler.instance().getNetworkModList();
   dat.writeInt(activeMods.size());
   for (ModContainer mc : activeMods) {
     dat.writeUTF(mc.getModId());
   }
   dat.writeByte(FMLNetworkHandler.getCompatibilityLevel());
   return dat.toByteArray();
 }
Exemplo n.º 2
0
 public void registerGuiHandler(Object mod, IGuiHandler handler) {
   ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
   NetworkModHandler nmh = FMLNetworkHandler.instance().findNetworkModHandler(mc);
   if (nmh == null) {
     FMLLog.log(
         Level.FINE,
         "The mod %s needs to be a @NetworkMod to register a Networked Gui Handler",
         mc.getModId());
   } else {
     serverGuiHandlers.put(mc, handler);
   }
   clientGuiHandlers.put(mc, handler);
 }
Exemplo n.º 3
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)));
  }
Exemplo n.º 4
0
 void openRemoteGui(
     ModContainer mc, EntityPlayerMP player, int modGuiId, World world, int x, int y, int z) {
   IGuiHandler handler = serverGuiHandlers.get(mc);
   NetworkModHandler nmh = FMLNetworkHandler.instance().findNetworkModHandler(mc);
   if (handler != null && nmh != null) {
     Container container =
         (Container) handler.getServerGuiElement(modGuiId, player, world, x, y, z);
     if (container != null) {
       player.incrementWindowID();
       player.closeInventory();
       int windowId = player.currentWindowId;
       Packet250CustomPayload pkt = new Packet250CustomPayload();
       pkt.channel = "FML";
       pkt.data =
           FMLPacket.makePacket(Type.GUIOPEN, windowId, nmh.getNetworkId(), modGuiId, x, y, z);
       pkt.length = pkt.data.length;
       player.serverForThisPlayer.sendPacketToPlayer(pkt);
       player.craftingInventory = container;
       player.craftingInventory.windowId = windowId;
       player.craftingInventory.addCraftingToCrafters(player);
     }
   }
 }
Exemplo n.º 5
0
 public static Packet131ItemData getTinyPacket(Object var0, short var1, byte[] var2) {
   NetworkModHandler var3 = FMLNetworkHandler.instance().findNetworkModHandler(var0);
   return new Packet131ItemData((short) var3.getNetworkId(), var1, var2);
 }
Exemplo n.º 6
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);
  }