Class FluidType
Fluid. This is used to link a flowing and source fluid together
 without relying on tags. Most accessors do not correlate to in-game features;
 they are provided for mods to take advantage of.
 Accessors are typically implemented in a method call chain. As such, it can provide a general implementation while more specific implementations can be implemented by overriding methods further in the call chain (on fluids, entities, etc.).
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classThe properties of the fluid.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final @Nullable BlockPathTypesstatic final intThe number of fluid units that a bucket represents.private final booleanprivate final booleanprivate final booleanprivate final booleanprivate final booleanprivate final booleanprivate final intprivate Stringprivate final floatprivate final intprivate final doubleprivate final @Nullable BlockPathTypesprivate final Rarityprivate ObjectA lazy value which computes the number of fluid types within the registry.protected final Map<SoundAction,SoundEvent> A map of actions performed to sound that should be played.private final booleanprivate final intprivate final int
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal booleancanBePlacedInLevel(BlockAndTintGetter getter, BlockPos pos, FluidState state) Returns whether the fluid can be placed in the level.final booleancanBePlacedInLevel(BlockAndTintGetter getter, BlockPos pos, FluidStack stack) Returns whether the fluid can be placed in the level.booleancanConvertToSource(FluidState state, LevelReader reader, BlockPos pos) Returns whether the fluid can create a source.booleancanConvertToSource(FluidStack stack) Returns whether the fluid can create a source.booleancanDrownIn(LivingEntity entity) Returns whether the entity can drown in the fluid.booleancanExtinguish(Entity entity) Returns whether the entity can be extinguished by this fluid.booleancanExtinguish(FluidState state, BlockGetter getter, BlockPos pos) Returns whether the block can be extinguished by this fluid.booleancanHydrate(Entity entity) Returns whether the entity can be hydrated by this fluid.booleancanHydrate(FluidState state, BlockGetter getter, BlockPos pos, BlockState source, BlockPos sourcePos) Returns whether the block can be hydrated by a fluid.booleancanHydrate(FluidStack stack) Returns whether the fluid can hydrate.booleancanPushEntity(Entity entity) Returns whether the fluid can push an entity.booleancanRideVehicleUnder(Entity vehicle, Entity rider) Returns whether the entity can ride in this vehicle under the fluid.booleanReturns whether the entity can swim in the fluid.@Nullable BlockPathTypesgetAdjacentBlockPathType(FluidState state, BlockGetter level, BlockPos pos, @Nullable Mob mob, BlockPathTypes originalType) Gets the path type of the adjacent fluid to a pathfinding entity.getBlockForFluidState(BlockAndTintGetter getter, BlockPos pos, FluidState state) Returns the associatedBlockStatefor aFluidState.@Nullable BlockPathTypesgetBlockPathType(FluidState state, BlockGetter level, BlockPos pos, @Nullable Mob mob, boolean canFluidLog) Gets the path type of this fluid when an entity is pathfinding.getBucket(FluidStack stack) Returns the bucket containing the fluid.intReturns the density of the fluid.intgetDensity(FluidState state, BlockAndTintGetter getter, BlockPos pos) Returns the density of the fluid.intgetDensity(FluidStack stack) Returns the density of the fluid.Returns the component representing the name of the fluid type.getDescription(FluidStack stack) Returns the component representing the name of the fluid type.Returns the identifier representing the name of the fluid type.getDescriptionId(FluidStack stack) Returns the identifier representing the name of the fluid.floatgetFallDistanceModifier(Entity entity) Returns how much the fluid should scale the damage done to a falling entity when hitting the ground per tick.intReturns the light level emitted by the fluid.intgetLightLevel(FluidState state, BlockAndTintGetter getter, BlockPos pos) Returns the light level emitted by the fluid.intgetLightLevel(FluidStack stack) Returns the light level emitted by the fluid.Returns the rarity of the fluid.getRarity(FluidStack stack) Returns the rarity of the fluid.@Nullable SoundEventgetSound(@Nullable Player player, BlockGetter getter, BlockPos pos, SoundAction action) Returns a sound to play when a certain action is performed at a position.@Nullable SoundEventgetSound(Entity entity, SoundAction action) Returns a sound to play when a certain action is performed by the entity in the fluid.@Nullable SoundEventgetSound(SoundAction action) Returns a sound to play when a certain action is performed.@Nullable SoundEventgetSound(FluidStack stack, SoundAction action) Returns a sound to play when a certain action is performed.getStateForPlacement(BlockAndTintGetter getter, BlockPos pos, FluidStack stack) Returns theFluidStatewhen aFluidStackis trying to place it.intReturns the temperature of the fluid.intgetTemperature(FluidState state, BlockAndTintGetter getter, BlockPos pos) Returns the temperature of the fluid.intgetTemperature(FluidStack stack) Returns the temperature of the fluid.intReturns the viscosity, or thickness, of the fluid.intgetViscosity(FluidState state, BlockAndTintGetter getter, BlockPos pos) Returns the viscosity, or thickness, of the fluid.intgetViscosity(FluidStack stack) Returns the viscosity, or thickness, of the fluid.private voidvoidinitializeClient(Consumer<IClientFluidTypeExtensions> consumer) final booleanisAir()Returns whether the fluid type represents air.final booleanReturns whether a fluid is lighter than air.final booleanReturns whether the fluid type is from vanilla.booleanisVaporizedOnPlacement(Level level, BlockPos pos, FluidStack stack) Determines if this fluid should be vaporized when placed into a level.doublemotionScale(Entity entity) Returns how much the velocity of the fluid should be scaled by when applied to an entity.booleanmove(FluidState state, LivingEntity entity, Vec3 movementVector, double gravity) Performs how an entity moves when within the fluid.voidonVaporize(@Nullable Player player, Level level, BlockPos pos, FluidStack stack) Performs an action when a fluid can be vaporized when placed into a level.voidsetItemMovement(ItemEntity entity) Performs what to do when an item is in a fluid.booleanshouldUpdateWhileBoating(FluidState state, Boat boat, Entity rider) Whenfalse, the fluid will no longer update its height value while within a boat while it is not within a fluid (Boat.isUnderWater().booleansupportsBoating(Boat boat) Returns whether the boat can be used on the fluid.booleansupportsBoating(FluidState state, Boat boat) Returns whether the boat can be used on the fluid.toString()
- 
Field Details- 
BUCKET_VOLUMEpublic static final int BUCKET_VOLUMEThe number of fluid units that a bucket represents.- See Also:
 
- 
SIZEA lazy value which computes the number of fluid types within the registry.
- 
descriptionId
- 
motionScaleprivate final double motionScale
- 
canPushEntityprivate final boolean canPushEntity
- 
canSwimprivate final boolean canSwim
- 
canDrownprivate final boolean canDrown
- 
fallDistanceModifierprivate final float fallDistanceModifier
- 
canExtinguishprivate final boolean canExtinguish
- 
canConvertToSourceprivate final boolean canConvertToSource
- 
supportsBoatingprivate final boolean supportsBoating
- 
pathType
- 
adjacentPathType
- 
canHydrateprivate final boolean canHydrate
- 
lightLevelprivate final int lightLevel
- 
densityprivate final int density
- 
temperatureprivate final int temperature
- 
viscosityprivate final int viscosity
- 
rarity
- 
soundsA map of actions performed to sound that should be played.
- 
renderProperties
 
- 
- 
Constructor Details- 
FluidTypeDefault constructor.- Parameters:
- properties- the general properties of the fluid type
 
 
- 
- 
Method Details- 
getDescriptionReturns the component representing the name of the fluid type.- Returns:
- the component representing the name of the fluid type
 
- 
getDescriptionIdReturns the identifier representing the name of the fluid type. If no identifier was specified, then the identifier will be defaulted tofluid_type.<modid>.<registry_name>.- Returns:
- the identifier representing the name of the fluid type
 
- 
getLightLevelpublic int getLightLevel()Returns the light level emitted by the fluid.Note: This should be a value between [0,15]. If not specified, the light level is0as most fluids do not emit light.Implementation: This is used by the bucket model to determine whether the fluid should render full-bright when applyFluidLuminosityistrue.- Returns:
- the light level emitted by the fluid
 
- 
getDensitypublic int getDensity()Returns the density of the fluid.Note: This is an arbitrary number. Negative or zero values indicate that the fluid is lighter than air. If not specified, the density is approximately equivalent to the real-life density of water in kg/m^3.- Returns:
- the density of the fluid
 
- 
getTemperaturepublic int getTemperature()Returns the temperature of the fluid.Note: This is an arbitrary number. Higher temperature values indicate that the fluid is hotter. If not specified, the temperature is approximately equivalent to the real-life room temperature of water in Kelvin.- Returns:
- the temperature of the fluid
 
- 
getViscositypublic int getViscosity()Returns the viscosity, or thickness, of the fluid.Note: This is an arbitrary number. The value should never be negative. Higher viscosity values indicate that the fluid flows more slowly. If not specified, the viscosity is approximately equivalent to the real-life viscosity of water in m/s^2.- Returns:
- the viscosity of the fluid
 
- 
getRarityReturns the rarity of the fluid.Note: If not specified, the rarity of the fluid is Rarity.COMMON.- Returns:
- the rarity of the fluid
 
- 
getSoundReturns a sound to play when a certain action is performed. If no sound is present, then the sound will benull.- Parameters:
- action- the action being performed
- Returns:
- the sound to play when performing the action
 
- 
motionScaleReturns how much the velocity of the fluid should be scaled by when applied to an entity.- Parameters:
- entity- the entity in the fluid
- Returns:
- a scalar to multiply to the fluid velocity
 
- 
canPushEntityReturns whether the fluid can push an entity.- Parameters:
- entity- the entity in the fluid
- Returns:
- trueif the entity can be pushed by the fluid,- falseotherwise
 
- 
canSwimReturns whether the entity can swim in the fluid.- Parameters:
- entity- the entity in the fluid
- Returns:
- trueif the entity can swim in the fluid,- falseotherwise
 
- 
getFallDistanceModifierReturns how much the fluid should scale the damage done to a falling entity when hitting the ground per tick.Implementation: If the entity is in many fluids, the smallest modifier is applied. - Parameters:
- entity- the entity in the fluid
- Returns:
- a scalar to multiply to the fall damage
 
- 
canExtinguishReturns whether the entity can be extinguished by this fluid.- Parameters:
- entity- the entity in the fluid
- Returns:
- trueif the entity can be extinguished,- falseotherwise
 
- 
movePerforms how an entity moves when within the fluid. If using custom movement logic, the method should returntrue. Otherwise, the movement logic will default to water.- Parameters:
- state- the state of the fluid
- entity- the entity moving within the fluid
- movementVector- the velocity of how the entity wants to move
- gravity- the gravity to apply to the entity
- Returns:
- trueif custom movement logic is performed,- falseotherwise
 
- 
canDrownInReturns whether the entity can drown in the fluid.- Parameters:
- entity- the entity in the fluid
- Returns:
- trueif the entity can drown in the fluid,- falseotherwise
 
- 
setItemMovementPerforms what to do when an item is in a fluid.- Parameters:
- entity- the item in the fluid
 
- 
supportsBoatingReturns whether the boat can be used on the fluid.- Parameters:
- boat- the boat trying to be used on the fluid
- Returns:
- trueif the boat can be used,- falseotherwise
 
- 
supportsBoatingReturns whether the boat can be used on the fluid.- Parameters:
- state- the state of the fluid
- boat- the boat trying to be used on the fluid
- Returns:
- trueif the boat can be used,- falseotherwise
 
- 
shouldUpdateWhileBoatingWhenfalse, the fluid will no longer update its height value while within a boat while it is not within a fluid (Boat.isUnderWater().- Parameters:
- state- the state of the fluid the rider is within
- boat- the boat the rider is within that is not inside a fluid
- rider- the rider of the boat
- Returns:
- trueif the fluid height should be updated,- falseotherwise
 
- 
canRideVehicleUnderReturns whether the entity can ride in this vehicle under the fluid.- Parameters:
- vehicle- the vehicle being ridden in
- rider- the entity riding the vehicle
- Returns:
- trueif the vehicle can be ridden in under this fluid,- falseotherwise
 
- 
canHydrateReturns whether the entity can be hydrated by this fluid.Hydration is an arbitrary word which depends on the entity. - Parameters:
- entity- the entity in the fluid
- Returns:
- trueif the entity can be hydrated,- falseotherwise
 
- 
getSoundReturns a sound to play when a certain action is performed by the entity in the fluid. If no sound is present, then the sound will benull.- Parameters:
- entity- the entity in the fluid
- action- the action being performed
- Returns:
- the sound to play when performing the action
 
- 
canExtinguishReturns whether the block can be extinguished by this fluid.- Parameters:
- state- the state of the fluid
- getter- the getter which can get the fluid
- pos- the position of the fluid
- Returns:
- trueif the block can be extinguished,- falseotherwise
 
- 
canConvertToSourceReturns whether the fluid can create a source.- Parameters:
- state- the state of the fluid
- reader- the reader that can get the fluid
- pos- the location of the fluid
- Returns:
- trueif the fluid can create a source,- falseotherwise
 
- 
getBlockPathType@Nullable public @Nullable BlockPathTypes getBlockPathType(FluidState state, BlockGetter level, BlockPos pos, @Nullable @Nullable Mob mob, boolean canFluidLog) Gets the path type of this fluid when an entity is pathfinding. Whennull, uses vanilla behavior.- Parameters:
- state- the state of the fluid
- level- the level which contains this fluid
- pos- the position of the fluid
- mob- the mob currently pathfinding, may be- null
- canFluidLog-- trueif the path is being applied for fluids that can log blocks, should be checked against if the fluid can log a block
- Returns:
- the path type of this fluid
 
- 
getAdjacentBlockPathType@Nullable public @Nullable BlockPathTypes getAdjacentBlockPathType(FluidState state, BlockGetter level, BlockPos pos, @Nullable @Nullable Mob mob, BlockPathTypes originalType) Gets the path type of the adjacent fluid to a pathfinding entity. Path types with a negative malus are not traversable for the entity. Pathfinding entities will favor paths consisting of a lower malus. Whennull, uses vanilla behavior.- Parameters:
- state- the state of the fluid
- level- the level which contains this fluid
- pos- the position of the fluid
- mob- the mob currently pathfinding, may be- null
- originalType- the path type of the source the entity is on
- Returns:
- the path type of this fluid
 
- 
getSound@Nullable public @Nullable SoundEvent getSound(@Nullable @Nullable Player player, BlockGetter getter, BlockPos pos, SoundAction action) Returns a sound to play when a certain action is performed at a position. If no sound is present, then the sound will benull.- Parameters:
- player- the player listening to the sound
- getter- the getter which can get the fluid
- pos- the position of the fluid
- action- the action being performed
- Returns:
- the sound to play when performing the action
 
- 
canHydratepublic boolean canHydrate(FluidState state, BlockGetter getter, BlockPos pos, BlockState source, BlockPos sourcePos) Returns whether the block can be hydrated by a fluid.Hydration is an arbitrary word which depends on the block. - A farmland has moisture
- A sponge can soak up the liquid
- A coral can live
 - Parameters:
- state- the state of the fluid
- getter- the getter which can get the fluid
- pos- the position of the fluid
- source- the state of the block being hydrated
- sourcePos- the position of the block being hydrated
- Returns:
- trueif the block can be hydrated,- falseotherwise
 
- 
getLightLevelReturns the light level emitted by the fluid.Note: This should be a value between [0,15]. If not specified, the light level is0as most fluids do not emit light.- Parameters:
- state- the state of the fluid
- getter- the getter which can get the fluid
- pos- the position of the fluid
- Returns:
- the light level emitted by the fluid
 
- 
getDensityReturns the density of the fluid.Note: This is an arbitrary number. Negative or zero values indicate that the fluid is lighter than air. If not specified, the density is approximately equivalent to the real-life density of water in kg/m^3.- Parameters:
- state- the state of the fluid
- getter- the getter which can get the fluid
- pos- the position of the fluid
- Returns:
- the density of the fluid
 
- 
getTemperatureReturns the temperature of the fluid.Note: This is an arbitrary number. Higher temperature values indicate that the fluid is hotter. If not specified, the temperature is approximately equivalent to the real-life room temperature of water in Kelvin.- Parameters:
- state- the state of the fluid
- getter- the getter which can get the fluid
- pos- the position of the fluid
- Returns:
- the temperature of the fluid
 
- 
getViscosityReturns the viscosity, or thickness, of the fluid.Note: This is an arbitrary number. The value should never be negative. Higher viscosity values indicate that the fluid flows more slowly. If not specified, the viscosity is approximately equivalent to the real-life viscosity of water in m/s^2.- Parameters:
- state- the state of the fluid
- getter- the getter which can get the fluid
- pos- the position of the fluid
- Returns:
- the viscosity of the fluid
 
- 
canConvertToSourceReturns whether the fluid can create a source.- Parameters:
- stack- the stack holding the fluid
- Returns:
- trueif the fluid can create a source,- falseotherwise
 
- 
getSoundReturns a sound to play when a certain action is performed. If no sound is present, then the sound will benull.- Parameters:
- stack- the stack holding the fluid
- action- the action being performed
- Returns:
- the sound to play when performing the action
 
- 
getDescriptionReturns the component representing the name of the fluid type.- Parameters:
- stack- the stack holding the fluid
- Returns:
- the component representing the name of the fluid type
 
- 
getDescriptionIdReturns the identifier representing the name of the fluid. If no identifier was specified, then the identifier will be defaulted tofluid_type.<modid>.<registry_name>.- Parameters:
- stack- the stack holding the fluid
- Returns:
- the identifier representing the name of the fluid
 
- 
canHydrateReturns whether the fluid can hydrate.Hydration is an arbitrary word which depends on the implementation. - Parameters:
- stack- the stack holding the fluid
- Returns:
- trueif the fluid can hydrate,- falseotherwise
 
- 
getLightLevelReturns the light level emitted by the fluid.Note: This should be a value between [0,15]. If not specified, the light level is0as most fluids do not emit light.- Parameters:
- stack- the stack holding the fluid
- Returns:
- the light level emitted by the fluid
 
- 
getDensityReturns the density of the fluid.Note: This is an arbitrary number. Negative or zero values indicate that the fluid is lighter than air. If not specified, the density is approximately equivalent to the real-life density of water in kg/m^3.- Parameters:
- stack- the stack holding the fluid
- Returns:
- the density of the fluid
 
- 
getTemperatureReturns the temperature of the fluid.Note: This is an arbitrary number. Higher temperature values indicate that the fluid is hotter. If not specified, the temperature is approximately equivalent to the real-life room temperature of water in Kelvin.- Parameters:
- stack- the stack holding the fluid
- Returns:
- the temperature of the fluid
 
- 
getViscosityReturns the viscosity, or thickness, of the fluid.Note: This is an arbitrary number. The value should never be negative. Higher viscosity values indicate that the fluid flows more slowly. If not specified, the viscosity is approximately equivalent to the real-life viscosity of water in m/s^2.- Parameters:
- stack- the stack holding the fluid
- Returns:
- the viscosity of the fluid
 
- 
getRarityReturns the rarity of the fluid.Note: If not specified, the rarity of the fluid is Rarity.COMMON.- Parameters:
- stack- the stack holding the fluid
- Returns:
- the rarity of the fluid
 
- 
isAirpublic final boolean isAir()Returns whether the fluid type represents air.- Returns:
- trueif the type represents air,- falseotherwise
 
- 
isVanillapublic final boolean isVanilla()Returns whether the fluid type is from vanilla.- Returns:
- trueif the type is from vanilla,- falseotherwise
 
- 
getBucketReturns the bucket containing the fluid.- Parameters:
- stack- the stack holding the fluid
- Returns:
- the bucket containing the fluid
 
- 
getBlockForFluidStateReturns the associatedBlockStatefor aFluidState.- Parameters:
- getter- the getter which can get the level data
- pos- the position of where the fluid would be
- state- the state of the fluid
- Returns:
- the BlockStateof a fluid
 
- 
getStateForPlacementReturns theFluidStatewhen aFluidStackis trying to place it.- Parameters:
- getter- the getter which can get the level data
- pos- the position of where the fluid is being placed
- stack- the stack holding the fluid
- Returns:
- the FluidStatebeing placed
 
- 
canBePlacedInLevelReturns whether the fluid can be placed in the level.- Parameters:
- getter- the getter which can get the level data
- pos- the position of where the fluid is being placed
- state- the state of the fluid being placed
- Returns:
- trueif the fluid can be placed,- falseotherwise
 
- 
canBePlacedInLevelReturns whether the fluid can be placed in the level.- Parameters:
- getter- the getter which can get the level data
- pos- the position of where the fluid is being placed
- stack- the stack holding the fluid
- Returns:
- trueif the fluid can be placed,- falseotherwise
 
- 
isLighterThanAirpublic final boolean isLighterThanAir()Returns whether a fluid is lighter than air. If the fluid's density is lower than or equal0, the fluid is considered lighter than air.Tip: 0is the "canonical" density of air within Forge.Note: Fluids lighter than air will have their bucket model rotated upside-down; fluid block models will have their vertices inverted. - Returns:
- trueif the fluid is lighter than air,- falseotherwise
 
- 
isVaporizedOnPlacementDetermines if this fluid should be vaporized when placed into a level.Note: Fluids that can turn lava into obsidian should vaporize within the nether to preserve the intentions of vanilla. - Parameters:
- level- the level the fluid is being placed in
- pos- the position to place the fluid at
- stack- the stack holding the fluid being placed
- Returns:
- trueif this fluid should be vaporized on placement,- falseotherwise
- See Also:
 
- 
onVaporizepublic void onVaporize(@Nullable @Nullable Player player, Level level, BlockPos pos, FluidStack stack) Performs an action when a fluid can be vaporized when placed into a level.Note: The fluid will already have been drained from the stack. - Parameters:
- player- the player placing the fluid, may be- nullfor blocks like dispensers
- level- the level the fluid is vaporized in
- pos- the position the fluid is vaporized at
- stack- the stack holding the fluid being vaporized
- See Also:
 
- 
toString
- 
getRenderPropertiesInternal
- 
initClientprivate void initClient()
- 
initializeClient
 
-