Skip to main content
General Mechanics registers a large set of industrial fluids through CoreFluids. Each fluid is represented by a FluidDefinition record that bundles all NeoForge fluid objects together, and the underlying visual and chemical properties are held by a BaseFluid instance.

FluidDefinition

FluidDefinition is a record that aggregates all parts of a fluid registration.
public record FluidDefinition(
    String englishName,
    Supplier<FluidType> type,
    Supplier<FlowingFluid> source,
    Supplier<FlowingFluid> flowing,
    BlockDefinition<LiquidBlock> block,
    ItemDefinition<BucketItem> bucket
)
englishName
String
Human-readable fluid name used for item/block registration.
type
Supplier<FluidType>
Lazy supplier for the FluidType (holds visual and chemical properties).
source
Supplier<FlowingFluid>
The still/source fluid variant.
flowing
Supplier<FlowingFluid>
The flowing fluid variant.
block
BlockDefinition<LiquidBlock>
The placed liquid block.
bucket
ItemDefinition<BucketItem>
The bucket item for this fluid.

Getting a FluidStack

// Default amount: 1000 mB
FluidStack stack = CoreFluids.CRUDE_OIL.getStack();

// Custom amount
FluidStack stack500 = CoreFluids.CRUDE_OIL.getStack(500);

BaseFluid

BaseFluid extends NeoForge’s FluidType and implements IClientFluidExtensions. It holds all visual and chemical properties for a registered fluid.
public class BaseFluid extends FluidType implements IClientFluidExtensions

Constructor

public BaseFluid(
    FluidType.Properties properties,
    ResourceLocation stillTexture,
    ResourceLocation flowingTexture,
    ResourceLocation overlayTexture,
    int tintColor,
    Vector3f fogColor,
    boolean isAcidic,
    boolean isBasic,
    long temp
)

Properties

GetterTypeDescription
getTintColor()intARGB tint applied to the fluid texture
getFogColor()Vector3fRGB fog color when submerged
isAcidic()booleanWhether the fluid is acidic
isBasic()booleanWhether the fluid is basic/alkaline
getTemp()longTemperature in Kelvin
getStillTexture()ResourceLocationTexture for the still surface
getFlowingTexture()ResourceLocationTexture for flowing surfaces
getOverlayTexture()ResourceLocationOverlay texture when inside the fluid
isAcidic, isBasic, and temp have corresponding setters.

CoreFluids registry methods

registerFluid() — short form

public static FluidDefinition registerFluid(
    String englishName,
    int tintColor,
    Vector3f fogColor,
    String chemicalFormula
)
Registers a room-temperature, neutral fluid. isAcidic and isBasic default to false; temp defaults to 298L K.
englishName
String
required
Display name used to derive registry IDs and bucket/block names.
tintColor
int
required
ARGB integer tint color (e.g. 0xFFFF9933).
fogColor
Vector3f
required
RGB fog color shown when the player is submerged.
chemicalFormula
String
required
Chemical formula string registered with CoreFormulas (e.g. "H₂SO₄"). Pass null or blank to skip formula registration.

registerFluid() — full form

public static FluidDefinition registerFluid(
    String englishName,
    int tintColor,
    Vector3f fogColor,
    String chemicalFormula,
    boolean isAcidic,
    boolean isBasic,
    long temp
)
Registers a fluid with explicit acidity and temperature values.
isAcidic
boolean
Mark the fluid as an acid.
isBasic
boolean
Mark the fluid as a base/alkali.
temp
long
Temperature in Kelvin.

getFluids()

public static List<FluidDefinition> getFluids()
Returns an unmodifiable list of every FluidDefinition registered through CoreFluids.

getBaseFluid()

public static BaseFluid getBaseFluid(FluidDefinition definition)
Casts the FluidType inside the given definition to BaseFluid. Returns null if the type is not a BaseFluid instance.

Formula integration

When a non-blank chemicalFormula is provided to registerFluid(), the mod automatically registers a Formula record for both the bucket item and the liquid block. The Formula record links an ItemLike to a formula string and can render a colored, italicized component:
public record Formula(ItemLike itemLike, String formula)

// Render with default styling (yellow, not italic)
Component component = formula.getFormulaComponent();

// Render with explicit options
Component component = formula.getFormulaComponent(boolean colored, boolean italic);

Code example: registering a custom fluid

import general.mechanics.registries.CoreFluids;
import general.mechanics.api.fluid.FluidDefinition;
import org.joml.Vector3f;

public class MyFluids {

    // Room-temperature, neutral fluid
    public static final FluidDefinition LIQUID_RESIN = CoreFluids.registerFluid(
        "Liquid Resin",
        0xFFAA6633,             // amber tint
        new Vector3f(0.7f, 0.4f, 0.2f), // brown fog
        "C₁₀H₈O₄"              // formula
    );

    // Hot acidic fluid with explicit properties
    public static final FluidDefinition HOT_ACID = CoreFluids.registerFluid(
        "Hot Acid",
        0xFFFFFF44,
        new Vector3f(0.9f, 0.9f, 0.2f),
        "HF",
        true,   // isAcidic
        false,  // isBasic
        500L    // 500 K
    );
}
Call registerFluid at mod initialization time, before FMLCommonSetupEvent fires. All registrations must happen during the DeferredRegister phase.

Build docs developers (and LLMs) love