Quilt 模板模组使用教程

Quilt 模板模组使用教程

quilt-template-modOfficial Quilt template mod.项目地址:https://gitcode.com/gh_mirrors/qu/quilt-template-mod

1. 项目的目录结构及介绍

quilt-template-mod/
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── com/example/
│   │   │       └── ExampleMod.java
│   │   └── resources/
│   │       ├── assets/
│   │       │   └── examplemod/
│   │       │       ├── logo.png
│   │       │       └── pack.mcmeta
│   │       ├── fabric.mod.json
│   │       └── quilt.mod.json
├── gradle/
├── build.gradle
├── gradlew
├── gradlew.bat
├── settings.gradle
└── README.md
  • src/main/java/com/example/ExampleMod.java: 项目的主类文件,包含模组的初始化代码。
  • src/main/resources/assets/examplemod/: 存放模组的资源文件,如纹理和图标。
  • src/main/resources/fabric.mod.jsonquilt.mod.json: 模组的元数据文件,包含模组的基本信息和依赖项。
  • gradle/: Gradle 构建工具的配置文件。
  • build.gradle: 项目的构建脚本,定义了项目的依赖和任务。
  • gradlewgradlew.bat: Gradle 包装器脚本,用于在不同平台上运行 Gradle。
  • settings.gradle: 项目的设置文件,定义了项目的名称和子项目。
  • README.md: 项目的说明文档。

2. 项目的启动文件介绍

src/main/java/com/example/ExampleMod.java 是项目的启动文件,主要负责模组的初始化工作。以下是该文件的基本结构:

package com.example;

import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExampleMod implements ModInitializer {
    public static final Logger LOGGER = LoggerFactory.getLogger("ExampleMod");

    @Override
    public void onInitialize(ModContainer mod) {
        LOGGER.info("Hello Quilt world from {}!", mod.metadata().name());
    }
}
  • ExampleMod 类实现了 ModInitializer 接口,该接口定义了 onInitialize 方法,用于模组的初始化。
  • LOGGER 是一个日志记录器,用于输出日志信息。
  • onInitialize 方法在模组加载时被调用,可以在这里进行模组的初始化操作。

3. 项目的配置文件介绍

src/main/resources/quilt.mod.json 是 Quilt 模组的配置文件,包含了模组的基本信息和依赖项。以下是该文件的基本结构:

{
  "schema_version": 1,
  "quilt_loader": {
    "group": "com.example",
    "id": "examplemod",
    "version": "1.0.0",
    "metadata": {
      "name": "Example Mod",
      "description": "A short description of your mod.",
      "contributors": {
        "YourName": "Owner"
      },
      "contact": {
        "homepage": "https://example.com",
        "issues": "https://example.com/issues",
        "sources": "https://example.com/sources"
      },
      "license": "MIT",
      "icon": "assets/examplemod/logo.png"
    },
    "intermediate_mappings": "net.fabricmc:intermediary",
    "entrypoints": {
      "init": "com.example.ExampleMod"
    },
    "depends": [
      {
        "id": "quilt_loader",
        "versions": ">=0.17.0-"
      },
      {
        "id": "quilted_fabric_api",
        "versions": ">=4.0.0-"
      },
      {
        "id": "minecraft",
        "versions": ">=1.19.2"
      }
    ]
  }
}

quilt-template-modOfficial Quilt template mod.项目地址:https://gitcode.com/gh_mirrors/qu/quilt-template-mod

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

穆继宪Half-Dane

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值