Skip to content

Developer API

JohnBraham edited this page Nov 2, 2026 · 1 revision

Developer API

The stable public package remains cyano.poweradvantage.api. Do not import the new implementation tree just to reach a fluid network.

FluidNetworkApi

public static int offerFluid(World world, BlockPos conduitPosition,
        FluidStack offered, int maxTransfer);

public static int offerFluid(World world, BlockPos conduitPosition,
        FluidStack offered, int maxTransfer,
        byte minimumPriority, @Nullable Object source);

Import cyano.poweradvantage.api.fluid.FluidNetworkApi. Calls perform a real transfer and return exact accepted millibuckets. They do not mutate/drain offered; the caller removes the returned amount from its own reserved supply. This is not simulation.

// Server-side, with exclusive access to this source supply:
FluidStack offered = sourceTank.drain(250, false);
if (offered != null) {
    int accepted = FluidNetworkApi.offerFluid(
            world, adjacentPipe, offered, 250,
            PowerRequest.LAST_PRIORITY, sourceTile);
    if (accepted > 0) sourceTank.drain(accepted, true);
}

The example assumes simulated/real source drains agree while held exclusively. The optional source object excludes that same request entity from receiving its own offer. The target must be a loaded fluid-conduit block. Client calls, invalid arguments/targets and nonpositive limits return zero. Priority, consumer acceptance and the transfer limit bound the result.

Optional Integrations

Use an optional compile-only dependency without embedding basePower. Gate with Loader.isModLoaded("basepower") and isolate API references in a compatibility class loaded only when present. A loader check cannot protect eagerly loaded missing types.

This replaces Iron Age Furniture's brittle reflection approach, but its old poweradvantage provider-ID check also needs changing.

Deprecated com.mcmoddev.poweradvantage compatibility types remain for math.Integer2D, registry.ITileEntityGUI, conduitnetwork.ConduitRegistry and init.Fluids. They preserve specific old contracts, not general implementation compatibility.

Current API source | Public API tree

Clone this wiki locally