我们本次来进行Minecraft 1.19.2 模组开发环境配置教程的介绍。

1.首先我们需要下载模组开发包:

1.19.2Forge MDK下载官网

找到Mdk的按钮点击并下载即可。

你也可以通过百度网盘下载该Mdk,下载链接附文末。

2.下载后解压该开发包,并用Idea打开:

之后等待系统自动构建环境:

出现Build Successful则说明项目成功构建了。

打开文件 -> 项目结构 -> 修改SDK版本为Java17 -> 应用

打开文件 -> 设置 -> 构建,执行,部署 -> 修改Gradle JVM

3.打开build.gradle文件,修改group字段和archivesBaseName字段:

plugins {id 'eclipse'id 'maven-publish'id 'net.minecraftforge.gradle' version '5.1.+'
}version = '1.0'
//修改为com.名称.你的模组名称
group = 'com.joy187.re8joymod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
//修改为你的模组名称,只允许小写
archivesBaseName = 're8joymod'// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {// The mappings can be changed at any time and must be in the following format.// Channel:   Version:// official   MCVersion             Official field/method names from Mojang mapping files// parchment  YYYY.MM.DD-MCVersion  Open community-sourced parameter names and javadocs layered on top of official//// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md//// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge// Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started//// Use non-default mappings at your own risk. They may not always work.// Simply re-run your setup task after changing the mappings to update your workspace.mappings channel: 'official', version: '1.19.2'// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.// Default run configurations.// These can be tweaked, removed, or duplicated as needed.runs {client {workingDirectory project.file('run')// Recommended logging data for a userdev environment// The markers can be added/remove as needed separated by commas.// "SCAN": For mods scan.// "REGISTRIES": For firing of registry events.// "REGISTRYDUMP": For getting the contents of all registries.property 'forge.logging.markers', 'REGISTRIES'// Recommended logging level for the console// You can set various levels here.// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levelsproperty 'forge.logging.console.level', 'debug'// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.property 'forge.enabledGameTestNamespaces', 're8joymod'mods {re8joymod {source sourceSets.main}}}server {workingDirectory project.file('run')property 'forge.logging.markers', 'REGISTRIES'property 'forge.logging.console.level', 'debug'property 'forge.enabledGameTestNamespaces', 're8joymod'mods {re8joymod {source sourceSets.main}}}// This run config launches GameTestServer and runs all registered gametests, then exits.// By default, the server will crash when no gametests are provided.// The gametest system is also enabled by default for other run configs under the /test command.gameTestServer {workingDirectory project.file('run')property 'forge.logging.markers', 'REGISTRIES'property 'forge.logging.console.level', 'debug'property 'forge.enabledGameTestNamespaces', 're8joymod'mods {re8joymod {source sourceSets.main}}}data {workingDirectory project.file('run')property 'forge.logging.markers', 'REGISTRIES'property 'forge.logging.console.level', 'debug'// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.args '--mod', 're8joymod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')mods {re8joymod {source sourceSets.main}}}}
}// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }repositories {// Put repositories for dependencies here// ForgeGradle automatically adds the Forge maven and Maven Central for you// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:// flatDir {//     dir 'libs'// }
}dependencies {// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.// The userdev artifact is a special name and will get all sorts of transformations applied to it.minecraft 'net.minecraftforge:forge:1.19.2-43.1.1'// Real mod deobf dependency examples - these get remapped to your current mappings// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency// Examples using mod jars from ./libs// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")// For more info...// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html// http://www.gradle.org/docs/current/userguide/dependency_management.html
}// Example for how to get properties into the manifest for reading at runtime.
jar {manifest {attributes(["Specification-Title"     : "re8joymod","Specification-Vendor"    : "re8joymodsareus","Specification-Version"   : "1", // We are version 1 of ourselves"Implementation-Title"    : project.name,"Implementation-Version"  : project.jar.archiveVersion,"Implementation-Vendor"   : "re8joymodsareus","Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])}
}// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
// publish.dependsOn('reobfJar')publishing {publications {mavenJava(MavenPublication) {artifact jar}}repositories {maven {url "file://${project.projectDir}/mcmodsrepo"}}
}tasks.withType(JavaCompile).configureEach {options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}

按下ctrl键+r键将所有的examplemod替换为你的模组名称(这里以re8joymod为例):

之后按下重新构建按钮等待gradle重新构建:

4.将我们第三步中group字段在Java包中创建出来,并在里面新建一个Main.java文件作为项目主类,将MOD_ID改为你的模组名称:


Main.java

package com.joy187.re8joymod;import com.mojang.logging.LogUtils;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
import org.slf4j.Logger;// The value here should match an entry in the META-INF/mods.toml file
@Mod(Main.MOD_ID)
public class Main
{// Define mod id in a common place for everything to referencepublic static final String MOD_ID = "re8joymod"; //修改为你的模组名称// Directly reference a slf4j loggerprivate static final Logger LOGGER = LogUtils.getLogger();public Main(){IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();// Register the commonSetup method for modloadingmodEventBus.addListener(this::commonSetup);// Register ourselves for server and other game events we are interested inMinecraftForge.EVENT_BUS.register(this);}private void commonSetup(final FMLCommonSetupEvent event){// Some common setup codeLOGGER.info("HELLO FROM COMMON SETUP");LOGGER.info("DIRT BLOCK >> {}", ForgeRegistries.BLOCKS.getKey(Blocks.DIRT));}// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)public static class ClientModEvents{@SubscribeEventpublic static void onClientSetup(FMLClientSetupEvent event){}}
}

5.找到resources包中的META-INFO中的mods.toml文件,对modid进行修改:

mods.toml

# This is an example mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here:  https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="MIT License"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="re8joymod" #mandatory 你Main中的MOD_ID名称
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
# see the associated build.gradle script for how to populate this completely automatically during a build
version="${file.jarVersion}" #mandatory# A display name for the mod
displayName="Resident Evil 8 joymod" #mandatory 你正式的模组名称
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
logoFile="examplemod.png" #optional
# A text field displayed in the mod UI
credits="Thanks for this example mod goes to Java" #optional
# A text field displayed in the mod UI
authors="joy187" #optional 作者的名称
# Display Test controls the display for your mod in the server connection screen
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)# The description text for the mod (multi line!) (#mandatory)
description='''
Have an adventure in the Resident Evil 8 world!
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.re8joymod]] #optional 改为你的modid# the modid of the dependencymodId="forge" #mandatory# Does this dependency have to exist - if not, ordering below must be specifiedmandatory=true #mandatory# The version range of the dependencyversionRange="[43,)" #mandatory# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatoryordering="NONE"# Side this dependency is applied on - BOTH, CLIENT or SERVERside="BOTH"
# Here's another dependency
[[dependencies.re8joymod]] #optional 改为你的modidmodId="minecraft"mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major versionversionRange="[1.19.2,1.20)"ordering="NONE"side="BOTH"

5.找到Gradle选项并点击genlntellijRuns等待其构建

构建成功之后点击下方的runClient启动客户端:


Nice!

1.19.2Forge下载百度网盘,密码:y2nq

Minecraft 1.19.2 Forge模组开发 01.Idea开发环境配置相关推荐

  1. Minecraft 1.19.2 Forge模组开发 05.矿石生成

    我们本次尝试在主世界生成模组中自定义的矿石 1.由于1.19的版本出现了深板岩层的矿石,我们要在BlockInit类中声明一个矿石的两种岩层形态: BlockInit.java package com ...

  2. Minecraft 1.19.2 Forge模组开发 04.动画效果物品

    我们本次实现一个具有动画效果的物品,本次演示的模型代码均在文末给出 效果演示效果演示效果演示 首先,请确保你的开发包中引入了geckolib依赖,相关教程请参考:Minecraft 1.19.2 Fo ...

  3. Minecraft 1.19.2 Forge模组开发 08.生物生成

    Minecraft 1.18.2 生物生成 我们今天尝试在1.19中生成模组中的生物 效果演示效果演示效果演示 1.在你的项目主类中的commonSetup方法中添加模组中生物的生成规则(可参考文末M ...

  4. Minecraft 1.19.2 Forge模组开发 02.物品栏+方块+物品

    今天是1024程序员日,我们尝试在1.19.2的模组中实现物品栏.方块和物品 1.在项目主类Main.java中添加物品栏声明,同时将物品和方块的类进行注册: Main.java package co ...

  5. Minecraft 1.19.2 Forge模组开发 10.3D动画盔甲

    Minecraft 1.16.5模组开发3D盔甲 Minecraft 1.12.2模组开发3D盔甲 Minecraft 1.18.2模组开发3D动画盔甲 我们本次在1.19.2的版本中实现具有动画效果 ...

  6. Minecraft 1.19.2 Forge模组开发 03.动画生物实体

    1.12.2动画生物实体教程 1.16.5动画生物实体教程 1.18.2动画生物实体教程 效 果 展 示 效果展示 效果展示 我们本次尝试在1.19.2中添加一个能够具有各种动画效果动作的生物实体. ...

  7. Minecraft 1.19.2 Forge模组开发 12.自定义鞘翅

    本次我们在模组中实现一个可用于飞行的鞘翅. 1.首先参考3D动画盔甲的教程一.二步制作盔甲的模型.动画文件. 2.模型制作完成,接下来需要制作我们的盔甲类 在items包中新建armor包 -> ...

  8. Minecraft 1.19.2 Forge模组开发 07.拼图建筑(jigsaw)

    如果你看过之前的Minecraft 1.19.2建筑生成的话,想必会更好理解这篇教程. 效果演示效果演示效果演示 1.我们本期准备生成的建筑分为4块,所以首先需要用4个结构方块将整个建筑包括起来: 2 ...

  9. Minecraft 1.19.2 Forge模组开发 06.建筑生成

    1.12.2自定义建筑生成 1.16.5自定义建筑生成 1.18.2自定义建筑生成 我们本次尝试在主世界生成一个自定义的建筑. 效 果 展 示 效果展示 效果展示 由于版本更新缘故,1.19的建筑生成 ...

  10. Minecraft 1.19.2 Fabric模组开发 03.动画生物实体

    我们本次尝试在1.19.2 Fabric中添加一个能够具有各种动画效果动作的生物实体. 效果展示 效果展示 效果展示 1.首先,为了实现这些动画效果,我们需要首先使用到一个模组:geckolib(下载 ...

最新文章

  1. CSDN创始人蒋涛:AI定义的开发者时代
  2. vs2005打开vs2008
  3. python locust最新版_python locust 性能测试:locust安装和一些参数介绍
  4. SAP MM 用户不希望采购订单一旦Release就自动打印输出,如何控制?
  5. golang中go mod使用第三方包
  6. Linux cat命令:连接文件并打印输出到标准输出设备
  7. automapper自动创建映射_ASP.NET Core教程:ASP.NET Core使用AutoMapper
  8. 三元组法矩阵加法java_C语言实现矩阵加法、减法、乘法和数乘运算
  9. java 内部错误2753_重新安装java出现错误的解决方法
  10. 富士相机设置传原图_更稳更快更小巧 富士轻旗舰X-S10无反相机评测
  11. review一下上一年的积累
  12. 组态软件专用短信终端
  13. VUE day_07(7.25)学子商城项目简略版
  14. WPF在资源内嵌入字体
  15. Linux开发板通过U盘拷贝文件
  16. 桌面图标出现混乱,图标文件混乱无法显示怎么修复
  17. 0开始学py爬虫(学习笔记)(Scrapy框架)(爬取职友集招聘信息)
  18. 向MySQL数据库中插入数据,sql语句没问题,但插入失败也不报错的原因
  19. yolov5模型转换(pt=>onnx=>rknn)和板端验证测试
  20. 2017年中兴算法大赛 迪杰特斯拉派

热门文章

  1. Objective-C 函数
  2. Windows XP优化指南
  3. dell笔记本驱动安装失败_如何以正确的顺序重新安装驱动程序 | Dell 中国
  4. linux安装7z命令,Linux 下安装 7zip 及使用
  5. CS269I:Incentives in Computer Science 学习笔记 Lecture 20: Fair Division(公平分配)(本系列完结撒花!)
  6. centos yum源配置
  7. iPad2如何从iOS6降级到5.1.1
  8. 91卫图助手免费获取高清影像
  9. 点滴记录笔记_持续更新
  10. wepe重装win10用U盘安装系统