promotional bannermobile promotional banner

M4id

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 Team

profile avatar
  • 2
    Projects
  • 45
    Downloads

#1 RainWorld Fan

More from DoctorM4id