[GH-ISSUE #6278] Native mods: fluid handler on items, Capabilities.FluidHandler.ITEM #2041

Closed
opened 2026-11-02 15:51:34 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @levzzz5154 on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6278

Originally assigned to: @levzzz5154 on GitHub.

🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally.

Part of #4953 ("Fluid handler on items (Capabilities.FluidHandler.ITEM)").

A tech mod's fluid containers are items: a bucket you fill from a tank, a canister that holds water or lava. The fluid handler on blocks (#5134, #5188, #5203) reads, fills and drains a block's tanks, but a mod has nothing to ask what fluid an item stack holds, nor to fill or empty it and get the changed container back.

Vanilla 26.3 and NeoForge:

  • BucketItem holds one bucket (1000 mB) of one fluid: Items.BUCKET is empty, WATER_BUCKET and LAVA_BUCKET are full. Filling or emptying one makes a new stack of the other item (BucketItem.getEmptySuccessItem, ItemUtils.createFilledResult); it is all or nothing, never part of a bucket. Milk, powder snow and fish buckets hold no fluid Horizon models (it has water and lava).
  • NeoForge's Capabilities.FluidHandler.ITEM is a ResourceHandler<FluidResource> on an ItemAccess: it acts on one item of the stack at a time (oneByOne) and may swap the item for another (an empty bucket for a filled one). A mod's own container keeps its contents in a data component.

Proposed, in the shape of #5188 (millibuckets, minecraft:water and minecraft:lava), no new vanilla firing point:

  • Hook native_item_fluid_tank(item, tank): a mod item (mod_id:name) declares itself a fluid container with a capacity in millibuckets. Asked at each call; vanilla's buckets are built in.
  • The mod item's contents live in the stack's minecraft:custom_data, under horizon_fluid (Fluid, Amount), so they are saved, sent to Horizon clients (#5467) and stack only with equal contents. An empty tank carries nothing, so empty containers stack.
  • Helpers that take a stack and answer without changing it (the caller commits):
    • native_item_fluid(stack): the fluid, amount and capacity of one item of the stack; none for any other item.
    • native_item_fluid_fill(stack, fluid, amount): how much one item of the stack takes, and the stack that item becomes (one item; the caller shrinks the original and hands out the result).
    • native_item_fluid_drain(stack, max): the fluid and how much one item of the stack gives, and the stack it becomes.

Works on any side (stacks hold no world state). Items in the world's blocks (a bucket in a machine's slot) are for the mod to combine with the block helpers. Fluid on entities and mod fluids are separate items. API from a fragment.

Originally created by @levzzz5154 on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6278 Originally assigned to: @levzzz5154 on GitHub. > 🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #4953 ("Fluid handler on items (`Capabilities.FluidHandler.ITEM`)"). A tech mod's fluid containers are items: a bucket you fill from a tank, a canister that holds water or lava. The fluid handler on blocks (#5134, #5188, #5203) reads, fills and drains a block's tanks, but a mod has nothing to ask what fluid an item stack holds, nor to fill or empty it and get the changed container back. Vanilla 26.3 and NeoForge: - `BucketItem` holds one bucket (1000 mB) of one fluid: `Items.BUCKET` is empty, `WATER_BUCKET` and `LAVA_BUCKET` are full. Filling or emptying one makes a new stack of the other item (`BucketItem.getEmptySuccessItem`, `ItemUtils.createFilledResult`); it is all or nothing, never part of a bucket. Milk, powder snow and fish buckets hold no fluid Horizon models (it has water and lava). - NeoForge's `Capabilities.FluidHandler.ITEM` is a `ResourceHandler<FluidResource>` on an `ItemAccess`: it acts on one item of the stack at a time (`oneByOne`) and may swap the item for another (an empty bucket for a filled one). A mod's own container keeps its contents in a data component. Proposed, in the shape of #5188 (millibuckets, `minecraft:water` and `minecraft:lava`), no new vanilla firing point: - Hook `native_item_fluid_tank(item, tank)`: a mod item (`mod_id:name`) declares itself a fluid container with a `capacity` in millibuckets. Asked at each call; vanilla's buckets are built in. - The mod item's contents live in the stack's `minecraft:custom_data`, under `horizon_fluid` (`Fluid`, `Amount`), so they are saved, sent to Horizon clients (#5467) and stack only with equal contents. An empty tank carries nothing, so empty containers stack. - Helpers that take a stack and answer without changing it (the caller commits): - `native_item_fluid(stack)`: the fluid, amount and capacity of one item of the stack; none for any other item. - `native_item_fluid_fill(stack, fluid, amount)`: how much one item of the stack takes, and the stack that item becomes (one item; the caller shrinks the original and hands out the result). - `native_item_fluid_drain(stack, max)`: the fluid and how much one item of the stack gives, and the stack it becomes. Works on any side (stacks hold no world state). Items in the world's blocks (a bucket in a machine's slot) are for the mod to combine with the block helpers. Fluid on entities and mod fluids are separate items. API from a fragment.
Author
Owner

@levzzz5154 commented on GitHub (Nov 1, 2026):

/claim

<!-- gh-comment-id:6562307682 --> @levzzz5154 commented on GitHub (Nov 1, 2026): /claim
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2041
No description provided.