Ejemplo n.º 1
0
 public TConstruct() {
   if (Loader.isModLoaded("Natura")) {
     log.info("Natura, what are we going to do tomorrow night?");
     LogManager.getLogger("Natura").info("TConstruct, we're going to take over the world!");
   } else {
     log.info("Preparing to take over the world");
   }
 }
Ejemplo n.º 2
0
  public static void register() {

    if (Loader.isModLoaded("VersionChecker")) {
      final NBTTagCompound nbt = new NBTTagCompound();
      nbt.setString("curseProjectName", CURSE_PROJECT_NAME);
      nbt.setString("curseFilenameParser", MOD_NAME_TEMPLATE);
      FMLInterModComms.sendRuntimeMessage(Module.MOD_ID, "VersionChecker", "addVersionCheck", nbt);
    }

    if (ModOptions.getOnlineVersionChecking()) {
      final VersionCheck test = new VersionCheck();
      MinecraftForge.EVENT_BUS.register(test);
      new Thread(test).start();
    }
  }
Ejemplo n.º 3
0
 public static boolean IsAvailable() {
   return Loader.isModLoaded("customnpcs");
 }
Ejemplo n.º 4
0
  /**
   * Fix IDs improperly allocated by early versions of the registry, best-effort.
   *
   * <p>Items sharing the same ID with a block, but not sharing the same registry name will be
   * mapped to an unused id. Losing items instead of blocks should minimize the damage.
   *
   * @param dataList List containing the IDs to fix
   */
  public static void fixBrokenIds(
      GameDataSnapshot.Entry blocks, GameDataSnapshot.Entry items, Set<Integer> blockedIds) {
    BitSet availabilityMap = new BitSet(MAX_ITEM_ID + 1);

    // reserve all ids occupied by blocks
    for (Entry<String, Integer> entry : blocks.ids.entrySet()) {
      availabilityMap.set(entry.getValue());
    }

    Set<Integer> newBlockedIds = new HashSet<Integer>();
    Set<String> itemsToRemove = new HashSet<String>();
    Map<String, Integer> itemsToRelocate = new HashMap<String, Integer>();

    // check all ids occupied by items
    for (Entry<String, Integer> entry : items.ids.entrySet()) {
      int oldId = entry.getValue();
      String name = entry.getKey();
      Item item = getMain().iItemRegistry.getRaw(name);
      boolean blockThisId = false; // block oldId unless it's used by a block

      if (item == null) // item no longer available
      {
        // can't fix items without reliably checking if they are ItemBlocks
        FMLLog.warning(
            "Item %s (old id %d) is no longer available and thus can't be fixed.", name, oldId);
        itemsToRemove.add(name);
        blockThisId = true;
      } else if (item instanceof ItemBlock) {
        if (blocks.ids.containsKey(name)) // the item was an ItemBlock before
        {
          int blockId = blocks.ids.get(name);

          if (blockId != oldId) // mis-located ItemBlock
          {
            // relocate to the matching block
            FMLLog.warning(
                "ItemBlock %s (old id %d) doesn't have the same id as its block (%d).",
                name, oldId, blockId);
            itemsToRelocate.put(name, blockId);
            blockThisId = true;
          } else // intact ItemBlock
          {
            availabilityMap.set(oldId); // occupy id
          }
        } else // the item hasn't been an ItemBlock before, but it's now
        {
          // can't fix these, drop them
          FMLLog.warning(
              "Item %s (old id %d) has been migrated to an ItemBlock and can't be fixed.",
              name, oldId);
          itemsToRemove.add(name);
          blockThisId = true;
        }
      } else if (availabilityMap.get(oldId)) // normal item, id is already occupied
      {
        // remove the item mapping
        FMLLog.warning(
            "Item %s (old id %d) is conflicting with another block/item and can't be fixed.",
            name, oldId);
        itemsToRemove.add(name);
      } else // intact Item
      {
        availabilityMap.set(oldId); // occupy id
      }

      // handle blocking the id from future use if possible (i.e. not used by a conflicting block)
      // blockThisId requests don't modify availabilityMap, it could only be set by a block (or
      // another item, which isn't being handled)
      if (blockThisId && !availabilityMap.get(oldId)) {
        // there's no block occupying this id, thus block the id from future use
        // as there may still be ItemStacks in the world referencing it
        newBlockedIds.add(oldId);
        availabilityMap.set(oldId);
      }
    }

    if (itemsToRemove.isEmpty() && itemsToRelocate.isEmpty()) return; // nothing to do

    // confirm
    String text =
        "Forge Mod Loader detected that this save is damaged.\n\n"
            + "It's likely that an automatic repair can successfully restore\n"
            + "most of it, except some items which may get swapped with others.\n\n"
            + "A world backup will be created as a zip file in your saves\n"
            + "directory automatically.\n\n"
            + itemsToRemove.size()
            + " items need to be removed.\n"
            + itemsToRelocate.size()
            + " items need to be relocated.";

    boolean confirmed = StartupQuery.confirm(text);
    if (!confirmed) StartupQuery.abort();

    // confirm missing mods causing item removal
    Set<String> modsMissing = new HashSet<String>();

    for (String name : itemsToRemove) {
      modsMissing.add(name.substring(0, name.indexOf(':')));
    }

    for (Iterator<String> it = modsMissing.iterator(); it.hasNext(); ) {
      String mod = it.next();

      if (mod.equals("minecraft") || Loader.isModLoaded(mod)) it.remove();
    }

    if (!modsMissing.isEmpty()) {
      text =
          "Forge Mod Loader detected that "
              + modsMissing.size()
              + " mods are missing.\n\n"
              + "If you continue items previously provided by those mods will be\n"
              + "removed while repairing this world save.\n\n"
              + "Missing mods:\n";

      for (String mod : modsMissing) text += mod + "\n";

      confirmed = StartupQuery.confirm(text);
      if (!confirmed) StartupQuery.abort();
    }

    // backup
    try {
      String skip = System.getProperty("fml.doNotBackup");
      if (skip == null || !"true".equals(skip)) {
        ZipperUtil.backupWorld();
      } else {
        for (int x = 0; x < 10; x++)
          FMLLog.severe("!!!!!!!!!! UPDATING WORLD WITHOUT DOING BACKUP !!!!!!!!!!!!!!!!");
      }
    } catch (IOException e) {
      StartupQuery.notify("The world backup couldn't be created.\n\n" + e);
      StartupQuery.abort();
    }

    // apply fix
    for (String name : itemsToRemove) {
      FMLLog.warning("Removed Item %s, old id %d.", name, items.ids.remove(name));
    }

    for (Map.Entry<String, Integer> entry : itemsToRelocate.entrySet()) {
      int newId = entry.getValue();
      int oldId = items.ids.put(entry.getKey(), newId);
      FMLLog.warning("Remapped Item %s to id %d, old id %d.", entry.getKey(), newId, oldId);
    }

    blockedIds.addAll(newBlockedIds);
  }
Ejemplo n.º 5
0
/** @author canitzp */
public class Compat {

  public static boolean isTeslaLoaded = Loader.isModLoaded("tesla");
  public static boolean isRailcraftLoaded = Loader.isModLoaded("railcraft");
}
Ejemplo n.º 6
0
  @Mod.EventHandler
  public void onInit(FMLInitializationEvent event) {
    proxy.init();

    isForestryInstalled = Loader.isModLoaded("Forestry");
  }