本文整理了Java中net.minecraftforge.fml.common.Loader.getActiveModList()
方法的一些代码示例,展示了Loader.getActiveModList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Loader.getActiveModList()
方法的具体详情如下:
包路径:net.minecraftforge.fml.common.Loader
类名称:Loader
方法名:getActiveModList
暂无
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
public static boolean isModLoaded( final String modid )
{
try
{
// if this fails for some reason, try the other method.
return Loader.isModLoaded( modid );
}
catch( final Throwable ignored )
{
}
for( final ModContainer f : Loader.instance().getActiveModList() )
{
if( f.getModId().equals( modid ) )
{
return true;
}
}
return false;
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final List<ModContainer> mods = loader.getActiveModList();
代码示例来源:origin: raoulvdberge/refinedstorage
@Nullable
static String getModNameByModId(String modId) {
ModContainer container = Loader.instance().getActiveModList().stream()
.filter(m -> m.getModId().toLowerCase().equals(modId))
.findFirst()
.orElse(null);
return container == null ? null : container.getName();
}
代码示例来源:origin: TeamLapen/Vampirism
private String getStatsString() {
try {
String b = "?" +
"current=" +
URLEncoder.encode(currentVersion.trim(), "UTF-8") +
'&' +
"mc=" +
URLEncoder.encode(Loader.MC_VERSION, "UTF-8") +
'&' +
"count=" +
URLEncoder.encode("" + Loader.instance().getActiveModList().size(), "UTF-8") +
'&' +
"side=" +
(FMLCommonHandler.instance().getEffectiveSide().isClient() ? "client" : "server");
return b;
} catch (UnsupportedEncodingException e) {
return "";
}
}
代码示例来源:origin: Vazkii/Patchouli
public void init() {
List<ModContainer> mods = Loader.instance().getActiveModList();
Map<Pair<ModContainer, ResourceLocation>, String> foundBooks = new HashMap<>();
代码示例来源:origin: gegy1000/Terrarium
public List<Result<T>> discoverFiles(String dataRoot, String basePath) {
List<ModContainer> activeModList = Loader.instance().getActiveModList();
ProgressManager.ProgressBar bar = ProgressManager.push("Discovering files", activeModList.size());
List<Result<T>> discoveries = new ArrayList<>();
for (ModContainer mod : activeModList) {
bar.step(mod.getName());
String base = dataRoot + "/" + mod.getModId() + "/" + basePath;
CraftingHelper.findFiles(mod, base, root -> true, (root, path) -> {
Path relativePath = root.relativize(path);
if (!"json".equals(FilenameUtils.getExtension(path.toString())) || relativePath.getNameCount() > 1) {
return true;
}
String name = FilenameUtils.removeExtension(relativePath.toString()).replaceAll("\\\\", "/");
ResourceLocation key = new ResourceLocation(mod.getModId(), name);
try (BufferedReader reader = Files.newBufferedReader(path)) {
JsonObject rootObject = new JsonParser().parse(reader).getAsJsonObject();
discoveries.add(new Result<>(key, this.parser.apply(rootObject)));
} catch (JsonParseException e) {
Terrarium.LOGGER.error("Couldn't parse JSON for {}", key, e);
} catch (IOException e) {
Terrarium.LOGGER.error("Couldn't read JSON {} from {}", key, path, e);
}
return true;
}, false, false);
}
ProgressManager.pop(bar);
return discoveries;
}
代码示例来源:origin: Darkhax-Minecraft/Bookshelf
/**
* Get's the owning mod instance. If none is set, Bookshelf will attempt to auto-get it
* using Forge's loader.
*
* @return The owning mod's instance.
*/
public Object getModInstance () {
if (this.modInstance == null) {
Constants.LOG.error("Registry helper for " + this.modid + " requires a mod instance be set. Attempting to get instance with mod ID. Please ask the mod author to set this themselves.");
for (final ModContainer container : Loader.instance().getActiveModList()) {
if (this.modid.equalsIgnoreCase(container.getModId())) {
this.modInstance = container.getMod();
break;
}
}
}
return this.modInstance;
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
public static void loadRecipes() {
ModContainer awModContainer = Loader.instance().activeModContainer();
//noinspection ConstantConditions
loadRecipes(awModContainer, new File(AWCoreStatics.configPathForFiles + "research_recipes"), "");
Loader.instance().getActiveModList().forEach(m -> AWCraftingManager.loadRecipes(m, m.getSource(), "assets/" + m.getModId() + "/research_recipes"));
Loader.instance().setActiveModContainer(awModContainer);
}
代码示例来源:origin: Vazkii/Patchouli
List<ResourceLocation> foundEntries = new ArrayList<>();
List<ResourceLocation> foundTemplates = new ArrayList<>();
List<ModContainer> mods = Loader.instance().getActiveModList();
代码示例来源:origin: Vazkii/Patchouli
public static void preInit() {
MinecraftForge.EVENT_BUS.register(ChangeListener.class);
List<ModContainer> mods = Loader.instance().getActiveModList();
for(ModContainer container : mods)
setFlag("mod:" + container.getModId(), true);
setFlag("debug", Patchouli.debug);
updateFlags();
}
内容来源于网络,如有侵权,请联系作者删除!