跳到正文

M4id

作者:DoctorM4id

A kotlin library. heart of M4id Studio's mods.

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。
M4id logo

M4id Library

A Kotlin toolkit for Minecraft mods on Fabric and NeoForge.

Write commands, networking, configuration, and registration once using Kotlin DSLs, then use them across both mod loaders. M4id is a shared library dependency for my mods.

JitPack
License: MPL-2.0
Minecraft
Loaders
Kotlin
Status

Note: M4id is currently in alpha. APIs may change between releases, and breaking changes are expected before version 1.0.


Features

Area Features Entry point
Commands A Brigadier DSL with nested literals, typed arguments, permission helpers, and suggestion providers. M4id.Command · dispatcher.addCommand(...)
Networking Serializable message classes with client and server handlers, without manually writing packet codecs. M4id.Message · M4idMsg
Data files Configuration and per-server data as plain Kotlin properties, with atomic saves and corrupt-file backups. DataFile.forClient · DataFile.forServer
Serialization kotlinx.serialization support for ResourceLocation, Vec3, AABB, CompoundTag, and ItemStack. M4id.Serial
Registration Register items, blocks, entities, effects, components, and more using concise registrar APIs. M4idAutoRegistrar
Text A builder DSL for styled chat components, including click and hover events. textLiteral { ... }
Input Keybinds with modifier keys and key-down/key-up callbacks. M4id.Input
Criteria Register and trigger advancement criteria from code. M4id.Criterion
Logging Per-mod loggers and logging markers. M4id.Logging
Percale Bridges between Mojang Codec, NBT, Gson, and kotlinx.serialization. dev.doctorm4id.percale

Installation

M4id is published through JitPack.

Each Minecraft version and loader combination is published as a separate artifact named <minecraft>-<loader>. For example, 1.21.1-fabric.

Gradle (Kotlin DSL)

Add JitPack to your repositories:

repositories {
    maven("https://jitpack.io&quot;)
}

Then add the appropriate dependency.

Fabric

dependencies {
    modImplementation(
        "com.github.DoctorM4id.M4id:1.21.1-fabric:0.1.0-alpha.5"
    )
}

NeoForge

dependencies {
    implementation(
        "com.github.DoctorM4id.M4id:1.21.1-neoforge:0.1.0-alpha.5"
    )
}

The JitPack project page provides the available artifacts and build information. You can also browse the GitHub tags for published versions.

Loader requirements

  • Fabric: The Kotlin standard library and kotlinx.serialization are bundled into the M4id JAR.
  • NeoForge: Requires Kotlin for Forge at runtime.

Compatibility

Minecraft version Fabric NeoForge Status
1.21.1 Yes Yes Supported
1.20.1 Planned N/A Planned, as needed
26.1 and newer Planned Planned Planned

Minecraft versions between those listed above are skipped.

For the full compatibility matrix and the latest release for each supported version, see SECURITY.md.

Java requirement: Minecraft 1.20.5 and newer requires Java 21.


Project layout

M4id/
├── build-logic/                  # Convention plugins, manifests, publishing, mixins
├── build.fabric.gradle.kts       # Fabric build configuration
├── build.neoforge.gradle.kts     # NeoForge build configuration
├── stonecutter.properties.toml   # Mod metadata and per-version dependencies
└── src/
    ├── fabric/                   # Fabric-specific code
    ├── neoforge/                 # NeoForge-specific code
    └── main/
        ├── java/dev/doctorm4id/
        │   ├── m4id/
        │   │   ├── command/      # Command DSL
        │   │   ├── message/      # Networking
        │   │   ├── data/         # Configuration and data files
        │   │   ├── serial/       # Serializers
        │   │   ├── registration/ # Auto-registrar
        │   │   ├── text/         # Text builder
        │   │   ├── input/        # Keybinds
        │   │   ├── ext/          # Extension functions
        │   │   ├── platform/     # Platform abstractions and implementations
        │   │   ├── util/         # General utilities
        │   │   └── internal/     # Internal code, mixins, and tests
        │   └── percale/          # Codec, NBT, and Gson bridges
        └── resources/            # Mixins, access wideners, and assets

Support


Credits

M4id includes code derived from Kambrik and Percale. Thanks to the original authors for their work.

License

M4id is licensed under the Mozilla Public License 2.0.

常见问题

M4id 支持哪些 Minecraft 版本?

M4id 支持 Minecraft Java 版 1.21.1,可用的加载器:Fabric / NeoForge。下载时注意选择和你游戏版本一致的文件。

M4id 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric / NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。

评论

登录后评论和评分

DoctorM4id 的其他作品

查看全部 →