Mekanism Documentation

repository·1.21.x·Indexed 23 days ago

https://github.com/mekanism/mekanism

A high-tech Minecraft add-on providing advanced machinery, tools, armor, and energy systems. This documentation covers the four-tier progression system (Basic, Advanced, Elite, Ultimate), development setup using NeoForge and JDK 21, API integration via ModMaven, and technical details on programmatic structure building and chunk monitoring commands.

Tokens
4.2K
Snippets
2
Records
31
Agent score
78%

What's inside Mekanism

  1. Understand the Mekanism directory structure

    1.21.x

    The repository is organized into several functional areas within the /src directory:

    • /src/main: Core Mekanism code and resources.
    • /src/api: The Mekanism API source code.
    • /src/additions: Code and resources for Mekanism: Additions.
    • /src/generators: Code and resources for Mekanism: Generators.
    • /src/tools: Code and resources for Mekanism: Tools.
    • /src/datagen: Contains data generators for various modules (Additions, Defense, Generators, Tools) and the generated resource outputs.
    • /src/gameTest: Game Tests for Mekanism.
    • /src/test: Unit tests for Mekanism.
  2. How Mekanism's tier-based system works

    1.21.x

    Mekanism organizes its core features (such as energy cubes and factories) using a four-tier progression system. The tiers are:

    1. Basic
    2. Advanced
    3. Elite
    4. Ultimate

    Players can upgrade components to the next tier using two methods:

    • Crafting: Place the component in a crafting grid and surround it with the required resources for that specific upgrade.
    • Tier Installers: Use tier installers directly in the game world to upgrade components.
  3. Build Mekanism jars using Gradle

    1.21.x
    You can build Mekanism using an IDE (like IntelliJ IDEA or Eclipse) or via the command line. To build the project manually from the root directory, use the Gradle wrapper. The resulting .jar files will be located in the build/libs/ folder.
  4. Add Mekanism as a dependency via Maven

    1.21.x

    Developers can use the Mekanism API by adding the ModMaven repository to their project. Mekanism v10+ is hosted on ModMaven.

    To integrate Mekanism, you must update your build.gradle to include the ModMaven repository and define your dependencies. Use compileOnly for the API to avoid leaking Mekanism internals into your mod's jar, and use runtimeOnly with fg.deobf if you need to run the mod or its modules during local development (e.g., during runClient).

    repositories {
        maven { url 'https://modmaven.dev/' }
    }
    
    dependencies {
        compileOnly "mekanism:Mekanism:${mekanism_version}:api"
        
        // If you want to test/use Mekanism & its modules during `runClient` invocation, use the following
        runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}")// Mekanism
        runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:additions")// Mekanism: Additions
        runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:generators")// Mekanism: Generators
        runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:tools")// Mekanism: Tools
    }
  5. Set up the Mekanism development environment

    1.21.x

    Mekanism is developed for Minecraft 1.21 using NeoForge. To set up your environment, ensure you meet the following requirements:

    • Gradle: Version 9.0 is recommended.
    • JDK: Version 21 is the target (matching Mojang's requirement), but a minimum of JDK 17 is required to run Gradle.
  6. Understand the Bin Insert Recipe

    1.21.x

    The BinInsertRecipe is a specialized crafting recipe in Mekanism that allows players to insert items into a Bin using a crafting grid.

    Recipe Requirements:

    • Exactly one Bin: The crafting grid must contain exactly one ItemBlockBin stack. The bin stack must have a count of 1.
    • Target Items: The grid must contain one or more stacks of the same item type (matching both item and components).
    • Grid Size: The crafting grid must have at least two slots to accommodate both the bin and the item(s).

    Behavior:

    • When the recipe is triggered, the items are inserted into the Bin's internal inventory.
    • If the Bin reaches capacity, the remaining items stay in the crafting grid as getRemainingItems.
    • The resulting item is the Bin stack, which is marked with the MekanismDataComponents.FROM_RECIPE component to handle post-crafting logic (such as attempting to pull excess items from the grid into the bin).
  7. Use the /chunk command to monitor chunk status

    1.21.x

    The /chunk command allows users to 'watch' specific chunks. When a watched chunk is loaded, unloaded, or has its chunk ticket level changed, players in that level will receive a system message notification. This is useful for monitoring chunk lifecycle events in a specific area.

    Available subcommands:

    • watch: Starts monitoring a chunk.
    • unwatch: Stops monitoring a chunk.
    • clear: Removes all active chunk watches.
    • flush: Forces a chunk cache tick to unload chunks.
  8. Use the /radiation command to manage radiation levels

    1.21.x

    The /radiation command allows administrators to add, get, heal, or reduce radiation levels at specific locations or for specific entities.

    Subcommands

    • add <magnitude> [location] [dimension]: Adds a specified radiation magnitude to a location.
      • magnitude: A double value (minimum Double.MIN_VALUE, maximum 10,000).
      • location (optional): A Vec3 coordinate.
      • dimension (optional): The dimension for the location.
    • addEntity [targets] <magnitude>: Adds radiation directly to an entity or a group of entities.
      • targets (optional): One or more entities.
      • magnitude: A double value.
    • get [location] [dimension]: Retrieves the radiation level at a specific location.
      • location (optional): A Vec3 coordinate.
      • dimension (optional): The dimension for the location.
    • heal [targets]: Resets the radiation level of the user or specified entities to the baseline radiation level.
      • targets (optional): One or more entities.
    • reduce [targets] <magnitude>: Reduces the radiation level of the user or specified entities by a given magnitude.
      • targets (optional): One or more entities.
      • magnitude: A double value.
    • removeAll: Clears all radiation sources from the world. Requires specific permissions.
  9. Reference the Mekanism packaging structure

    1.21.x

    Mekanism is distributed in several specialized jars and one combined jar. Each jar contains specific assets, data, and class files:

    Jar NameContents
    Mekanism.jarCore assets, data, and class files from /src/main and /src/api
    Mekanism-api.jarDevelopment-only jar containing class files from src/api/java
    MekanismAdditions.jarAssets, data, and classes for Mekanism: Additions
    MekanismGenerators.jarAssets, data, and classes for Mekanism: Generators
    MekanismTools.jarAssets, data, and classes for Mekanism: Tools
    MekanismDefense.jar(Planned for V11) Assets, data, and classes for Mekanism: Defense
    Mekanism-all.jarA single jar containing all assets, data, and classes from all modules. Note: For duplicate tags in /data, the last tag wins.
  10. Watch a chunk with /chunk watch

    1.21.x

    Use the watch subcommand to monitor a chunk. You can specify the chunk via its coordinates or use your current position.

    Usage patterns:

    • Watch chunk at current position: /chunk watch
    • Watch chunk at specific coordinates: /chunk watch <pos> (where <pos> is a column position argument).
    • Watch chunk at current position with a custom name: /chunk watch <name>
    • Watch chunk at specific coordinates with a custom name: /chunk watch <pos> <name>