Class FluidData

java.lang.Object
mcp.mobius.waila.api.data.FluidData
All Implemented Interfaces:
IData
Direct Known Subclasses:
FluidData.PlatformDependant

@NonExtendable public abstract class FluidData extends Object implements IData
Adds fluid information to an object.
  • Field Details

  • Constructor Details

    • FluidData

      public FluidData()
  • Method Details

    • describeFluid

      @ClientOnly public static <T extends Fluid> void describeFluid(T fluid, FluidData.FluidDescriptor<T> descriptor)
      Describes how the specific fluid will be shown in the client.

      Most platforms likely has API to do this already, so user might not need to register their own implementation here.

      • On Forge, FluidType will be used for fluid name and IClientFluidTypeExtensions for fluid sprite.
      • On Fabric, FluidVariantAttributeHandler will be used for fluid name and FluidVariantRenderHandler for fluid sprite.
      Throws:
      IllegalArgumentException - if the fluid is a FlowingFluid and is not the source fluid instance
    • describeFluid

      @ClientOnly public static <T extends Fluid> void describeFluid(Class<T> clazz, FluidData.FluidDescriptor<T> descriptor)
      Describes how the fluids of the specified type will be shown in the client.

      Most platforms likely has API to do this already, so user might not need to register their own implementation here.

      • On Forge, FluidType will be used for fluid name and IClientFluidTypeExtensions for fluid sprite.
      • On Fabric, FluidVariantAttributeHandler will be used for fluid name and FluidVariantRenderHandler for fluid sprite.
    • describeCauldron

      public static void describeCauldron(Block block, FluidData.CauldronDescriptor descriptor)
      Describes what fluids are contained in the specified cauldron-like block that store fluid on its block state.

      Some platforms have API to attach this information, so user might not need to register their own implementation here.

      • On Fabric, CauldronFluidContent is used to get the information.
    • describeCauldron

      public static void describeCauldron(Class<? extends Block> clazz, FluidData.CauldronDescriptor descriptor)
      Describes what fluids are contained in the specified cauldron-like block type that store fluid on its block state.

      Some platforms have API to attach this information, so user might not need to register their own implementation here.

      • On Fabric, CauldronFluidContent is used to get the information.
    • of

      public static FluidData of(FluidData.Unit unit)
      Creates a fluid data.
      Parameters:
      unit - the fluid unit of measurement
      See Also:
    • of

      public static FluidData of(FluidData.Unit unit, int slotCountHint)
      Creates a fluid data.
      Parameters:
      unit - the fluid unit of measurement
      slotCountHint - hint of how many the slots probably are to minimize growing the list more than necessary, the user can call add(net.minecraft.world.level.material.Fluid, net.minecraft.core.component.DataComponentPatch, double, double) more than the specified count
      See Also:
    • of

      public static <S> FluidData.PlatformDependant<S> of(FluidData.PlatformTranslator<S> translator)
      Creates a fluid data with platform-specific translator.

      Use the helper methods from the platform specific API package.

      Parameters:
      translator - the translator that gets the fluid, nbt, and (optionally) amount from a platform-specific object
      See Also:
    • of

      public static <S> FluidData.PlatformDependant<S> of(FluidData.PlatformTranslator<S> translator, int slotCountHint)
      Creates a fluid data with platform-specific translator.

      Use the helper methods from the platform specific API package.

      Parameters:
      translator - the translator that gets the fluid, nbt, and (optionally) amount from a platform-specific object
      slotCountHint - hint of how many the slots probably are to minimize growing the list more than necessary, the user can call add(net.minecraft.world.level.material.Fluid, net.minecraft.core.component.DataComponentPatch, double, double) more than the specified count
      See Also:
    • add

      public FluidData add(Fluid fluid, net.minecraft.core.component.DataComponentPatch data, double stored, double capacity)
      Adds a fluid entry.
      Parameters:
      fluid - the fluid instance, will be normalized as the source fluid if it is a FlowingFluid
      data - the fluid's NBT data, will NOT be modified so it safe to not copy it
      stored - the stored amount of the fluid, in the specified unit
      capacity - the maximum capacity of this slot, in the specified unit