Interface FixedFluidInvView

All Superinterfaces:
Convertible
All Known Subinterfaces:
FixedFluidInv, LimitedFixedFluidInv
All Known Implementing Classes:
AbstractPartialFixedFluidInvView, CombinedFixedFluidInv, CombinedFixedFluidInvView, DelegatingFixedFluidInv, EmptyFixedFluidInv, JumboFixedFluidInv, MappedFixedFluidInv, MappedFixedFluidInvView, SimpleFixedFluidInv, SimpleLimitedFixedFluidInv, SubFixedFluidInv, SubFixedFluidInvView

public interface FixedFluidInvView
extends Convertible
A view of a fixed inventory for fluids, where the number of tanks never changes, and every tank is "simple":
  • The fluid will stay in the tank until it is removed or changed by something else. (So setting the fluid in a tank of an FixedFluidInv will reflect that change in getInvFluid(int)).

The attribute is stored in FluidAttributes.FIXED_INV_VIEW.

There are various classes of interest:

  • Method Details

    • getTankCount

      int getTankCount()
      Returns:
      The number of tanks in this inventory.
    • getInvFluid

      FluidVolume getInvFluid​(int tank)
      Parameters:
      tank - The tank index. Must be a value between 0 (inclusive) and getTankCount() (exclusive) to be valid. (Like in arrays, lists, etc).
      Returns:
      The FluidVolume that is held in the tank at the moment. The returned volume must never be modified!
      Throws:
      java.lang.RuntimeException - if the given tank wasn't a valid index.
    • getMaxAmount

      @Deprecated default int getMaxAmount​(int tank)
      Deprecated.
      Parameters:
      tank - The tank index. Must be a value between 0 (inclusive) and getTankCount() (exclusive) to be valid. (Like in arrays, lists, etc).
      Returns:
      The maximum amount that the given tank can hold of the given fluid. This method will ignore the current stack in getInvFluid(int). Note that any setters that this object implements (like FixedFluidInv.setInvFluid(int, FluidVolume, Simulation) should reject stacks that are greater than this value. (and callers should only call this if they need to check the amounts separately. Note that it is meaningless to return values greater than the maximum amount an fluid can be stacked to here, and callers are free to throw an exception if this is violated. (Basically huge single-tank inventories shouldn't implement this interface).
      Throws:
      java.lang.RuntimeException - if the given tank wasn't a valid index.
    • getMaxAmount_F

      default FluidAmount getMaxAmount_F​(int tank)
      Parameters:
      tank - The tank index. Must be a value between 0 (inclusive) and getTankCount() (exclusive) to be valid. (Like in arrays, lists, etc).
      Returns:
      The maximum amount that the given tank can hold of the given fluid. This method will ignore the current stack in getInvFluid(int). Note that any setters that this object implements (like FixedFluidInv.setInvFluid(int, FluidVolume, Simulation) should reject stacks that are greater than this value. (and callers should only call this if they need to check the amounts separately. Note that it is meaningless to return values greater than the maximum amount an fluid can be stacked to here, and callers are free to throw an exception if this is violated. (Basically huge single-tank inventories shouldn't implement this interface).
      Throws:
      java.lang.RuntimeException - if the given tank wasn't a valid index.
    • isFluidValidForTank

      boolean isFluidValidForTank​(int tank, FluidKey fluid)
      Checks to see if the given fluid would be valid for this tank, ignoring current contents. Note that this method should adhere to the requirements of FluidFilter.matches(FluidKey), so passing empty fluids will generally not return useful results.
      Parameters:
      tank - The tank index. Must be a value between 0 (inclusive) and getTankCount() (exclusive) to be valid. (Like in arrays, lists, etc).
      Throws:
      java.lang.RuntimeException - if the given tank wasn't a valid index.
    • getFilterForTank

      default FluidFilter getFilterForTank​(int tank)
      Exposes isFluidValidForTank(int, FluidKey) as a (potentially) readable filter.
      Parameters:
      tank - The tank index. Must be a value between 0 (inclusive) and getTankCount() (exclusive) to be valid. (Like in arrays, lists, etc).
      Returns:
      An FluidFilter for this tank. If this tank is filtered by an FluidFilter internally then it is highly recommended that this be overridden to return that filter rather than the default opaque wrapper around isFluidValidForTank(int, FluidKey).
      Throws:
      java.lang.RuntimeException - if the given tank wasn't a valid index.
    • getTank

      default SingleFluidTankView getTank​(int tank)
    • tankIterable

      default java.lang.Iterable<? extends SingleFluidTankView> tankIterable()
    • fluidIterable

      default java.lang.Iterable<FluidVolume> fluidIterable()
    • getGroupedInv

      default GroupedFluidInvView getGroupedInv()
      Returns:
      A statistical view of this inventory.
    • addListener

      default ListenerToken addListener​(FluidInvTankChangeListener listener, ListenerRemovalToken removalToken)
      Adds the given listener to this inventory, such that the FluidInvTankChangeListener.onChange(FixedFluidInvView, int, FluidVolume, FluidVolume) will be called every time that this inventory changes. However if this inventory doesn't support listeners then this will return a null token.
      Parameters:
      removalToken - A token that will be called whenever the given listener is removed from this inventory (or if this inventory itself is unloaded or otherwise invalidated).
      Returns:
      A token that represents the listener, or null if the listener could not be added.
    • getSubInv

      default FixedFluidInvView getSubInv​(int fromIndex, int toIndex)
      Equivalent to List.subList(int, int).
      Parameters:
      fromIndex - The first tank to expose
      toIndex - The tank after the last tank to expose.
      Returns:
      a view of this inventory that only exposes the given number of tanks. Might return "this" if fromIndex is 0 and toIndex is equal to getTankCount().
      Throws:
      java.lang.RuntimeException - if any of the given tanks weren't valid.
    • getMappedInv

      default FixedFluidInvView getMappedInv​(int... tanks)
      Parameters:
      tanks - The tanks to expose.
      Returns:
      a view of this inventory that only exposes the given number of tanks. Might return "this" if the tank array is just [0,1, ... getTankCount()-1]
      Throws:
      java.lang.RuntimeException - if any of the given tanks weren't valid
    • offerSelfAsAttribute

      @Deprecated default void offerSelfAsAttribute​(AttributeList<?> list, @Nullable CacheInfo cacheInfo, @Nullable net.minecraft.util.shape.VoxelShape shape)
      Deprecated.
      Because this functionality has been fully replaced by Convertible and it's usage in AttributeList.
      Offers this object and getGroupedInv() to the attribute list. (Which, in turn, adds FixedFluidInv.getInsertable(), FixedFluidInv.getExtractable(), and FixedFluidInv.getTransferable() to the list as well).
    • convertTo

      default <T> T convertTo​(java.lang.Class<T> otherType)
      Description copied from interface: Convertible
      Attempts to provide a variant of this in the given class form. This does not have to return "this" object if this is already an instance of the given class.

      Note: In order to be typesafe (and prevent crashes) it is recommended that you return Class.cast(Object) with the object you wish to return rather than just blindly cast to "T".

      Specified by:
      convertTo in interface Convertible
    • validateFixedFluidInvView

      static void validateFixedFluidInvView​(FixedFluidInvView instance)
    • getFixedView

      default FixedFluidInvView getFixedView()
      Returns:
      An object that only implements FixedFluidInvView, and does not expose the modification methods that FixedFluidInv does. Implementations that don't expose any modification methods themselves should override this method to just return themselves.