Class FluidVariantAttributes

java.lang.Object
net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes

@Experimental public class FluidVariantAttributes extends Object
Common fluid variant attributes, accessible both client-side and server-side.

Experimental feature, we reserve the right to remove or change it without further notice. The transfer API is a complex addition, and we want to be able to correct possible design mistakes.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.sound.SoundEvent
    Return the sound corresponding to a container of this fluid variant being emptied if available, or the default (water) emptying sound otherwise.
    static net.minecraft.sound.SoundEvent
    Return the sound corresponding to a container of this fluid variant being filled if available, or the default (water) filling sound otherwise.
    getHandler(net.minecraft.fluid.Fluid fluid)
    Return the attribute handler for the passed fluid, if available, and null otherwise.
    getHandlerOrDefault(net.minecraft.fluid.Fluid fluid)
    Return the attribute handler for the passed fluid, if available, or the default instance otherwise.
    static int
    Return an integer in [0, 15]: the light level emitted by this fluid variant, or 0 if it doesn't naturally emit light.
    static net.minecraft.text.Text
    Return the name that should be used for the passed fluid variant.
    static int
    Return a non-negative integer, representing the temperature of this fluid in Kelvin.
    static int
    getViscosity(FluidVariant variant, @Nullable net.minecraft.world.World world)
    Return a positive integer, representing the viscosity of this fluid variant.
    static boolean
    Return true if this fluid is lighter than air.
    static void
    register(net.minecraft.fluid.Fluid fluid, FluidVariantAttributeHandler handler)
    Register an attribute handler for the passed fluid.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FluidVariantAttributes

      public FluidVariantAttributes()
  • Method Details

    • register

      public static void register(net.minecraft.fluid.Fluid fluid, FluidVariantAttributeHandler handler)
      Register an attribute handler for the passed fluid.
    • getHandler

      @Nullable public static @Nullable FluidVariantAttributeHandler getHandler(net.minecraft.fluid.Fluid fluid)
      Return the attribute handler for the passed fluid, if available, and null otherwise.
    • getHandlerOrDefault

      public static FluidVariantAttributeHandler getHandlerOrDefault(net.minecraft.fluid.Fluid fluid)
      Return the attribute handler for the passed fluid, if available, or the default instance otherwise.
    • getName

      public static net.minecraft.text.Text getName(FluidVariant variant)
      Return the name that should be used for the passed fluid variant.
    • getFillSound

      public static net.minecraft.sound.SoundEvent getFillSound(FluidVariant variant)
      Return the sound corresponding to a container of this fluid variant being filled if available, or the default (water) filling sound otherwise.
    • getEmptySound

      public static net.minecraft.sound.SoundEvent getEmptySound(FluidVariant variant)
      Return the sound corresponding to a container of this fluid variant being emptied if available, or the default (water) emptying sound otherwise.
    • getLuminance

      public static int getLuminance(FluidVariant variant)
      Return an integer in [0, 15]: the light level emitted by this fluid variant, or 0 if it doesn't naturally emit light.
    • getTemperature

      public static int getTemperature(FluidVariant variant)
      Return a non-negative integer, representing the temperature of this fluid in Kelvin. The reference values are 300 for water, and 1300 for lava.
    • getViscosity

      public static int getViscosity(FluidVariant variant, @Nullable @Nullable net.minecraft.world.World world)
      Return a positive integer, representing the viscosity of this fluid variant. Fluids with lower viscosity generally flow faster than fluids with higher viscosity.

      More precisely, viscosity should be 200 * FlowableFluid.getFlowSpeed(net.minecraft.world.WorldView) for flowable fluids. The reference values are 1000 for water, 2000 for lava in ultrawarm dimensions (such as the nether), and 6000 for lava in other dimensions.

      Parameters:
      world - World if available, otherwise null.
    • isLighterThanAir

      public static boolean isLighterThanAir(FluidVariant variant)
      Return true if this fluid is lighter than air. Fluids that are lighter than air generally flow upwards.