Interface FluidVariant

All Superinterfaces:
net.minecraft.core.component.DataComponentGetter, net.minecraft.core.component.DataComponentHolder, TransferVariant<net.minecraft.world.level.material.Fluid>, net.minecraft.core.TypedInstance<net.minecraft.world.level.material.Fluid>

@NonExtendable public interface FluidVariant extends TransferVariant<net.minecraft.world.level.material.Fluid>
An immutable association of a still fluid and data components.

Do not extend this class. Use of(Fluid) and of(Fluid, DataComponentPatch) to create instances.

FluidVariantRendering can be used for client-side rendering of fluid variants.

Fluid variants must always be compared with equals, never by reference! hashCode is guaranteed to be correct and constant time independently of the size of the components.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<FluidVariant>
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, FluidVariant>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieve a blank FluidVariant.
    default net.minecraft.world.level.material.Fluid
    Return the fluid of this variant.
    of(net.minecraft.world.level.material.Fluid fluid)
    Retrieve a FluidVariant with a fluid, and a null tag.
    of(net.minecraft.world.level.material.Fluid fluid, net.minecraft.core.component.DataComponentPatch components)
    Retrieve a FluidVariant with a fluid, and an optional tag.
    default net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>
     
    withComponents(net.minecraft.core.component.DataComponentPatch patch)
    Creates a copy of this FluidVariant with the provided component patch applied.

    Methods inherited from interface net.minecraft.core.component.DataComponentGetter

    getTyped

    Methods inherited from interface net.minecraft.core.component.DataComponentHolder

    get, getAllOfType, getOrDefault, has

    Methods inherited from interface net.minecraft.core.TypedInstance

    is, is, is, is, is, tags
  • Field Details

    • CODEC

      static final com.mojang.serialization.Codec<FluidVariant> CODEC
    • PACKET_CODEC

      static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, FluidVariant> PACKET_CODEC
  • Method Details

    • blank

      static FluidVariant blank()
      Retrieve a blank FluidVariant.
    • of

      static FluidVariant of(net.minecraft.world.level.material.Fluid fluid)
      Retrieve a FluidVariant with a fluid, and a null tag.

      The flowing and still variations of flowing fluids are normalized to always refer to the still variant. For example, FluidVariant.of(Fluids.FLOWING_WATER).getFluid() == Fluids.WATER.

    • of

      static FluidVariant of(net.minecraft.world.level.material.Fluid fluid, net.minecraft.core.component.DataComponentPatch components)
      Retrieve a FluidVariant with a fluid, and an optional tag.

      The flowing and still variations of flowing fluids are normalized to always refer to the still fluid. For example, FluidVariant.of(Fluids.FLOWING_WATER, DataComponentPatch.EMPTY).getFluid() == Fluids.WATER.

    • getFluid

      default net.minecraft.world.level.material.Fluid getFluid()
      Return the fluid of this variant.
    • typeHolder

      default net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid> typeHolder()
      Specified by:
      typeHolder in interface net.minecraft.core.TypedInstance<net.minecraft.world.level.material.Fluid>
    • withComponents

      FluidVariant withComponents(net.minecraft.core.component.DataComponentPatch patch)
      Creates a copy of this FluidVariant with the provided component patch applied.
      Specified by:
      withComponents in interface TransferVariant<net.minecraft.world.level.material.Fluid>
      Parameters:
      patch - the patch to apply
      Returns:
      the new variant with the patch applied