Skip to main content
General Mechanics exposes a structured API under the general.mechanics.api package. All public types are safe to depend on from addon mods. Internal implementation types under general.mechanics.block, general.mechanics.item, etc. are not part of the stable API surface.

GM interface

general.mechanics.GM is the top-level entry point. It declares the mod ID constant, a resource location factory, and runtime accessors.
public interface GM {
    String NAME   = "General Mechanics";
    String MODID  = "gm";

    Logger LOGGER = LoggerFactory.getLogger(NAME);

    /** Creates a ResourceLocation in the "gm" namespace. */
    static ResourceLocation getResource(String name) { ... }

    /** Creates a ResourceLocation in the Minecraft namespace. */
    static ResourceLocation getMinecraftResource(String name) { ... }

    /** Creates a ResourceLocation with an arbitrary namespace. */
    static ResourceLocation custom(String id, String name) { ... }

    static Path gameDirectory()   { ... }
    static Path configDirectory() { ... }
    static Path modsDirectory()   { ... }

    Collection<ServerPlayer> getPlayers();
    Level                    getClientLevel();
    MinecraftServer          getCurrentServer();
}
Obtain the runtime instance via GM.getInstance().

Package reference

general.mechanics.api.energy

Energy storage and powered-block contracts.Key types: CoreEnergyStorage, PoweredBlock, EnergizedCrafter

general.mechanics.api.multiblock

Multiblock structure definition and runtime management.Key types: MultiblockDefinition, MultiblockManager, MultiblockValidator, Layout, BlockPredicate

general.mechanics.api.upgrade

Machine upgrade system.Key types: UpgradeBase, UpgradeMap, Upgradeable, DeferredUpgradeMap

general.mechanics.api.item.element

Periodic-table element types and their item representations.Key types: ElementType (enum), AlloyType (enum)

general.mechanics.api.item.plastic

Plastic polymer types and their item/block representations.Key types: PlasticType, PlasticTypeItem, ColoredPlasticItem

general.mechanics.api.electrical

Electronic component type enums and their item wrappers.Sub-packages: capacitors, resistors, transistor, transformers, icsKey types: CapacitorType, ResistorType, TransistorType, TransformerType, IntegratedCircuitType

general.mechanics.api.formula

Chemical formula display system, linking items to rendered chemical formulae.Key types: Formula, IFormulaProvider

general.mechanics.api.fluid

Custom fluid definitions and client rendering extensions.Key types: BaseFluid, FluidDefinition, IClientFluidExtensions

Core registries

All content registered by General Mechanics is accessible through static fields in the general.mechanics.registries package. Each registry is a DeferredRegister instance bound to the gm namespace.

CoreBlocks

public class CoreBlocks {
    public static final DeferredRegister.Blocks REGISTRY = DeferredRegister.createBlocks(GM.MODID);
    public static final List<BlockDefinition<?>> BLOCKS = new ArrayList<>();

    // Ore blocks — one per mineable ElementType
    public static final BlockDefinition<OreBlock> TITANIUM_ORE_BLOCK = registerOre(ElementType.TITANIUM);
    // ...

    // Plastic blocks — one per PlasticType, plus 16 dye-colour variants each
    public static final BlockDefinition<PlasticTypeBlock> POLYETHYLENE_BLOCK = ...

    // Ice phases
    public static final BlockDefinition<IceBlock>   ICE2 = ...
    public static final BlockDefinition<Ice7Block>  ICE7 = ...

    // Machines
    public static final BlockDefinition<MatterFabricatorBlock> MATTER_FABRICATOR = ...
    public static final BlockDefinition<MachineFrameBlock>     POLYETHYLENE_MACHINE_FRAME = ...
    public static final BlockDefinition<HeatingElementBlock>   INDUSTRIAL_HEATING_ELEMENT = ...

    // Helpers
    public static List<BlockDefinition<?>>       getBlocks();
    public static List<OreBlock>                 getOreBlocks();
    public static List<PlasticTypeBlock>         getAllPlasticTypeBlocks();
    public static List<ColoredPlasticBlock>      getAllColoredPlasticBlocks();
    public static List<ColoredPlasticBlock>      getColoredPlasticBlocksForType(PlasticType plasticType);
}

CoreItems

public class CoreItems {
    public static final DeferredRegister.Items REGISTRY = DeferredRegister.createItems(GM.MODID);

    // Electrical components
    public static final ItemDefinition<CapacitorItem>        CAPACITOR_PF_100 = ...
    public static final ItemDefinition<ResistorItem>         RESISTOR_10 = ...
    public static final ItemDefinition<TransistorItem>       TRANSISTOR_NPN_BJT = ...
    public static final ItemDefinition<TransformerItem>      TRANSFORMER_STEP_UP = ...
    public static final ItemDefinition<IntegratedCircuitItem> IC_7400_ITEM = ...

    // Plastic items — one per PlasticType, plus 16 dye-colour variants each
    public static final ItemDefinition<PlasticTypeItem> POLYETHYLENE = ...

    // Tools
    public static final ItemDefinition<WrenchItem>              WRENCH = ...
    public static final ItemDefinition<FlatheadScrewdriverItem> FLATHEAD_SCREWDRIVER = ...
    public static final ItemDefinition<WireCuttersItem>         WIRE_CUTTERS = ...

    // Misc
    public static final ItemDefinition<CircuitItem> BASIC_CIRCUIT = ...
    public static final ItemDefinition<BaseItem>    BOLT  = ...
    public static final ItemDefinition<BaseItem>    SCREW = ...

    // Helpers
    public static List<ItemDefinition<?>>  getItems();
    public static List<ColoredPlasticItem> getAllColoredPlastics();
    public static List<BaseItem>           getColoredPlasticsForType(PlasticType plasticType);

    // Registration helpers available to subclasses / package members
    public static <T extends Item> ItemDefinition<T> register(
        String name, Function<Item.Properties, T> factory);
    public static <T extends Item> ItemDefinition<T> register(
        String name, ResourceLocation id,
        Function<Item.Properties, T> factory,
        @Nullable ResourceKey<CreativeModeTab> group);
}

CoreElements

CoreElements registers element ingots and automatically derives six additional item forms per element: raw ore, nugget, dust, plate, pile, and rod.
public class CoreElements {
    public static final DeferredRegister.Items REGISTRY = DeferredRegister.createItems(GM.MODID);

    // Natural elements (alkali metals, transition metals, lanthanides, actinides …)
    public static final ItemDefinition<ElementItem> LITHIUM_INGOT  = elementIngot(ElementType.LITHIUM);
    public static final ItemDefinition<ElementItem> TITANIUM_INGOT = elementIngot(ElementType.TITANIUM);
    public static final ItemDefinition<ElementItem> URANIUM_INGOT  = elementIngot(ElementType.URANIUM);
    // ...

    // Alloys
    public static final ItemDefinition<ElementItem> STEEL_INGOT          = elementIngot(ElementType.STEEL);
    public static final ItemDefinition<ElementItem> STAINLESS_STEEL_INGOT = elementIngot(ElementType.STAINLESS_STEEL);
    public static final ItemDefinition<ElementItem> BRASS_INGOT           = elementIngot(ElementType.BRASS);
    public static final ItemDefinition<ElementItem> BRONZE_INGOT          = elementIngot(ElementType.BRONZE);

    /** Registers an ingot and all derived forms for the given ElementType. */
    public static ItemDefinition<ElementItem> elementIngot(ElementType element);

    public static List<ItemDefinition<?>> getElements();
}
ElementType is a comprehensive enum covering the entire periodic table. Each constant carries atomic number, symbol, display name, colour, mass, and flags such as isAlloy() and isNatural().

CoreFluids

public class CoreFluids {
    public static final DeferredRegister<Fluid> REGISTRY =
        DeferredRegister.create(BuiltInRegistries.FLUID, GM.MODID);

    // Fuels and petroleum derivatives
    public static final FluidDefinition CRUDE_OIL   = registerFluid("Crude Oil",   0xFF281E15, fogColor, "C\u2081\u2082H\u2082\u2083");
    public static final FluidDefinition GASOLINE     = registerFluid("Gasoline",    0xFFFF9933, fogColor, "C\u2088H\u2081\u2088");
    public static final FluidDefinition DIESEL       = registerFluid("Diesel",      0xFFFFCC00, fogColor, "C\u2081\u2082H\u2082\u2083");

    // Acids
    public static final FluidDefinition SULFURIC_ACID     = registerFluid("Sulfuric Acid",     ..., "H\u2082SO\u2084", true,  false, 298L);
    public static final FluidDefinition HYDROCHLORIC_ACID = registerFluid("Hydrochloric Acid", ..., "HCl",           true,  false, 298L);

    // Cryogenic liquids and gases
    public static final FluidDefinition LIQUID_NITROGEN = registerFluid("Liquid Nitrogen", ..., "N\u2082(l)", false, false, 77L);
    public static final FluidDefinition HYDROGEN        = registerFluid("Hydrogen",        ..., "H\u2082",    false, false, 20L);
    // ...

    public static List<FluidDefinition> getFluids();
    public static BaseFluid             getBaseFluid(FluidDefinition definition);

    /**
     * Registers a fluid along with its source/flowing variants,
     * liquid block, and bucket item.
     *
     * @param englishName     display name
     * @param tintColor       ARGB tint colour
     * @param fogColor        RGB fog colour
     * @param chemicalFormula Unicode formula string (may use subscript characters), or null
     * @param isAcidic        whether the fluid is acidic
     * @param isBasic         whether the fluid is basic
     * @param temp            temperature in Kelvin
     */
    public static FluidDefinition registerFluid(
        String englishName, int tintColor, Vector3f fogColor,
        String chemicalFormula, boolean isAcidic, boolean isBasic, long temp);
}

CoreUpgrades

public class CoreUpgrades {
    public static final DeferredRegister.Items REGISTRY = DeferredRegister.createItems(GM.MODID);

    public static final ItemDefinition<UpgradeBase> SPEED            = create("Speed Upgrade",      "Increases machine operation speed.", ...);
    public static final ItemDefinition<UpgradeBase> CAPACITY         = create("Capacity Upgrade",   "Expands the operational size of machines.", ...);
    public static final ItemDefinition<UpgradeBase> EFFICIENCY       = create("Efficiency Upgrade", "Reduces power consumption per operation.", ...);
    public static final ItemDefinition<UpgradeBase> OVERCLOCK        = create("Overclock Upgrade",  "Greatly increases speed but at a power efficiency cost.", ...);
    public static final ItemDefinition<UpgradeBase> AUTO_EJECTOR     = create("Auto Ejector",       "Automatically pushes output to connected inventories.", ...);
    public static final ItemDefinition<UpgradeBase> VOID_MOD         = create("Void Mod",           "Destroys overflow items instead of clogging the machine.", ...);
    // ... (16 upgrade types total)

    public static List<ItemDefinition<?>> getUpgrades();

    /**
     * Returns the upgrades compatible with a given block, as defined in the upgrade map registry.
     */
    public static ImmutableList<Pair<ItemDefinition<UpgradeBase>, Integer>>
        getCompatibleUpgrades(Block block);
}
UpgradeBase is the base class for all upgrade items:
public class UpgradeBase extends BaseItem {
    public UpgradeBase(Item.Properties properties, String description) { ... }

    /** Applies the upgrade to a block. Throws if the block does not implement Upgradeable. */
    public void functionalUpgrade(BaseEntityBlock<?> block, BlockState state);

    public boolean setApplied(boolean hasBeenApplied);
    public boolean hasBeenApplied();
    public String  getEnglishDescription();
}

CoreRecipes

public class CoreRecipes {
    // Fabrication — Matter Fabricator recipe type
    public static final DeferredHolder<RecipeSerializer<?>, RecipeSerializer<FabricationRecipe>>  FABRICATION_SERIALIZER;
    public static final DeferredHolder<RecipeType<?>,       RecipeType<FabricationRecipe>>         FABRICATION_RECIPE_TYPE;

    // Crushing — ore processing
    public static final DeferredHolder<RecipeSerializer<?>, RecipeSerializer<CrushingRecipe>>     CRUSHING_SERIALIZER;
    public static final DeferredHolder<RecipeType<?>,       RecipeType<CrushingRecipe>>            CRUSHING_RECIPE_TYPE;

    // Fluid Mixing
    public static final DeferredHolder<RecipeSerializer<?>, RecipeSerializer<FluidMixingRecipe>>  FLUID_MIXING_SERIALIZER;
    public static final DeferredHolder<RecipeType<?>,       RecipeType<FluidMixingRecipe>>         FLUID_MIXING_RECIPE_TYPE;
}

CoreComponents

CoreComponents registers NeoForge data component types for persisting machine state on item stacks:
public class CoreComponents {
    public static final DeferredRegister<DataComponentType<?>> REGISTRY;

    /** Integer component: FE currently stored in the item. */
    public static final DeferredHolder<DataComponentType<?>, DataComponentType<Integer>> ENERGY_STORED;

    /** Integer component: Maximum FE the item can store. */
    public static final DeferredHolder<DataComponentType<?>, DataComponentType<Integer>> ENERGY_MAX;

    /** Compound component: Serialized inventory contents. */
    public static final DeferredHolder<DataComponentType<?>, DataComponentType<InventoryComponent>> INVENTORY;
}
These components use persistent(Codec) so they survive item stack serialization to NBT.

CoreRegistries

CoreRegistries holds custom Registry instances for data-driven content:
public class CoreRegistries {
    /** Registry for multiblock structure definitions. */
    public static final Registry<MultiblockDefinition> MULTIBLOCK_DEFINITIONS;

    /** Registry for upgrade compatibility maps. */
    public static final Registry<UpgradeMap<?>> UPGRADE_MAP_REGISTRY;

    /** Registry for chemical formula bindings. */
    public static final Registry<Formula> FORMULAS_REGISTRY;

    public static void registerRegistries(NewRegistryEvent event);
}

DeferredRegister pattern

All GM registries follow the standard NeoForge DeferredRegister pattern. When writing an addon you register against your own namespace, but you can reference GM’s DeferredRegister instances to look up existing entries or to obtain type information at startup.
// Reading an existing GM block from within your mod's setup
Block titaniumOre = CoreBlocks.TITANIUM_ORE_BLOCK.block();
ResourceLocation key = CoreBlocks.REGISTRY.getKey(titaniumOre); // gm:titanium_ore

// Reading an element definition
ItemDefinition<ElementItem> steel = CoreElements.STEEL_INGOT;
Item steelItem = steel.get();
ResourceLocation steelId = steel.id(); // gm:steel_ingot
To register your own content that depends on GM types, create a DeferredRegister in your own namespace and reference GM API classes in your factories:
public class MyBlocks {
    public static final DeferredRegister.Blocks REGISTRY =
        DeferredRegister.createBlocks("mymod");

    // A machine frame that accepts GM plastic types
    public static final DeferredHolder<Block, MachineFrameBlock> MY_FRAME =
        REGISTRY.register("my_machine_frame",
            () -> new MachineFrameBlock(PlasticType.POLYETHYLENE));
}

Build docs developers (and LLMs) love