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 Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe properties of the fluid. -
Field Summary
FieldsModifier 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 Summary
Constructors -
Method Summary
Modifier 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.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_VOLUME
public static final int BUCKET_VOLUMEThe number of fluid units that a bucket represents.- See Also:
-
SIZE
A lazy value which computes the number of fluid types within the registry. -
descriptionId
-
motionScale
private final double motionScale -
canPushEntity
private final boolean canPushEntity -
canSwim
private final boolean canSwim -
canDrown
private final boolean canDrown -
fallDistanceModifier
private final float fallDistanceModifier -
canExtinguish
private final boolean canExtinguish -
canConvertToSource
private final boolean canConvertToSource -
supportsBoating
private final boolean supportsBoating -
pathType
-
adjacentPathType
-
canHydrate
private final boolean canHydrate -
lightLevel
private final int lightLevel -
density
private final int density -
temperature
private final int temperature -
viscosity
private final int viscosity -
rarity
-
sounds
A map of actions performed to sound that should be played. -
renderProperties
-
-
Constructor Details
-
FluidType
Default constructor.- Parameters:
properties- the general properties of the fluid type
-
-
Method Details
-
getDescription
Returns the component representing the name of the fluid type.- Returns:
- the component representing the name of the fluid type
-
getDescriptionId
Returns 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
-
getLightLevel
public 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
-
getDensity
public 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
-
getTemperature
public 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
-
getViscosity
public 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
-
getRarity
Returns the rarity of the fluid.Note: If not specified, the rarity of the fluid is
Rarity.COMMON.- Returns:
- the rarity of the fluid
-
getSound
Returns 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
-
motionScale
Returns 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
-
canPushEntity
Returns 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
-
canSwim
Returns 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
-
getFallDistanceModifier
Returns 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
-
canExtinguish
Returns whether the entity can be extinguished by this fluid.- Parameters:
entity- the entity in the fluid- Returns:
trueif the entity can be extinguished,falseotherwise
-
move
Performs 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 fluidentity- the entity moving within the fluidmovementVector- the velocity of how the entity wants to movegravity- the gravity to apply to the entity- Returns:
trueif custom movement logic is performed,falseotherwise
-
canDrownIn
Returns 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
-
setItemMovement
Performs what to do when an item is in a fluid.- Parameters:
entity- the item in the fluid
-
supportsBoating
Returns 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
-
supportsBoating
Returns whether the boat can be used on the fluid.- Parameters:
state- the state of the fluidboat- the boat trying to be used on the fluid- Returns:
trueif the boat can be used,falseotherwise
-
canRideVehicleUnder
Returns whether the entity can ride in this vehicle under the fluid.- Parameters:
vehicle- the vehicle being ridden inrider- the entity riding the vehicle- Returns:
trueif the vehicle can be ridden in under this fluid,falseotherwise
-
canHydrate
Returns 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
-
getSound
Returns 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 fluidaction- the action being performed- Returns:
- the sound to play when performing the action
-
canExtinguish
Returns whether the block can be extinguished by this fluid.- Parameters:
state- the state of the fluidgetter- the getter which can get the fluidpos- the position of the fluid- Returns:
trueif the block can be extinguished,falseotherwise
-
canConvertToSource
Returns whether the fluid can create a source.- Parameters:
state- the state of the fluidreader- the reader that can get the fluidpos- 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 fluidlevel- the level which contains this fluidpos- the position of the fluidmob- the mob currently pathfinding, may benullcanFluidLog-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 fluidlevel- the level which contains this fluidpos- the position of the fluidmob- the mob currently pathfinding, may benulloriginalType- 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 soundgetter- the getter which can get the fluidpos- the position of the fluidaction- the action being performed- Returns:
- the sound to play when performing the action
-
canHydrate
public 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 fluidgetter- the getter which can get the fluidpos- the position of the fluidsource- the state of the block being hydratedsourcePos- the position of the block being hydrated- Returns:
trueif the block can be hydrated,falseotherwise
-
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.- Parameters:
state- the state of the fluidgetter- the getter which can get the fluidpos- the position of the fluid- Returns:
- the light level emitted by the fluid
-
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.- Parameters:
state- the state of the fluidgetter- the getter which can get the fluidpos- the position of the fluid- Returns:
- the density of the fluid
-
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.- Parameters:
state- the state of the fluidgetter- the getter which can get the fluidpos- the position of the fluid- Returns:
- the temperature of the fluid
-
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.- Parameters:
state- the state of the fluidgetter- the getter which can get the fluidpos- the position of the fluid- Returns:
- the viscosity of the fluid
-
canConvertToSource
Returns whether the fluid can create a source.- Parameters:
stack- the stack holding the fluid- Returns:
trueif the fluid can create a source,falseotherwise
-
getSound
Returns 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 fluidaction- the action being performed- Returns:
- the sound to play when performing the action
-
getDescription
Returns 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
-
getDescriptionId
Returns 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
-
canHydrate
Returns 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
-
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.- Parameters:
stack- the stack holding the fluid- Returns:
- the light level emitted by the fluid
-
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.- Parameters:
stack- the stack holding the fluid- Returns:
- the density of the fluid
-
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.- Parameters:
stack- the stack holding the fluid- Returns:
- the temperature of the fluid
-
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.- Parameters:
stack- the stack holding the fluid- Returns:
- the viscosity of the fluid
-
getRarity
Returns 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
-
isAir
public final boolean isAir()Returns whether the fluid type represents air.- Returns:
trueif the type represents air,falseotherwise
-
isVanilla
public final boolean isVanilla()Returns whether the fluid type is from vanilla.- Returns:
trueif the type is from vanilla,falseotherwise
-
getBucket
Returns the bucket containing the fluid.- Parameters:
stack- the stack holding the fluid- Returns:
- the bucket containing the fluid
-
getBlockForFluidState
Returns the associatedBlockStatefor aFluidState.- Parameters:
getter- the getter which can get the level datapos- the position of where the fluid would bestate- the state of the fluid- Returns:
- the
BlockStateof a fluid
-
getStateForPlacement
Returns theFluidStatewhen aFluidStackis trying to place it.- Parameters:
getter- the getter which can get the level datapos- the position of where the fluid is being placedstack- the stack holding the fluid- Returns:
- the
FluidStatebeing placed
-
canBePlacedInLevel
Returns whether the fluid can be placed in the level.- Parameters:
getter- the getter which can get the level datapos- the position of where the fluid is being placedstate- the state of the fluid being placed- Returns:
trueif the fluid can be placed,falseotherwise
-
canBePlacedInLevel
Returns whether the fluid can be placed in the level.- Parameters:
getter- the getter which can get the level datapos- the position of where the fluid is being placedstack- the stack holding the fluid- Returns:
trueif the fluid can be placed,falseotherwise
-
isLighterThanAir
public 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
-
isVaporizedOnPlacement
Determines 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 inpos- the position to place the fluid atstack- the stack holding the fluid being placed- Returns:
trueif this fluid should be vaporized on placement,falseotherwise- See Also:
-
onVaporize
public 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 benullfor blocks like dispenserslevel- the level the fluid is vaporized inpos- the position the fluid is vaporized atstack- the stack holding the fluid being vaporized- See Also:
-
toString
-
getRenderPropertiesInternal
-
initClient
private void initClient() -
initializeClient
-