Java 从哪里开始创建 Minecraft 客户端 mod

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22739920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 17:35:47  来源:igfitidea点击:

Where to start with creating Minecraft client mods

javaeclipseminecraftminecraft-forge

提问by zfb

I've looked all over the net and YouTube and for some reason this is some top secret information or something but I'm trying to find out where to get started on making a Minecraft client mod, preferably something that can be put into a pack like feed the beast or technicpack for simplicity for users but either way is fine.

我浏览了整个网络和 YouTube,出于某种原因,这是一些绝密信息或其他内容,但我试图找出从哪里开始制作 Minecraft 客户端 mod,最好是可以打包的东西像喂野兽或技术包一样为用户简单起见,但无论哪种方式都很好。

How would I go about creating a mod? I'm familiar with eclipse and java programming itself but I don't know where to start writing a plugin.

我将如何创建一个模组?我熟悉 eclipse 和 java 编程本身,但我不知道从哪里开始编写插件。

I've tried setting up Minecraft Forge but for some reason it is so incredibly confusing and very messy. can't I just include some Minecraft library, start with a simple boilerplate and go from there? (Like developing for Bukkit)

我试过设置 Minecraft Forge,但出于某种原因,它是如此令人难以置信的混乱和非常混乱。我不能只包含一些 Minecraft 库,从一个简单的样板开始,然后从那里开始吗?(比如为 Bukkit 开发)

采纳答案by zfb

Choosing a modding method

选择修改方法

When creating minecraft client mods my research has found that different methods of creating mods. of the choices listed here, they have different perks:

在创建 minecraft 客户端 mod 时,我的研究发现了创建 mod 的不同方法。在此处列出的选择中,它们有不同的好处:

  • Source modding: Confusing to install mods, difficult to develop for, highest probability of breaking (especially after an update), but allows for the most features to be added.
  • ModLoader: Easier to use, limited features, not used often, unable to find support?
  • Minecraft Forge: Slightly more difficult to develop, more extendable, large API, easy to install mods, frequently used (FTB, Technic)
  • 模组:安装模组容易混淆,难以开发,破坏概率最高(尤其是更新后),但允许添加最多的功能。
  • ModLoader:更容易使用,功能有限,不经常使用,找不到支持?
  • Minecraft Forge:开发难度稍大,可扩展性更强,API 大,易于安装模组,经常使用(FTB,技术)

Minecraft Forge is probably one of the better options as of right now (March 2014) so here is a short intro to getting started:

Minecraft Forge 可能是目前(2014 年 3 月)更好的选择之一,因此这里是入门的简短介绍:

Setting up Minecraft Forge with Eclipse (Mac & PC)

使用 Eclipse 设置 Minecraft Forge(Mac 和 PC)

  1. Download & install Java Development Kit 7(Also works w/ JDK 8, but not JDK 9+)
  2. Download & install eclipse(or other Java IDE such as IntelliJ, etc.)
  3. Download Src (MDK)files of Minecraft Forgefor the version of Minecraft you want to develop. (I Suggest Recommended)
  4. Extract the files to a folder of your choosing (ex. /Library/Java/). Windows:Shift + Right Clickinto the white space of the folder and select "Open command window here" OR for Mac: open Terminal and navigate to the directory of the extracted files.
  5. Run this command. Windows:gradlew setupDecompWorkspaceOR Mac:./gradlew setupDecompWorkspace
  6. If previous command finishes successfully, run the following. Windows:gradlew eclipseOR Mac:./gradlew eclipse(Note: You can substitute the name of another IDE. Ex. gradlew idea)
  7. Open Eclipse. If this is your first timeusing eclipse you will get a popup saying "Select a workspace". If this is the case, browse to the extracted files, select the "eclipse" folder and press "OK". If this is NOT your first timeusing eclipse, go to File > Switch Workspace > other...and select the eclipse folder inside the folder where you extracted the forge files.
  8. That's all, you should now have a forge environment ready to go to start creating mods.
  1. 下载并安装Java Development Kit 7(也适用于 JDK 8,但不适用于 JDK 9+)
  2. 下载并安装eclipse(或其他 Java IDE,如 IntelliJ 等)
  3. 为您要开发的 Minecraft 版本下载Minecraft Forge 的Src (MDK)文件。(我建议推荐
  4. 将文件解压缩到您选择的文件夹(例如/Library/Java/)。Windows:Shift + 右键单击文件夹的空白区域并选择“在此处打开命令窗口”或对于Mac:打开终端并导航到解压缩文件的目录。
  5. 运行此命令。Windows:gradlew setupDecompWorkspaceMac:./gradlew setupDecompWorkspace
  6. 如果上一个命令成功完成,请运行以下命令。Windows:gradlew eclipseMac:(./gradlew eclipse注意:您可以替换另一个 IDE 的名称。例如gradlew idea
  7. 打开日食。如果这是您第一次使用 eclipse,您会看到一个弹出窗口,上面写着“选择一个工作区”。如果是这种情况,请浏览到提取的文件,选择“eclipse”文件夹并按“OK”。如果这不是您第一次使用 eclipse,请转至文件 > 切换工作区 > 其他...,然后在提取伪造文件的文件夹中选择 eclipse 文件夹。
  8. 就是这样,您现在应该有一个准备好开始创建模组的锻造环境。

Getting forge to work the way you would expect it to

让 Forge 以您期望的方式工作

    There are no sounds playing in minecraft?

    我的世界没有声音?

  • Go into the eclipse directory and copy the "assets" folder and paste it up one directory (where gradlew.bat is).
  • 进入 eclipse 目录并复制“assets”文件夹并将其粘贴到一个目录(gradlew.bat 所在的目录)。

    I didn't get a login screen so my username isn't there

    我没有得到登录屏幕,所以我的用户名不存在

  • Single-Player
    To add your username go into eclipse and navigate to "Run > Run Configurations.. > java Application > client > Arguments" and under "Program arguments:" add the following replacing "steve" with your username --username steve.
  • Multi-Player
    For testing in a multi-player you mustauthenticate yourself or the server wont allow you on. You do basically the same thing as you would in single player but instead of '--username steve' you would replace it with your Minecraft account email address and add your password as so replacing 312mine!with your own password --username [email protected] --password 321mine!.
    noteYou can use the authenticated version in single-player as well but it's not necessary.
  • 单人游戏
    要添加您的用户名,请进入 eclipse 并导航到“Run > Run Configurations.. > java Application > client > Arguments”并在“Program arguments:”下添加以下内容,将“steve”替换为您的用户名--username steve
  • 多人游戏
    要在多人游戏中进行测试,您必须对自己进行身份验证,否则服务器将不允许您进入。你做的事情基本上和你在单人游戏中做的一样,但你会用你的 Minecraft 帐户电子邮件地址替换它,而不是“--username steve”,并添加你的密码,然后312mine!用你自己的密码替换--username [email protected] --password 321mine!
    note您也可以在单人游戏中使用经过身份验证的版本,但这不是必需的。

Helpful resources

有用的资源



(1) Links Curtousy of Dylan Meeus

(1) Dylan Meeus 的链接 Curtousy