[CF4M教程]#1准备

访问CF4M文档

CF4M(Client Minecraft for Minecraft)是Minecraft的客户端框架可以它可以便捷的写Module,Setting,Command,Config.等等

导入

添加maven仓库

allprojects {
	repositories {
		maven { url 'https://maven.enaium.cn' }
	}
}

使用最新的CF4M 写这个文档的时候最新版是 1.8.1

dependencies {
	implementation 'cn.enaium.cf4m:cf4m:1.8.1'
}

Fabric 导入

如果您用的是Fabric请导入下面的

dependencies {
	modImplementation 'cn.enaium.cf4m:cf4m-fabric:1.8.1'
}

还需要您在fabric.mod.json文件里添加

"depends": {
    "cf4m": ">=1.8.1"
}

当然还需用在mods文件夹放入这个mod

使用

public void run() {
	
	CF4M.run(this);

	//参数1:当前的主类,参数2:客户端的目录(游戏目录/客户端名)
    // CF4M.run(this, Minecraft.getMinecraft().mcDataDir.toString() + "/" + name);
}

public void stop() {
    CF4M.stop();
}

在游戏的启动和停止的时候调用run

之后写的Module Command Config 等等都要和主类在同一包下

需要注意的是,如果您使用的是Mixin注入的方式也要这样做. mixins的包也不要和主类在同一个包下.

✔正确示范

cn.enaium.example
----client.主类
--------modules
--------commands
--------configs
--------...
----mixins

❌错误示范

cn.enaium.example
----client.主类
--------mixins
--------modules
--------commands
--------configs
--------...