net.minecraftforge.fml.common.Loader Java Examples
The following examples show how to use
net.minecraftforge.fml.common.Loader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassDiscoverer.java From CodeChickenCore with MIT License | 6 votes |
private void findClasspathMods() { List<ModContainer> mods = Loader.instance().getActiveModList(); HashSet<String> searched = new HashSet<String>(); for (ModContainer mod : mods) { File source = mod.getSource(); if(source == null || searched.contains(source.getAbsolutePath())) continue; searched.add(source.getAbsolutePath()); if (source.isFile()) { CodeChickenCorePlugin.logger.debug("Found a mod container %s, examining for codechicken classes", source.getAbsolutePath()); try { readFromZipFile(source); } catch (Exception e) { CodeChickenCorePlugin.logger.error("Failed to scan " + source.getAbsolutePath() + ", the zip file is invalid", e); } } else if (source.isDirectory()) { CodeChickenCorePlugin.logger.debug("Found a minecraft related directory at %s, examining for codechicken classes", source.getAbsolutePath()); readFromDirectory(source, source); } } }
Example #2
Source File: Utils.java From SkyblockAddons with MIT License | 6 votes |
/** * Check if another mod is loaded. * * @param modId The modid to check. * @param version The version of the mod to match (optional). */ public boolean isModLoaded(String modId, String version) { boolean isLoaded = Loader.isModLoaded(modId); // Check for the modid... if (isLoaded && version != null) { // Check for the specific version... for (ModContainer modContainer : Loader.instance().getModList()) { if (modContainer.getModId().equals(modId) && modContainer.getVersion().equals(version)) { return true; } } return false; } return isLoaded; }
Example #3
Source File: GTRecipe.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public static void initIC2Circuits() { if (!Loader.isModLoaded(GTValues.MOD_ID_GTCX)) { if (GTConfig.general.addBasicCircuitRecipes) { int recipeId = IC2.config.getFlag(IC2_STEEL_MODE) ? 1921363733 : 1058514721; recipes.overrideRecipe("shaped_item.itemPartCircuit_" + recipeId, GTMaterialGen.getIc2(Ic2Items.electricCircuit, 1), "CCC", "RIR", "CCC", 'C', Ic2Items.insulatedCopperCable.copy(), 'R', GTValues.DUST_REDSTONE, 'I', GTValues.INPUT_INGOT_ELECTRIC); recipeId = IC2.config.getFlag(IC2_STEEL_MODE) ? -1911001323 : 1521116961; recipes.overrideRecipe("shaped_item.itemPartCircuit_" + recipeId, GTMaterialGen.getIc2(Ic2Items.electricCircuit, 1), "CRC", "CIC", "CRC", 'C', Ic2Items.insulatedCopperCable.copy(), 'R', GTValues.DUST_REDSTONE, 'I', GTValues.INPUT_INGOT_ELECTRIC); recipes.addRecipe(GTMaterialGen.getIc2(Ic2Items.electricCircuit, 2), "CCC", "III", "CCC", 'C', Ic2Items.insulatedCopperCable.copy(), 'I', GTValues.INPUT_INGOT_ELECTRIC); recipes.addRecipe(GTMaterialGen.getIc2(Ic2Items.electricCircuit, 2), "CIC", "CIC", "CIC", 'C', Ic2Items.insulatedCopperCable.copy(), 'I', GTValues.INPUT_INGOT_ELECTRIC); } if (GTConfig.general.addAdvCircuitRecipes) { recipes.overrideRecipe("shaped_item.itemPartCircuitAdv_-1948043137", GTMaterialGen.getIc2(Ic2Items.advancedCircuit, 1), "RGR", "LCL", "RGR", 'R', GTValues.DUST_REDSTONE, 'G', GTValues.DUST_GLOWSTONE, 'C', GTValues.CIRCUIT_BASIC, 'L', GTValues.INPUT_LAPIS_ANY); recipes.overrideRecipe("shaped_item.itemPartCircuitAdv_-205948801", GTMaterialGen.getIc2(Ic2Items.advancedCircuit, 1), "RLR", "GCG", "RLR", 'R', GTValues.DUST_REDSTONE, 'G', GTValues.DUST_GLOWSTONE, 'C', GTValues.CIRCUIT_BASIC, 'L', GTValues.INPUT_LAPIS_ANY); recipes.addRecipe(GTMaterialGen.getIc2(Ic2Items.advancedCircuit, 2), "RGR", "LCL", "RGR", 'R', GTValues.INPUT_INGOT_SILVER, 'G', GTValues.DUST_GLOWSTONE, 'C', GTValues.INPUT_CIRCUIT_BASIC_X2, 'L', GTValues.INPUT_LAPIS_ANY); recipes.addRecipe(GTMaterialGen.getIc2(Ic2Items.advancedCircuit, 2), "RLR", "GCG", "RLR", 'R', GTValues.INPUT_INGOT_SILVER, 'G', GTValues.DUST_GLOWSTONE, 'C', GTValues.INPUT_CIRCUIT_BASIC_X2, 'L', GTValues.INPUT_LAPIS_ANY); } } }
Example #4
Source File: ModIdentifier.java From VanillaFix with MIT License | 6 votes |
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; }
Example #5
Source File: ModuleRegistry.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public void copyAllModules(File directory) { Map<String, ModContainer> modList = Loader.instance().getIndexedModList(); for (Map.Entry<String, ModContainer> entry : modList.entrySet()) { for (ModuleInstance module : modules) { InputStream stream = LibrarianLib.PROXY.getResource(entry.getKey(), "wizmodules/" + module.getNBTKey() + ".json"); if (stream == null) { Wizardry.LOGGER.error(" > SOMETHING WENT WRONG! Could not read module " + module.getNBTKey() + " from mod jar of '" + entry.getKey() + "'! Report this to the devs on Github!"); continue; } try { FileUtils.copyInputStreamToFile(stream, new File(directory + "/wizmodules/", module.getNBTKey() + ".json")); Wizardry.LOGGER.info(" > Module " + module.getNBTKey() + " copied successfully from mod jar."); } catch (IOException e) { e.printStackTrace(); } } } }
Example #6
Source File: FireRecipes.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public void copyAllRecipes(File directory) { Map<String, ModContainer> modList = Loader.instance().getIndexedModList(); for (Map.Entry<String, ModContainer> entry : modList.entrySet() ) { for (String recipeName : getResourceListing(entry.getKey(), "fire_recipes")) { if (recipeName.isEmpty()) continue; InputStream stream = LibrarianLib.PROXY.getResource(entry.getKey(), "fire_recipes/" + recipeName); if (stream == null) { Wizardry.LOGGER.fatal(" > SOMETHING WENT WRONG! Could not read recipe " + recipeName + " from mod jar of '" + entry.getKey() + "'! Report this to the devs on Github!"); continue; } try { FileUtils.copyInputStreamToFile(stream, new File(directory, recipeName)); Wizardry.LOGGER.info(" > Fire recipe " + recipeName + " copied successfully from mod jar."); } catch (IOException e) { e.printStackTrace(); } } } }
Example #7
Source File: ManaRecipes.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public void copyAllRecipes(File directory) { Map<String, ModContainer> modList = Loader.instance().getIndexedModList(); for (Map.Entry<String, ModContainer> entry : modList.entrySet() ) { for (String recipeName : getResourceListing(entry.getKey(), "fluid_recipes")) { if (recipeName.isEmpty()) continue; InputStream stream = LibrarianLib.PROXY.getResource(entry.getKey(), "fluid_recipes/" + recipeName); if (stream == null) { Wizardry.LOGGER.fatal(" > SOMETHING WENT WRONG! Could not read recipe " + recipeName + " from mod jar of '" + entry.getKey() + "'! Report this to the devs on Github!"); continue; } try { FileUtils.copyInputStreamToFile(stream, new File(directory, recipeName)); Wizardry.LOGGER.info(" > Mana recipe " + recipeName + " copied successfully from mod jar."); } catch (IOException e) { e.printStackTrace(); } } } }
Example #8
Source File: AddressHelper.java From malmo with MIT License | 6 votes |
/** Set the actual port used for mission control - not persisted, could be different each time the Mod is run. * @param port the port currently in use for mission control. */ static public void setMissionControlPort(int port) { if (port != AddressHelper.missionControlPort) { AddressHelper.missionControlPort = port; // Also update our metadata, for displaying to the user: ModMetadata md = Loader.instance().activeModContainer().getMetadata(); if (port != -1) md.description = "Talk to this Mod using port " + TextFormatting.GREEN + port; else md.description = TextFormatting.RED + "ERROR: No mission control port - check configuration"; // See if changing the port should lead to changing the login details: //AuthenticationHelper.update(MalmoMod.instance.getModPermanentConfigFile()); } }
Example #9
Source File: ExNihiloAdscensio.java From ExNihiloAdscensio with MIT License | 6 votes |
@EventHandler public static void init(FMLInitializationEvent event) { OreRegistry.loadJson(new File(configDirectory, "OreRegistry.json")); loadConfigs(); Recipes.init(); OreRegistry.doRecipes(); proxy.initOreModels(); proxy.registerColorHandlers(); FMLInterModComms.sendMessage("Waila", "register", "exnihiloadscensio.compatibility.CompatWaila.callbackRegister"); if (Loader.isModLoaded("theoneprobe") && Config.doTOPCompat) { CompatTOP.init(); } }
Example #10
Source File: ActionOpenModConfig.java From Custom-Main-Menu with MIT License | 6 votes |
@Override public void perform(Object source, GuiCustom parent) { for (ModContainer mod : Loader.instance().getModList()) { if (mod.getModId().equals(modid)) { IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(mod); if (guiFactory != null) { GuiScreen newScreen = guiFactory.createConfigGui(parent); Minecraft.getMinecraft().displayGuiScreen(newScreen); } } } }
Example #11
Source File: GTJei.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
public static void initEntries() { GTJeiHandler.addEntry(new GTJeiEntry(GTTileCentrifuge.RECIPE_LIST, GTBlocks.tileCentrifuge, GTGuiMachine.GTIndustrialCentrifugeGui.class, 78, 24, 20, 18)); if (!Loader.isModLoaded(GTValues.MOD_ID_GTCX)){ GTJeiHandler.addEntry(new GTJeiEntry(GTTileMultiFusionReactor.RECIPE_LIST, GTBlocks.tileFusionReactor, GTGuiMachine.GTFusionComputerGui.class, 110, 34, 25, 17)); } }
Example #12
Source File: ConfigStorage.java From OpenModsLib with MIT License | 5 votes |
public void register(Configuration value) { ModContainer mod = Loader.instance().activeModContainer(); Preconditions.checkNotNull(mod, "Can't register outside initialization"); final String modId = mod.getModId(); configs.put(modId, value); }
Example #13
Source File: ModNotLoadedPredicate.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@Override public boolean getResult(List<String> arguments) { for (String modId : arguments) { if (Loader.isModLoaded(modId)) return false; } return true; }
Example #14
Source File: BackpackRegistry.java From WearableBackpacks with MIT License | 5 votes |
/** Registers a backpack to randomly spawn on the specified entity. * Must be called after registerEntity, in pre-initialization phase (or before). * * @param entityID The entity to register to spawn with this backpack. * * @param entryID String uniquely identifying this entry for this entity. * For example "wearblebackpacks:default". * @param backpack Backpack item ID to spawn on the entity. * For example "wearablebackpacks:backpack". * @param chance Chance in 1 out of X. For example 100 = 1% and 1000 = 0.1%. * @param lootTable Loot table for the backpack when spawned on this mob (if any). * @param colorRange A range of colors to spawn the backpack with, or null if default. **/ public static void registerBackpack(String entityID, String entryID, String backpack, int chance, String lootTable, ColorRange colorRange) { if (entityID == null) throw new NullPointerException("entityID must not be null"); if (entryID == null) throw new NullPointerException("entryID must not be null"); BackpackEntityEntry entityEntry = getDefaultEntityEntry(entityID); if (entityEntry == null) new IllegalStateException("entityID '" + entityID + "' has not been registered yet"); if (entityEntry._backpackEntries.stream().anyMatch(e -> e.id.equals(entryID))) throw new IllegalArgumentException("entryID '" + entryID + "' has already been used for entityID '" + entityID + "'"); if (Loader.instance().getLoaderState().compareTo(LoaderState.PREINITIALIZATION) > 0) throw new IllegalStateException("Must be called during (or before) pre-initialization phase."); entityEntry._backpackEntries.add(new BackpackEntry(entryID, backpack, chance, lootTable, colorRange, true)); }
Example #15
Source File: BackpackRegistry.java From WearableBackpacks with MIT License | 5 votes |
/** Registers an entity as possible backpack carrier, meaning * they'll get constructed with an IBackpack capability. * Must be called in pre-initialization phase (or before). */ public static void registerEntity(String entityID, RenderOptions renderOptions) { if (entityID == null) throw new NullPointerException("entityID must not be null"); if (getDefaultEntityEntry(entityID) != null) throw new IllegalArgumentException("entityID '" + entityID + "' has already been registered"); if (Loader.instance().getLoaderState().compareTo(LoaderState.PREINITIALIZATION) > 0) throw new IllegalStateException("Must be called during (or before) pre-initialization phase."); _defaultEntities.add(new BackpackEntityEntry(entityID, renderOptions, new ArrayList<>(), true)); }
Example #16
Source File: ManaRecipes.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public static String[] getResourceListing(String mod, String path) { List<String> all = Lists.newArrayList(); if (CraftingHelper.findFiles(Loader.instance().getIndexedModList().get(mod), "assets/" + mod + "/" + path, null, (root, full) -> all.add(root.relativize(full).toString()), false, false)) return all.toArray(new String[0]); return new String[0]; }
Example #17
Source File: WorldGenLoader.java From Sakura_mod with MIT License | 5 votes |
@SubscribeEvent public void HotSpringGen(Decorate event) { if(Loader.isModLoaded("tfc")) return; BlockPos pos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8); BlockPos newPos = WorldUtil.findGround(event.getWorld(),pos, true, false, true); Biome biome = event.getWorld().getBiome(pos); if (newPos != null&&event.getWorld().provider instanceof WorldProviderSurface&&biome != Biomes.DESERT && biome != Biomes.DESERT_HILLS && event.getRand().nextFloat() < SakuraConfig.hotspring_weight / 10000.0F) { new WorldGenHotSpring().generate(event.getWorld(), event.getRand(), newPos); } }
Example #18
Source File: ManifestHandler.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public void loadNewInternalManifest(String... categories) { Map<String, ModContainer> modList = Loader.instance().getIndexedModList(); for (Map.Entry<String, ModContainer> entry : modList.entrySet()) { for (String category : categories) { try { for (String fileName : ManaRecipes.getResourceListing(entry.getKey(), category)) { if (fileName.isEmpty()) continue; InputStream stream = LibrarianLib.PROXY.getResource(entry.getKey(), category + "/" + fileName); if (stream == null) { Wizardry.LOGGER.error(" > SOMETHING WENT WRONG! Could not read " + fileName + " in " + category + " from mod jar! Report this to the devs on Github!"); continue; } try (BufferedReader br = new BufferedReader(new InputStreamReader(stream, Charset.defaultCharset()))) { StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { sb.append(line); sb.append('\n'); } addItemToManifest(category, entry.getKey(), Files.getNameWithoutExtension(fileName), sb.toString().hashCode() + ""); } } } catch (IOException e) { e.printStackTrace(); } } } }
Example #19
Source File: PlatformCommand.java From YUNoMakeGoodMap with Apache License 2.0 | 5 votes |
protected List<ResourceLocation> getPlatforms() { if (platforms.size() == 0) { for (ModContainer mc : Loader.instance().getModList()) { File src = mc.getSource(); if (src == null) continue; InputStream is = getClass().getResourceAsStream("/assets/" + mc.getModId() + "/structures/sky_block_platforms.txt"); if (is == null) continue; try { for (String line : CharStreams.readLines(new InputStreamReader(is))) { if (getClass().getResourceAsStream("/assets/" + mc.getModId() + "/structures/" + line + ".nbt") != null) platforms.add(new ResourceLocation(mc.getModId(), line)); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } for (File f : YUNoMakeGoodMap.instance.getStructFolder().listFiles()) { if (!f.isFile() || !f.getName().endsWith(".nbt")) continue; platforms.add(new ResourceLocation("/config/", f.getName().substring(0, f.getName().length() - 4))); } } return platforms; }
Example #20
Source File: CommonProxy.java From Moo-Fluids with GNU General Public License v3.0 | 5 votes |
@Override public void registerPlugins() { if (Loader.isModLoaded("waila")) { WailaPlugin.init(); } if (Loader.isModLoaded("theoneprobe")) { TheOneProbePlugin.init(); } }
Example #21
Source File: TofuCompat.java From TofuCraftReload with MIT License | 5 votes |
public static void preInit() { if (Loader.isModLoaded("tconstruct")) { TConstructCompat.preInit(); } if (Loader.isModLoaded("flammpfeil.slashblade")){ SlashBlade.InitEventBus.register(new SlashBladeCompat()); } if (Loader.isModLoaded("tfc")) { TFCCompat.preInit(); } }
Example #22
Source File: ExNihiloAdscensio.java From ExNihiloAdscensio with MIT License | 5 votes |
@EventHandler public static void postInit(FMLPostInitializationEvent event) { if (Loader.isModLoaded("tconstruct") && Config.doTICCompat) { CompatTConstruct.postInit(); } if (Loader.isModLoaded("EnderIO") && Config.doEnderIOCompat) { CompatEIO.postInit(); } }
Example #23
Source File: ItemSignals.java From Signals with GNU General Public License v3.0 | 5 votes |
public static void addTooltip(ItemStack stack, World world, List<String> curInfo){ String info = "signals.tooltip." + stack.getItem().getUnlocalizedName(); String translatedInfo = I18n.format(info); if(!translatedInfo.equals(info)) { if(Signals.proxy.isSneakingInGui()) { translatedInfo = TextFormatting.AQUA + translatedInfo; if(!Loader.isModLoaded("IGWMod")) translatedInfo += " \\n \\n" + I18n.format("signals.tooltip.assistIGW"); curInfo.addAll(SignalsUtils.convertStringIntoList(translatedInfo, 60)); } else { curInfo.add(TextFormatting.AQUA + I18n.format("signals.gui.tooltip.sneakForInfo")); } } }
Example #24
Source File: JEIIntegrationManager.java From NotEnoughItems with MIT License | 5 votes |
public static String proxyCallback() { if (Loader.isModLoaded("jei")) { jeiLoaded = true; return JEIProxy.class.getName(); } jeiLoaded = false; return DummyProxy.class.getName(); }
Example #25
Source File: ClassDiscoverer.java From CodeChickenCore with MIT License | 5 votes |
public ClassDiscoverer(IStringMatcher matcher, Class<?>... superclasses) { this.matcher = matcher; this.superclasses = new String[superclasses.length]; for (int i = 0; i < superclasses.length; i++) this.superclasses[i] = superclasses[i].getName().replace('.', '/'); classes = new ArrayList<Class<?>>(); modClassLoader = (ModClassLoader) Loader.instance().getModClassLoader(); }
Example #26
Source File: ProductionLine.java From Production-Line with MIT License | 5 votes |
@Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { isIC2Loaded = Loader.isModLoaded("IndustrialCraft 2"); setupMeta(); PLConfig.init(event.getSuggestedConfigurationFile()); PLEntity.init(); proxy.preInit(); }
Example #27
Source File: AdvancedRocketry.java From AdvancedRocketry with MIT License | 5 votes |
@EventHandler public void serverStarted(FMLServerStartedEvent event) { for (int dimId : DimensionManager.getInstance().getLoadedDimensions()) { DimensionProperties properties = DimensionManager.getInstance().getDimensionProperties(dimId); if(!properties.isNativeDimension && properties.getId() == zmaster587.advancedRocketry.api.Configuration.MoonId && !Loader.isModLoaded("GalacticraftCore")) { properties.isNativeDimension = true; } } }
Example #28
Source File: RecipeLoader.java From TofuCraftReload with MIT License | 5 votes |
public static void Init() { registerCompressorRecipes(); registerCrasherRecipes(); registerAggregatorRecipe(); if (Loader.isModLoaded("crafttweaker")) { doDelayTask(); } actions = null; }
Example #29
Source File: ModUtil.java From AgriCraft with MIT License | 5 votes |
/** * Finds the mod container for the mod with the given mod id. * * @param modId The id of the mod of the container to search for. * @return The container associated with the mod of the given id, or the empty optional. */ @Nonnull public static Optional<ModContainer> resolveModContainer(@Nullable String modId) { return Loader.instance() .getActiveModList() .stream() .filter(c -> Objects.equals(modId, c.getModId())) .findFirst(); }
Example #30
Source File: SakuraRecipeRegister.java From Sakura_mod with MIT License | 5 votes |
public static void Init() { barrelRegister(); furnaceRegister(); L2ISRegister(); mortarRegister(); potRegister(); if (Loader.isModLoaded("crafttweaker")) doDelayTask(); actions = null; }