Register Fluids and Buckets

RegistryLib’s fluid registration consolidates the flowing fluid, visual settings, fluid block, and bucket item into a single Builder flow. For mods with large numbers of chemicals, molten materials, or custom liquids, this makes fluid content much easier to scale.


Simple Example

The simplest fluid registration: built-in greyscale textures and a display name.

private static final Identifier FLUID_STILL =
        Identifier.fromNamespaceAndPath("registrylib", "block/fluid/liquid_still");
private static final Identifier FLUID_FLOW =
        Identifier.fromNamespaceAndPath("registrylib", "block/fluid/liquid_flow");

public static final FluidEntry<BaseFlowingFluid.Flowing> ACID =
        RegistryLibTest.REGISTRYLIB
                .fluid("acid", FLUID_STILL, FLUID_FLOW)
                .lang("Acid")
                .clientExtension(FLUID_STILL, FLUID_FLOW)
                .register();

Full Example

A full FluidBuilder example covering tinting, physical parameters, block/bucket configuration, and tags.

public static final FluidEntry<BaseFlowingFluid.Flowing> MOLTEN_IRON =
        RegistryLibTest.REGISTRYLIB
                .fluid("molten_iron", FLUID_STILL, FLUID_FLOW)
                .properties(p -> p.density(3000).viscosity(6000).temperature(1800))
                .lang("Molten Iron")
                .clientExtension(FLUID_STILL, FLUID_FLOW, 0xFFFF4400)
                .tag(FluidTags.LAVA)
                .block(block -> block
                    .properties(p -> p.lightLevel(s -> 12))
                )
                .bucket(bucket -> bucket
                    .lang("Molten Iron Bucket")
                )
                .register();

public static final FluidEntry<BaseFlowingFluid.Flowing> LIQUID_MAGIC =
        RegistryLibTest.REGISTRYLIB
                .fluid(
                        "liquid_magic",
                        Identifier.withDefaultNamespace("block/water_still"),
                        Identifier.withDefaultNamespace("block/water_flow"))
                .properties(p -> p.lightLevel(15).density(500).viscosity(200))
                .lang("Liquid Magic")
                .block(block -> block
                    .properties(p -> p.lightLevel(s -> 15))
                )
                .bucket(bucket -> bucket
                    .lang("Liquid Magic Bucket")
                )
                .register();

API Reference

clientExtension(Identifier, Identifier)

Sets the still and flowing textures for the fluid without tinting.

fluid.clientExtension(FLUID_STILL, FLUID_FLOW);

When using registrylib’s built-in greyscale textures, omitting the colour preserves the original grey tone.


clientExtension(Identifier, Identifier, int)

Sets the textures and tints them with an ARGB colour. Designed for use with greyscale textures and runtime tinting.

fluid.clientExtension(FLUID_STILL, FLUID_FLOW, 0xFFFF4400);

The colour format is ARGB (e.g. 0xFFFF4400 = opaque orange-red). Tinting is also applied to the bucket item model.


clientExtension(Supplier<Supplier<IClientFluidTypeExtensions>>)

Fully custom client fluid rendering extension, for advanced usage.

fluid.clientExtension(() -> () -> new IClientFluidTypeExtensions() {
    // custom implementation
});

properties(Consumer<FluidType.Properties>)

Configures FluidType’s physical parameters: density, viscosity, temperature, light level, and more.

fluid.properties(p -> p.density(3000).viscosity(6000).temperature(1800));

These parameters affect the fluid’s buoyancy calculations, flow-speed display, and tooltip information.


fluidProperties(Consumer<BaseFlowingFluid.Properties>)

Configures properties at the BaseFlowingFluid level (e.g. manually linking source/block/bucket).

fluid.fluidProperties(p -> p.slopeFindDistance(4).levelDecreasePerBlock(1));

In most cases this does not need to be called manually; block() and bucket() handle the linking automatically.


lang(String)

Sets the fluid’s display name.

fluid.lang("Molten Iron");

defaultLang()

Derives the display name automatically from the registry name (e.g. molten_ironMolten Iron).

fluid.defaultLang();

source(Function<BaseFlowingFluid.Properties, ? extends BaseFlowingFluid>)

Sets a custom source fluid factory.

fluid.source(BaseFlowingFluid.Source::new);

By default defaultSource() is called automatically; use this only when a custom source fluid class is required.


defaultSource()

Uses the default BaseFlowingFluid.Source as the source fluid.

fluid.defaultSource();

block(Consumer)

Accepts a lambda to configure the BlockBuilder for the fluid block sub-entry.

fluid.block(block -> block
    .properties(p -> p.lightLevel(s -> 15))
);

Use this to set block-specific properties such as light emission and explosion resistance.


block(BiFunction, Consumer)

Uses a custom LiquidBlock subclass factory and accepts a lambda to configure the BlockBuilder.

fluid.block(MyLiquidBlock::new, block -> block
    .properties(p -> p.lightLevel(s -> 10))
);

noBlock()

Disables fluid block generation. The fluid will not be placeable as a block in the world.

fluid.noBlock();

defaultBlock()

Uses the default fluid block settings.

fluid.defaultBlock();

bucket(Consumer)

Accepts a lambda to configure the ItemBuilder for the bucket item sub-entry.

fluid.bucket(bucket -> bucket
    .lang("Molten Iron Bucket")
);

bucket(BiFunction, Consumer)

Uses a custom BucketItem subclass factory and accepts a lambda to configure the ItemBuilder.

fluid.bucket(MyBucket::new, bucket -> bucket
    .lang("Custom Bucket")
);

noBucket()

Disables bucket item generation.

fluid.noBucket();

defaultBucketTab(ResourceKey<CreativeModeTab>)

Sets the default creative tab for the bucket item.

fluid.defaultBucketTab(CreativeModeTabs.TOOLS_AND_UTILITIES);

tag(TagKey<Fluid>...)

Adds tags to the fluid.

fluid.tag(FluidTags.LAVA);

Tags are applied to both the source fluid and the flowing fluid.


removeTag(TagKey<Fluid>...)

Removes previously added fluid tags.

fluid.removeTag(FluidTags.LAVA);

Texture Conventions

The default textures provided by RegistryLib are located at:

  • registrylib:block/fluid/liquid_still — still texture (greyscale)
  • registrylib:block/fluid/liquid_flow — flowing texture (greyscale)

These are single-channel greyscale images designed for runtime tinting via clientExtension(still, flow, color). When using a custom coloured texture (e.g. vanilla water), use the two-argument overload instead.


This site uses Just the Docs, a documentation theme for Jekyll.