Interface FluidBehavior
@Experimental
public interface FluidBehavior
Interface for handling common entity fluid interactions.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FluidBehaviorA simple fluid behavior that acts similarly to water. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanDrownInFluid(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 booleancanMoveDownInFluid(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 booleancanSprintInFluid(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 booleancanSupportBoat(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 booleancanSwimInFluid(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).voidhandleFluidInteractionUpdate(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 booleanshouldTryFloatingInFluid(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).static FluidBehavior.Buildersimple()voidtravelInFluid(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
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 typeentity- entity that fluid interaction update is processed forinteraction- entity's fluid interaction tracker, can be used to query values or apply fluid currentcanPushEntity- 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 atLivingEntity.travelInWater(Vec3, double, boolean, double)andLivingEntity.travelInLava(Vec3, double, boolean, double).- Parameters:
fluid- a tag key representing the fluid typeentity- entity that is moving through a fluidinput- entity's movement inputbaseGravity- entity's gravityisFalling- whatever entity is currently falling or notoldY- 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 typeentity- 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 typeentity- 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 typeentity- 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 typeentity- 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 typeentity- 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 typeentity- entity that is moving through a fluid
-
simple
-