Interface FluidBehavior


@Experimental public interface FluidBehavior
Interface for handling common entity fluid interactions.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final FluidBehavior
    A simple fluid behavior that acts similarly to water.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canDrownInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.LivingEntity entity)
    Checks if entity should drown while submerged in fluid.
    default boolean
    canMoveDownInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity)
    Checks if player can controllably go down faster by sneaking while in fluid.
    default boolean
    canSprintInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.LivingEntity entity)
    Checks if entity should be able to sprint in this fluid.
    default boolean
    canSupportBoat(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity)
    Checks if boat-like entity should be able to float on this fluid.
    default boolean
    canSwimInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity)
    Used to determine whatever player or entity can sprint-swim in a fluid (like in water).
    void
    handleFluidInteractionUpdate(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.EntityFluidInteraction interaction, boolean canPushEntity)
    Called when fluid pushing should be applied to an entity.
    default boolean
    shouldTryFloatingInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity)
    Used to determine whatever entity should try floating/jumping in fluid (think mobs in water/lava).
     
    void
    travelInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.phys.Vec3 input, double baseGravity, boolean isFalling, double oldY)
    Used to apply fluid movement logic for the entity.
  • Field Details

    • WATER_LIKE

      static final FluidBehavior WATER_LIKE
      A simple fluid behavior that acts similarly to water.
  • Method Details

    • handleFluidInteractionUpdate

      void handleFluidInteractionUpdate(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.EntityFluidInteraction interaction, boolean canPushEntity)
      Called when fluid pushing should be applied to an entity.
      Parameters:
      fluid - a tag key representing the fluid type
      entity - entity that fluid interaction update is processed for
      interaction - entity's fluid interaction tracker, can be used to query values or apply fluid current
      canPushEntity - controls whatever entity can be pushed
    • travelInFluid

      void travelInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.phys.Vec3 input, double baseGravity, boolean isFalling, double oldY)
      Used to apply fluid movement logic for the entity. For implementing this method, you should look into how vanilla handles, movement in fluids at LivingEntity.travelInWater(Vec3, double, boolean, double) and LivingEntity.travelInLava(Vec3, double, boolean, double).
      Parameters:
      fluid - a tag key representing the fluid type
      entity - entity that is moving through a fluid
      input - entity's movement input
      baseGravity - entity's gravity
      isFalling - whatever entity is currently falling or not
      oldY - old y position value
    • canSwimInFluid

      default boolean canSwimInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity)
      Used to determine whatever player or entity can sprint-swim in a fluid (like in water).
      Parameters:
      fluid - a tag key representing the fluid type
      entity - entity that fluid interaction update is processed for
    • shouldTryFloatingInFluid

      default boolean shouldTryFloatingInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity)
      Used to determine whatever entity should try floating/jumping in fluid (think mobs in water/lava).
      Parameters:
      fluid - a tag key representing the fluid type
      entity - entity that fluid interaction update is processed for
    • canMoveDownInFluid

      default boolean canMoveDownInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity)
      Checks if player can controllably go down faster by sneaking while in fluid.
      Parameters:
      fluid - a tag key representing the fluid type
      entity - entity that is moving through a fluid
    • canDrownInFluid

      default boolean canDrownInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.LivingEntity entity)
      Checks if entity should drown while submerged in fluid.
      Parameters:
      fluid - a tag key representing the fluid type
      entity - entity to check against
    • canSupportBoat

      default boolean canSupportBoat(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.Entity entity)
      Checks if boat-like entity should be able to float on this fluid.
      Parameters:
      fluid - a tag key representing the fluid type
      entity - entity that is moving through a fluid
    • canSprintInFluid

      default boolean canSprintInFluid(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluid, net.minecraft.world.entity.LivingEntity entity)
      Checks if entity should be able to sprint in this fluid.
      Parameters:
      fluid - a tag key representing the fluid type
      entity - entity that is moving through a fluid
    • simple

      static FluidBehavior.Builder simple()