介绍
MJUtils
A set of tools to simplify writing mods. It contains a modular system for initialization of mods and a system of configurations by annotations.
The source code contains the documentation.
If you are using ResearchItemCopy, you must add the following dependency: “required-after:Thaumcraft;”.
You can send a pull request if you find grammar errors.
Modular system examples
Add module and configuration handlers to the main mod class:
package your.path;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLConstructionEvent;
import mjaroslav.mcmods.mjutils.module.ModuleSystem;
import mjaroslav.mcmods.mjutils.module.AnnotationBasedConfiguration;
@Mod(modid = "your_modid", version = "0.0.0", name = "Module example mod")
public class ModExample {
// Handler for annotation configurations.
private static AnnotationBasedConfiguration config;
// Handler for work with modules.
private static ModuleSystem modSys;
@EventHandler
public void construct(FMLConstructionEvent event) {
// The second argument is logger.
config = new AnnotationBasedConfiguration("your_modid", null);
// The third argument is a proxy.
modSys = new ModuleSystem(MODID, config, null);
// Find all modules and create their instances..
modSys.initSystem(event);
}
// DON'F FORGET CALL ALL INITIALIZATION METHODS:
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
modSys.preInit(event);
}
@EventHandler
public void init(FMLInitializationEvent event) {
modSys.init(event);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
modSys.postInit(event);
}
}
Now you can create simple module:
package your.path;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
//import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import mjaroslav.mcmods.mjutils.module.Modular;
import mjaroslav.mcmods.mjutils.module.Module;
// All classes with Module annotation must implement the Modular
// interface.
@Module("your_modid")
public class ModuleExample implements Modular {
@Override
public void preInit(FMLPreInitializationEvent event) {
System.out.println("Hi! I'm in pre init!");
}
// All interface methods that can be neglected contain the default
// implementation: you can inherit them only when necessary.
//
// @Override
// public void init(FMLInitializationEvent event) {
// System.out.println("I'm ignored :c");
// }
@Override
public void postInit(FMLPostInitializationEvent event) {
System.out.println("Hi! I'm in post init!");
}
}
An example of creating an annotation configuration:
package your.path;
import mjaroslav.mcmods.mjutils.module.ConfigurationCategory;
import mjaroslav.mcmods.mjutils.module.ConfigurationProperty;
@ConfigurationCategory(modID = "your_modid", name = ConfigurationCategory.GENERAL_NAME,
comment = ConfigurationCategory.GENERAL_COMMENT)
public class CategoryGeneral {
@ConfigurationCategory(name = "subcategory")
public static class SubCategory {
@ConfigurationProperty(defaultBoolean = true)
public static boolean test;
@ConfigurationProperty(name = "test2", defaultInt = 1)
public static int test1;
}
@ConfigurationProperty(defaultDouble = Math.E)
public static double e;
}
Use the documentation to find out more info about library usages.
常见问题
MJUtils 支持哪些 Minecraft 版本?
MJUtils 支持 Minecraft Java 版 1.7.10,可用的加载器:Forge。下载时注意选择和你游戏版本一致的文件。
MJUtils 怎么安装?
先用 PCL2 或 HMCL 启动器安装对应版本的 Forge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。
MJaroslav 的其他作品
查看全部 →ThaumOres
A small modification, additive Thaumcraft shards ore to the generation of the Nether, the End and bedrock layer of the Overworld.
Realistic Brewing Stand
Little logical fix (in render) of the brewing stand.
UnbreakEn
Enchantment that will save your instrument.
Villager Mantle Fix
A small modification that returns to villagers their mantles
评论
登录后评论和评分