Skip to content

Instantly share code, notes, and snippets.

@williewillus
Last active June 20, 2016 20:22
Show Gist options
  • Save williewillus/a3499af0660dab0ff093a3fbad9a159e to your computer and use it in GitHub Desktop.
Save williewillus/a3499af0660dab0ff093a3fbad9a159e to your computer and use it in GitHub Desktop.
Fluid Cap breakdown
Personal notes for fluid cap and general fluid grokking since this seems really unintuitive to me.
I have not worked with fluids before and the fluid cap seems very baggage-laden to me.
It feels held back by the previous implementation of Fluids,
and is not consistent with the interface of `IItemHandler`, the inventory cap.
Oh well. Here goes.
Classes:
- `IFluidHandler`: The Capability Interface for the fluid cap.
- Generally something that has this cap has one or more "tanks" inside of it, that can hold Fluids.
- You can fill and drain out of this handler, letting it decide which tank to use internally
- Can also query it for an `IFluidTankProperties[]`
- Why can this not directly get a list of `IFluidTanks`, instead opting for gimped out state snapshots?
- `IFluidTank`: Interface for some sort of "tank"
- Can get the `FluidStack`, get the amount, get the capacity
- Can fill and drain
- Can get a `FluidTankInfo`: Immutable snapshot of a tank's state: contains `FluidStack` and `Capacity`
- `FluidTank`: Straightforward implementation of the interface
- Also a `IFluidHandler` itself - simply the only tank in the handler
- `IFluidTankProperties`: Abstract read-only representation of a tank's state
- Can get the tank's contents, max capacity, and whether you can drain specific Fluids in or out of it
- `FluidTankPropertiesWrapper`: Implementation that draws from an actual `FluidTank` object
- Why is this not on the `FluidTank` itself??
- `FluidTankProperties`: Immutable POJO implementation of the interface.
- Seems to be a duplicate of `FluidTankInfo`, yet `FluidTankInfo` is not deprecated?!
- Even contains a factory to convert from `FluidTankInfo` to `FluidTankProperties`
- `IFluidHandler` impls:
- `FluidHandlerItemStack`: Designed to wrap around an ItemStack and use NBT to track the Fluids.
- Also implements `ICapabilityProvider` for maximum convenience
- Assumes the stack only has one tank.
- subclass `Consumable`: Destroys the stack when fluid exhausted
- subclass `SwapEmpty`: Switches the stack to another when fluid exhausted
- `FluidHandlerItemStackSimply`: Designed to wrap aroudn an ItemStack and use NBT to track the Fluids.
- Also implements `ICapabilityProvider` for maximum convenience
- Assumes the stack only has one tank.
- Only allows the handler/tank to be in two states: full, or empty.
- subclass `Consumable`: Destroys the stack when fluid exhausted
- subclass `SwapEmpty`: Switches the stack to another when fluid exhausted
- `EmptyFluidHandler`: Straightforward. Immutable.
- `FluidHandlerFluidMap`: Handler that delegates each Fluid to another internal handler.
- e.g. Milk will to one `IFluidHandler`, water to another `IFluidHandler`, etc.
- `FluidHandlerConcatenate`: Handler that joins a bunch of other handlers into one object. Similar to `CombinedInvWrapper` for items.
- `ItemFluidContainer`: Demo of an Item with an `IFluidHandler` attached. Defaults to a single `FluidHandlerItemStack`
- `TileFluidHandler`: Demo of a TE with an `IFluidHandler` attached. Defaults to a `FluidTank` with a bucket's capacity.
DO NOT USE Classes:
- The *other* `IFluidHandler`: Old one. Don't use.
- The *other* `ItemFluidContainer`: Old one. Don't use.
- The *other* `TileFluidHandler`: Old one. Don't use.
- `IFluidContainer`: Completely obsoleted by caps.
- `FluidContainerRegistry`: Completely obsoleted by caps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment