在经过漫长的前言后,终于来到了最痛苦的一步了——配置MCP环境。
——引言
1.1.明确开发工具
IntelliJ IDEA 2022.2!
(经济条件不好的同学可以下载社区版)
下载链接:传送门
1.2.下载Forge MDK
1.2.1.什么是Forge MDK?
(摘自https://forums.minecraftforge.net/topic/33057-what-are-mdk-files/)
What are MDK files?
Warix
I tried to install 1504 version of minecraft forge and i get error after i started eclipse ( same as this guy http://www.minecraftforge.net/forum/index.php/topic,33216).
Warix
I just wondered what are these versions. ( 1502 works for me). I’m not sure is it supposed not to work , because i installed it same way as normal minecraft forge.
diesieben07
Yes, those are the “normal” source downloads. MDK = Mod Development Kit.
LexManos
Its just a rebrand of the src download, because it no longer {and hasnt for a long time} include forge’ s source/workspace. Just the basic tools setup.
So, its the same thing as the src.
简单来说,Minecraft Forge MDK 是指 Mod Development Kit。
1.2.2.下载Forge MDK
从Forge官网下载Forge MDK, 并尽可能采用推荐版本(笔者采用的是14.23.5.2860版本)本教程的所用开发操作都是基于此。
1.3.配置你的工作环境
解压你在1.2.2下载的压缩包,并尽量放置在纯英文路径下。
使用IDEA打开项目:
(本教程的目录如下:)
(本教程所使用的文件是直接从Github上已上传的项目中克隆下来的,所以会有“提交”视图)
在进入项目后,IDEA会自动进行构建。
当出现BUILD SUCCESSFUL
的字样时,说明你已经搭建成功了!
当然,在构建完成后,你会发现在 java
目录下存在一个com.example.examplemod
的包,那是测试用的,删掉即可。
⚠注意⚠
为了不给以后的开发工作带来麻烦,建议先修改build.gradle
文件!
修改如下:
build.gradle(摘录)
version = '0.0.1-Programming_Debug'
group = 'com.rycb.etch'
archivesBaseName = 'EasyTech_Build'
这里的version
是指你的Mod版本号(可以参照Github推荐的语义化标准),group
表示组id,建议使用Java包命名规范(用户域名的倒序),比如你的项目所在网站为www.example.com
,那么包名建议为:
com.example.<your_username>.<your_project_name>
比如本教程的所有代码都在com.rycb.etech
下。
当然,也有直接以Mod名称作为包名的,等等。
总之,包的命名以不冲突为前提。
archivesBaseName
表示生成的Mod包(.jar文件)所使用的名称, Mod包使用的文件名是“名称+横线+版本号.jar”,这里就是EasyTech_Build-0.0.1-Programming_Debug.jar
。
注:
因为资源大多在国外,所以可能要等待一段漫长的时间。建议在网络状况好的地方运行此命令,以配置开发环境,并获取反编译过的Minecraft源代码。如果有条件,建议使用国外的代理。
2022/8/1补充
建议在build.gradle
的末尾添加下面这句话,以防止中文乱码:
[compileJava, compileTestJava]
*.options*.encoding = 'UTF-8'