net.minecraftforge.fml.common.Loader.getModList()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中net.minecraftforge.fml.common.Loader.getModList()方法的一些代码示例,展示了Loader.getModList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Loader.getModList()方法的具体详情如下:
包路径:net.minecraftforge.fml.common.Loader
类名称:Loader
方法名:getModList

Loader.getModList介绍

暂无

代码示例

代码示例来源:origin: SquidDev-CC/plethora

public static Set<String> getContainingMods(File file) {
  Set<String> modIds = Sets.newHashSet();
  for (ModContainer container : Loader.instance().getModList()) {
    if (container.getSource().equals(file)) {
      modIds.add(container.getModId());
    }
  }
  return modIds;
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
protected @Nonnull Map<String, Configuration> getConfigurations() {
 Map<String, Configuration> result = new HashMap<>();
 for (ModContainer modContainer : Loader.instance().getModList()) {
  Object mod = modContainer.getMod();
  if (mod instanceof IEnderIOAddon) {
   Configuration configuration = ((IEnderIOAddon) mod).getConfiguration();
   if (configuration != null) {
    result.put(modContainer.getModId(), configuration);
   }
  }
 }
 return result;
}

代码示例来源:origin: OpenMods/OpenData

private void collectFilesFromModContainers(ASMDataTable table) {
  final File dummyEntry = new File("minecraft.jar"); // dummy entry comes from MCP container
  for (ModContainer c : Loader.instance().getModList()) {
    File f = c.getSource();
    if (f != null && !f.equals(dummyEntry) && !f.isDirectory()) {
      FileMeta meta = getOrCreateData(f);
      meta.mods.put(c.getModId(), new ModMeta(c));
    }
  }
}

代码示例来源:origin: TehNut/HWYLA

public static ModContainer findModContainer(String modID) {
    return containers.computeIfAbsent(modID, s -> {
      for (ModContainer container : Loader.instance().getModList())
        if (modID.equalsIgnoreCase(container.getModId()))
          return container;

      return Loader.instance().getMinecraftModContainer();
    });
  }
}

代码示例来源:origin: iLexiconn/LLibrary

for (ModContainer mod : Loader.instance().getModList()) {
  String modId = mod.getModId();
  try {

代码示例来源:origin: DimensionalDevelopment/VanillaFix

private static Map<File, Set<ModContainer>> makeModMap() {
  Map<File, Set<ModContainer>> modMap = new HashMap<>();
  for (ModContainer mod : Loader.instance().getModList()) {
    Set<ModContainer> currentMods = modMap.getOrDefault(mod.getSource(), new HashSet<>());
    currentMods.add(mod);
    try {
      modMap.put(mod.getSource().getCanonicalFile(), currentMods);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    modMap.remove(Loader.instance().getMinecraftModContainer().getSource()); // Ignore minecraft jar (minecraft)
    modMap.remove(Loader.instance().getIndexedModList().get("FML").getSource()); // Ignore forge jar (FML, forge)
  } catch (NullPointerException ignored) {
    // Workaround for https://github.com/MinecraftForge/MinecraftForge/issues/4919
  }
  return modMap;
}

代码示例来源:origin: SleepyTrousers/EnderIO

@SubscribeEvent(priority = EventPriority.LOW)
public static void registerAddonBlocks(@Nonnull RegistryEvent.Register<Block> event) {
 for (ModContainer modContainer : Loader.instance().getModList()) {
  Object mod = modContainer.getMod();
  if (mod instanceof IEnderIOAddon) {
   ((IEnderIOAddon) mod).injectBlocks(NullHelper.notnullF(event.getRegistry(), "RegistryEvent.Register<Block>.getRegistry()"));
  }
 }
}

代码示例来源:origin: iLexiconn/LLibrary

if (updateContainer != null) {
  final ModContainer[] modContainer = { null };
  Loader.instance().getModList().stream().filter(container -> container.getModId().equals(annotation.modid())).forEach(container -> modContainer[0] = container);

代码示例来源:origin: iLexiconn/LLibrary

@Mod.EventHandler
public void onPreInit(FMLPreInitializationEvent event) {
  if (!LLibrary.LLIBRARY_ROOT.exists()) {
    LLibrary.LLIBRARY_ROOT.mkdirs();
  }
  for (ModContainer mod : Loader.instance().getModList()) {
    ConfigHandler.INSTANCE.injectConfig(mod, event.getAsmData());
    NetworkHandler.INSTANCE.injectNetworkWrapper(mod, event.getAsmData());
  }
  LLibrary.CONFIG.load();
  LLibrary.PROXY.onPreInit();
}

代码示例来源:origin: RS485/LogisticsPipes

@Override
public boolean init() {
  List<ModContainer> modList = Loader.instance().getModList();
  for (ModContainer mod : modList) {
    if (mod.getModId().equals("StorageDrawers")) {
      try {
        VersionRange validVersions = VersionRange.createFromVersionSpec("[1.7.8,)");
        ArtifactVersion version = new DefaultArtifactVersion(mod.getVersion());
        return validVersions.containsVersion(version);
      } catch (InvalidVersionSpecificationException e) {
        return false;
      }
    }
  }
  return false;
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
@SubscribeEvent
public void onConfigChanged(@Nonnull OnConfigChangedEvent event) {
 if (event.getModID().equals(factory.getModid())) {
  Log.info("Updating config...");
  syncConfig();
  // also notify addons of the config change as we present their config values in our GUI
  for (ModContainer modContainer : Loader.instance().getModList()) {
   if (modContainer.getMod() instanceof IEnderIOAddon && !modContainer.getModId().equals(factory.getModid())) {
    MinecraftForge.EVENT_BUS.post(new OnConfigChangedEvent(modContainer.getModId(), null, event.isWorldRunning(), event.isRequiresMcRestart()));
   }
  }
 }
}

代码示例来源:origin: SleepyTrousers/EnderIO

final List<ModContainer> modList = Loader.instance().getModList();
ProgressManager.ProgressBar bar2 = ProgressManager.push("Mod", modList.size());
for (ModContainer modContainer : modList) {

相关文章