Skip to main content
This guide walks through adding General Mechanics as a compile-time dependency so your addon mod can access its registries and API.

Prerequisites

  • Oracle JDK 21 — required by the NeoForge toolchain
  • IntelliJ IDEA (Community Edition or higher) is recommended
  • Lombok plugin — General Mechanics uses Lombok annotations throughout its source
  • Minecraft Development plugin — recommended for NeoForge mod development

Setup

1

Add the GENLAB Maven repository

General Mechanics artifacts are published to the GENLAB Maven repository at https://maven.superscary.net. Add it to your repositories block and scope it to the general.mechanics group so Gradle does not query it unnecessarily for unrelated dependencies.
repositories {
    maven {
        name = 'GENLAB Maven'
        url = 'https://maven.superscary.net'
        content {
            includeGroup 'general.mechanics'
        }
    }
}
2

Declare the dependency

Add General Mechanics to your dependencies block. Replace ${mc_version} with your target Minecraft version (e.g. 1.21.1) and ${gtm_version} with the General Mechanics release you want to target.
dependencies {
    // NeoForge
    implementation "general.mechanics:gm-${mc_version}:${gtm_version}"
}
Define the version variables in your gradle.properties:
gradle.properties
mc_version=1.21.1
gtm_version=1.0.0
3

Declare a mod dependency in neoforge.mods.toml

To ensure General Mechanics is present at runtime and NeoForge loads your mod after it, add a dependency entry in your META-INF/neoforge.mods.toml:
neoforge.mods.toml
[[dependencies.your_mod_id]]
    modId = "gm"
    type = "required"
    versionRange = "[1.0.0,)"
    ordering = "AFTER"
    side = "BOTH"
Replace your_mod_id with your own mod’s ID. The General Mechanics mod ID is gm (see GM.MODID).
4

Access the core registries

Once the dependency is on the compile classpath, you can reference the core registries directly. All registries are DeferredRegister instances keyed to the gm namespace.
import general.mechanics.registries.CoreBlocks;
import general.mechanics.registries.CoreItems;
import general.mechanics.registries.CoreElements;
import general.mechanics.registries.CoreFluids;
import general.mechanics.registries.CoreUpgrades;

// Access a block registered by General Mechanics
Block titaniumOre = CoreBlocks.TITANIUM_ORE_BLOCK.block();

// Access an element ingot item
Item steelIngot = CoreElements.STEEL_INGOT.get();

// Access a fluid definition
FluidDefinition crudeOil = CoreFluids.CRUDE_OIL;

Mod ID constant

The General Mechanics mod ID is defined as a constant on the GM interface:
import general.mechanics.GM;

// GM.MODID == "gm"
String modId = GM.MODID;
Use this constant rather than a hard-coded string when constructing ResourceLocation values that reference General Mechanics content. GM also provides a convenience method:
// Equivalent to ResourceLocation.fromNamespaceAndPath("gm", "titanium_ingot")
ResourceLocation loc = GM.getResource("titanium_ingot");

Registry overview

ClassDeferredRegister typeDescription
CoreBlocksDeferredRegister.BlocksAll GM blocks (ores, plastic blocks, machines, ice variants)
CoreItemsDeferredRegister.ItemsAll GM items (tools, electrical components, plastic items, circuits)
CoreElementsDeferredRegister.ItemsElement ingots and their derived forms (raw, nugget, dust, plate, pile, rod)
CoreFluidsDeferredRegister<Fluid>All GM fluids (fuels, acids, gases, cryogenic liquids)
CoreUpgradesDeferredRegister.ItemsMachine upgrade items

Build docs developers (and LLMs) love