Package alexiil.mc.lib.attributes.fluid
Class FluidContainerRegistry
java.lang.Object
alexiil.mc.lib.attributes.fluid.FluidContainerRegistry
Maps
Item
instances to empty and full containers. This also handles registering more complex behaviour: for
example a custom handler to fill a glass bottle with potions.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static class
Fill handler for an emptyItemStack
. -
Method Summary
Modifier and TypeMethodDescriptionstatic FluidVolume
getContainedFluid(net.minecraft.item.Item item)
Retrieves theFluidVolume
contained by the givenItem
, if the item has been registered directly withmapContainer(Item, Item, FluidVolume)
.static Set<net.minecraft.item.Item>
Retrieves everyItem
that has been registered as an empty container with mapContainer or any of the "register*" methods.static Set<net.minecraft.item.Item>
Retrieves everyItem
that has been registered withmapContainer(Item, Item, FluidVolume)
as a direct container that is full.static Set<net.minecraft.item.Item>
getFullContainersFor(FluidKey fluid)
Retrieves everyItem
that has been registered withmapContainer(Item, Item, FluidVolume)
as a direct container that is full of the specified fluid.static void
mapContainer(net.minecraft.item.Item empty, net.minecraft.item.Item full, FluidVolume fluid)
Directly maps a givenItem
as containing the given fluid, with anotherItem
as the empty container.static void
registerFillHandler(net.minecraft.item.Item empty, FluidAmount minimum, FluidAmount capacity, FluidContainerRegistry.FluidFillFunction fn)
static void
registerFillHandler(net.minecraft.item.Item empty, FluidFilter fluids, boolean isFilterSpecific, FluidAmount minimum, FluidAmount capacity, FluidContainerRegistry.FluidFillFunction fn)
static void
registerFillHandler(net.minecraft.item.Item empty, FluidFilter fluids, boolean isFilterSpecific, FluidContainerRegistry.FluidFillHandler handler)
Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original.static void
registerFillHandler(net.minecraft.item.Item empty, FluidContainerRegistry.FluidFillHandler handler)
Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original.static void
registerFillHandler(net.minecraft.item.Item empty, FluidKey fluid, FluidAmount minimum, FluidAmount capacity, FluidContainerRegistry.FluidFillFunction fn)
Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original.static void
registerFillHandler(net.minecraft.item.Item empty, FluidKey fluid, FluidContainerRegistry.FluidFillHandler handler)
Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original.static void
registerFillHandler(net.minecraft.item.Item empty, Class<?> keyClass, boolean matchSubclasses, FluidContainerRegistry.FluidFillHandler handler)
Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original.
-
Method Details
-
mapContainer
public static void mapContainer(net.minecraft.item.Item empty, net.minecraft.item.Item full, FluidVolume fluid)Directly maps a givenItem
as containing the given fluid, with anotherItem
as the empty container. This is the most simple mapping possible: no NBT is used to store the fluid data, and is bi-directional: you can drain the fluid from the full item to get both the given fluid (and the empty item), and fill the empty item with the same amount of the given fluid to get the full item. -
registerFillHandler
public static void registerFillHandler(net.minecraft.item.Item empty, FluidKey fluid, FluidContainerRegistry.FluidFillHandler handler)Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInv
separately in order to be drained back to the emptyItem
). -
registerFillHandler
public static void registerFillHandler(net.minecraft.item.Item empty, FluidKey fluid, FluidAmount minimum, FluidAmount capacity, FluidContainerRegistry.FluidFillFunction fn)Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInv
separately in order to be drained back to the emptyItem
). -
registerFillHandler
public static void registerFillHandler(net.minecraft.item.Item empty, FluidFilter fluids, boolean isFilterSpecific, FluidContainerRegistry.FluidFillHandler handler)Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInv
separately in order to be drained back to the emptyItem
).- Parameters:
empty
- The empty item to fill fromfluids
- The filter to test which fluids can be filled using this handler.isFilterSpecific
- If true then this will take priority overClass
based mappings.handler
-
-
registerFillHandler
public static void registerFillHandler(net.minecraft.item.Item empty, FluidFilter fluids, boolean isFilterSpecific, FluidAmount minimum, FluidAmount capacity, FluidContainerRegistry.FluidFillFunction fn) -
registerFillHandler
public static void registerFillHandler(net.minecraft.item.Item empty, FluidContainerRegistry.FluidFillHandler handler)Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInv
separately in order to be drained back to the emptyItem
).This variant applies to every
FluidKey
.- Parameters:
empty
-handler
-
-
registerFillHandler
public static void registerFillHandler(net.minecraft.item.Item empty, FluidAmount minimum, FluidAmount capacity, FluidContainerRegistry.FluidFillFunction fn) -
registerFillHandler
public static void registerFillHandler(net.minecraft.item.Item empty, Class<?> keyClass, boolean matchSubclasses, FluidContainerRegistry.FluidFillHandler handler)Registers a custom fill handler for the given empty item, which always creates filledItemStack
s with differentItem
s to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInv
separately in order to be drained back to the emptyItem
).- Parameters:
empty
- The empty item to fill fromkeyClass
- The base class to test against.matchSubclasses
- If true then subclasses of the givenClass
will also be matched.handler
-
-
getFullContainersFor
Retrieves everyItem
that has been registered withmapContainer(Item, Item, FluidVolume)
as a direct container that is full of the specified fluid.- Returns:
- An unmodifiable view of the set of
Item
s which contain the givenFluidKey
. (Which also updates as new entries are registered).
-
getEmptyContainers
Retrieves everyItem
that has been registered as an empty container with mapContainer or any of the "register*" methods. (In other words a set of every item that is guaranteed to have aGroupedFluidInv
as one of it's attributes).- Returns:
- An unmodifiable view of the set of every
Item
which can have fluid filled into them, but are currently empty. (Which also updates as new entries are registered).
-
getFullContainers
Retrieves everyItem
that has been registered withmapContainer(Item, Item, FluidVolume)
as a direct container that is full.- Returns:
- An unmodifiable view of the set of every
Item
which contain fluid. (Which also updates as new entries are registered).
-
getContainedFluid
Retrieves theFluidVolume
contained by the givenItem
, if the item has been registered directly withmapContainer(Item, Item, FluidVolume)
. (In other words: this doesn't work for potions or other complex items that store fluid data in NBT).- Returns:
- A copy of the contained
FluidVolume
, or an emptyFluidVolume
if the item hasn't been mapped.
-