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
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classFill handler for an emptyItemStack. -
Method Summary
Modifier and TypeMethodDescriptionstatic FluidVolumegetContainedFluid(net.minecraft.item.Item item) Retrieves theFluidVolumecontained by the givenItem, if the item has been registered directly withmapContainer(Item, Item, FluidVolume).static Set<net.minecraft.item.Item>Retrieves everyItemthat has been registered as an empty container with mapContainer or any of the "register*" methods.static Set<net.minecraft.item.Item>Retrieves everyItemthat has been registered withmapContainer(Item, Item, FluidVolume)as a direct container that is full.static Set<net.minecraft.item.Item>getFullContainersFor(FluidKey fluid) Retrieves everyItemthat has been registered withmapContainer(Item, Item, FluidVolume)as a direct container that is full of the specified fluid.static voidmapContainer(net.minecraft.item.Item empty, net.minecraft.item.Item full, FluidVolume fluid) Directly maps a givenItemas containing the given fluid, with anotherItemas the empty container.static voidregisterFillHandler(net.minecraft.item.Item empty, FluidAmount minimum, FluidAmount capacity, FluidContainerRegistry.FluidFillFunction fn) static voidregisterFillHandler(net.minecraft.item.Item empty, FluidFilter fluids, boolean isFilterSpecific, FluidAmount minimum, FluidAmount capacity, FluidContainerRegistry.FluidFillFunction fn) static voidregisterFillHandler(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 filledItemStacks with differentItems to the original.static voidregisterFillHandler(net.minecraft.item.Item empty, FluidContainerRegistry.FluidFillHandler handler) Registers a custom fill handler for the given empty item, which always creates filledItemStacks with differentItems to the original.static voidregisterFillHandler(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 filledItemStacks with differentItems to the original.static voidregisterFillHandler(net.minecraft.item.Item empty, FluidKey fluid, FluidContainerRegistry.FluidFillHandler handler) Registers a custom fill handler for the given empty item, which always creates filledItemStacks with differentItems to the original.static voidregisterFillHandler(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 filledItemStacks with differentItems 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 givenItemas containing the given fluid, with anotherItemas 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 filledItemStacks with differentItems to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInvseparately 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 filledItemStacks with differentItems to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInvseparately 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 filledItemStacks with differentItems to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInvseparately 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 overClassbased 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 filledItemStacks with differentItems to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInvseparately 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 filledItemStacks with differentItems to the original. (In other words, this is single-directional: the filled item must exposeGroupedFluidInvseparately 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 givenClasswill also be matched.handler-
-
getFullContainersFor
Retrieves everyItemthat 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
Items which contain the givenFluidKey. (Which also updates as new entries are registered).
-
getEmptyContainers
Retrieves everyItemthat 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 aGroupedFluidInvas one of it's attributes).- Returns:
- An unmodifiable view of the set of every
Itemwhich can have fluid filled into them, but are currently empty. (Which also updates as new entries are registered).
-
getFullContainers
Retrieves everyItemthat has been registered withmapContainer(Item, Item, FluidVolume)as a direct container that is full.- Returns:
- An unmodifiable view of the set of every
Itemwhich contain fluid. (Which also updates as new entries are registered).
-
getContainedFluid
Retrieves theFluidVolumecontained 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 emptyFluidVolumeif the item hasn't been mapped.
-