General Mechanics uses NeoForge energy capabilities (
net.neoforged.neoforge.energy). Machines expose their energy storage through the standard NeoForge capability system, making them compatible with any other mod that supports Forge Energy.CoreEnergyStorage
CoreEnergyStorage extends NeoForge’s built-in EnergyStorage and adds mutable setters for live capacity and stored energy adjustments:
setStored() and setMaxStorage() methods are useful for machine upgrades or data loading from NBT.
PoweredBlock Interface
Any block entity that holds aCoreEnergyStorage implements PoweredBlock:
BasePoweredBlockEntity (the base class for all powered block entities in the mod) implements PoweredBlock and exposes the storage via the NeoForge energy capability.
EnergizedCrafter Interface
EnergizedCrafter<T extends Recipe<?>> extends both Crafter<T> and the energy contract, describing a machine that consumes FE to advance a crafting process:
BaseEnergyCrafter
BaseEnergyCrafter<T extends CoreRecipe<?>> is the abstract base class for all powered crafting machines. It wires together EnergizedCrafter, PoweredBlock, and sided item I/O:
Tick Loop
On every server tick,BaseEnergyCrafter.tick() runs the following logic:
- Bail out if
!isEnabled()or redstone signal prevents running. - Look up a matching recipe for the current inventory contents.
- Check
hasEnoughEnergy(getEnergyAmount()). - If all conditions pass: call
increaseCraftingProgress(), extractgetEnergyAmount()FE from the storage, and callsetChanged(). - When
hasFinished()returnstrue: craft the item, reset progress to 0. - If conditions fail mid-craft: reset progress to 0.
- Update
POWEREDblock state to reflect active/inactive status.
Machine States
MachineState | Meaning |
|---|---|
ACTIVE | Crafting in progress |
INACTIVE | Idle — no recipe, no inputs, or redstone blocked |
ERROR | Energy empty, output slot full, or machine disabled |
Energy in Practice
Matter Fabricator Example
The Matter Fabricator is a concrete implementation:Energy Transfer
Machines accept energy from adjacent blocks that push FE via the NeoForge energy capability. There is no built-in cable block in the core module — use a compatible energy cable from another mod or child module.Power Infrastructure Tips
- Always check
CoreEnergyStorage.getMaxEnergyStored()when sizing generators — machines have hard-coded buffer limits. - The
MAX_DRAINattribute onBasePoweredBlockEntitycontrols the maximum FE accepted per tick. Feeding a machine faster thanMAX_DRAINwastes the surplus. - Progress resets to zero if power is cut mid-craft. Keep your buffers full to avoid wasted cycles.
setStored()bypasses transfer rate limits and is intended for NBT loading or debugging, not normal gameplay automation.