我们本次来进行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. 关于后缀自动机的总结
  2. android tablerow 间隔,android-如何使TableRow从右到左
  3. VMware ubuntu20.04 server随win10自动启动与关闭
  4. ICCV2021|面向城市场景理解的大规模3D点云挑战赛
  5. diskgenius创建efi分区_DISKGEN 专业版修改硬盘为GPT分区 ESP分区图文教程
  6. 图解一致性哈希算法,看这文就够了!
  7. Grafana实现zabbix数据可视化展示
  8. file_put_contents记录的日志内容丢失
  9. WPFAvalonDock基本用法
  10. 个人主页博客网页设计制作HTML5+CSS大作业——清新春暖花开个人博客网站(6页)
  11. 一些css/css3特效以及边框流光特效实现
  12. 码力十足学量化|如何获取指数成分股及权重数据
  13. HTML5游戏引擎(二)01-egret引擎的安装与hello world
  14. 尚硅谷-Promise
  15. 她在IT圈里摸爬滚打的十年
  16. 微信小程序 车轮之 滑动删除
  17. 再谈OT算法的协同文档制作的底层基础架构记录
  18. 线性表 (一) 线性表定义与线性表插入与删除
  19. oracle in与exists疑惑
  20. 20、生鲜电商平台-优惠券设计与架构

热门文章

  1. Java读写文件的常用方法
  2. CUDA核函数share memory
  3. php获取远程数据,教你如何用php实现LOL数据远程获取
  4. MATLAB统计签选课名单程序,关于2018级方向课程选择的通知(1.7选课名单公布)...
  5. 使用开源软件7ZIP在Windows压缩.tar.gz格式包
  6. SolidWorks修改工程图中文字字体的方法
  7. python聊天室设计_基于python的GUI聊天室设计
  8. 如何恢复cuteftp pro 7.0的站点数据?
  9. 学生用计算机的按键名称,计算器各个键的功能
  10. 朱军清华大学计算机系是哪里人,朱军(清华大学计算机系教授)_百度百科