Package net.minecraftforge.fluids
Class FluidAttributes
java.lang.Object
net.minecraftforge.fluids.FluidAttributes
- Direct Known Subclasses:
FluidAttributes.Water
Minecraft Forge Fluid Implementation
This class is a fluid (liquid or gas) equivalent to "Item." It describes the nature of a fluid
and contains its general properties.
These properties do not have inherent gameplay mechanics - they are provided so that mods may
choose to take advantage of them.
Fluid implementations are not required to actively use these properties, nor are objects
interfacing with fluids required to make use of them, but it is encouraged.
The default values can be used as a reference point for mods adding fluids such as oil or heavy
water.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
private int
Color used by universal bucket and the ModelFluid baked model.private int
Density of the fluid - completely arbitrary; negative density indicates that the fluid is lighter than air.private SoundEvent
private SoundEvent
private ResourceLocation
private boolean
This indicates if the fluid is gaseous.private int
The light level emitted by this fluid.private ResourceLocation
private Rarity
The rarity of the fluid.private ResourceLocation
private int
Temperature of the fluid - completely arbitrary; higher temperature indicates that the fluid is hotter than air.private String
private int
Viscosity ("thickness") of the fluid - completely arbitrary; negative values are not permissible. -
Constructor Summary
ModifierConstructorDescriptionprotected
FluidAttributes(FluidAttributes.Builder builder, Fluid fluid)
-
Method Summary
Modifier and TypeMethodDescriptionstatic FluidAttributes.Builder
builder(ResourceLocation stillTexture, ResourceLocation flowingTexture)
boolean
canBePlacedInWorld(BlockAndTintGetter reader, BlockPos pos, FluidState state)
boolean
canBePlacedInWorld(BlockAndTintGetter reader, BlockPos pos, FluidStack state)
boolean
doesVaporize(BlockAndTintGetter reader, BlockPos pos, FluidStack fluidStack)
Determines if this fluid should vaporize in dimensions where water vaporizes when placed.getBlock(BlockAndTintGetter reader, BlockPos pos, FluidState state)
getBucket(FluidStack stack)
int
getColor()
int
getColor(BlockAndTintGetter world, BlockPos pos)
int
getColor(FluidStack stack)
int
int
getDensity(BlockAndTintGetter world, BlockPos pos)
int
getDensity(FluidStack stack)
getDisplayName(FluidStack stack)
Returns the localized name of this fluid.getEmptySound(BlockAndTintGetter world, BlockPos pos)
getEmptySound(FluidStack stack)
getFillSound(BlockAndTintGetter world, BlockPos pos)
getFillSound(FluidStack stack)
getFlowingTexture(BlockAndTintGetter world, BlockPos pos)
getFlowingTexture(FluidStack stack)
int
int
getLuminosity(BlockAndTintGetter world, BlockPos pos)
int
getLuminosity(FluidStack stack)
getRarity(BlockAndTintGetter world, BlockPos pos)
getRarity(FluidStack stack)
getStateForPlacement(BlockAndTintGetter reader, BlockPos pos, FluidStack state)
getStillTexture(BlockAndTintGetter world, BlockPos pos)
getStillTexture(FluidStack stack)
int
int
getTemperature(BlockAndTintGetter world, BlockPos pos)
int
getTemperature(FluidStack stack)
Returns the translation key of this fluid.getTranslationKey(FluidStack stack)
A FluidStack sensitive version of getTranslationKeyint
int
getViscosity(BlockAndTintGetter world, BlockPos pos)
int
getViscosity(FluidStack stack)
boolean
boolean
isGaseous(BlockAndTintGetter world, BlockPos pos)
boolean
isGaseous(FluidStack stack)
boolean
void
vaporize(Player player, Level worldIn, BlockPos pos, FluidStack fluidStack)
Called instead of placing the fluid block ifDimensionType.ultraWarm()
anddoesVaporize(BlockAndTintGetter, BlockPos, FluidStack)
are true.
-
Field Details
-
BUCKET_VOLUME
public static final int BUCKET_VOLUME- See Also:
- Constant Field Values
-
translationKey
-
stillTexture
-
flowingTexture
-
overlayTexture
-
fillSound
-
emptySound
-
luminosity
private final int luminosityThe light level emitted by this fluid. Default value is 0, as most fluids do not actively emit light. -
density
private final int densityDensity of the fluid - completely arbitrary; negative density indicates that the fluid is lighter than air. Default value is approximately the real-life density of water in kg/m^3. -
temperature
private final int temperatureTemperature of the fluid - completely arbitrary; higher temperature indicates that the fluid is hotter than air. Default value is approximately the real-life room temperature of water in degrees Kelvin. -
viscosity
private final int viscosityViscosity ("thickness") of the fluid - completely arbitrary; negative values are not permissible. Default value is approximately the real-life density of water in m/s^2 (x10^-3). Higher viscosity means that a fluid flows more slowly, like molasses. Lower viscosity means that a fluid flows more quickly, like helium. -
isGaseous
private final boolean isGaseousThis indicates if the fluid is gaseous. Generally this is associated with negative density fluids. -
rarity
The rarity of the fluid. Used primarily in tool tips. -
color
private final int colorColor used by universal bucket and the ModelFluid baked model. Note that this int includes the alpha so converting this to RGB with alpha would be float r = ((color >> 16) & 0xFF) / 255f; // red float g = ((color >> 8) & 0xFF) / 255f; // green float b = ((color >> 0) & 0xFF) / 255f; // blue float a = ((color >> 24) & 0xFF) / 255f; // alpha
-
-
Constructor Details
-
FluidAttributes
-
-
Method Details
-
getBucket
-
getBlock
-
getStateForPlacement
-
canBePlacedInWorld
-
canBePlacedInWorld
-
isLighterThanAir
public final boolean isLighterThanAir() -
doesVaporize
Determines if this fluid should vaporize in dimensions where water vaporizes when placed. To preserve the intentions of vanilla, fluids that can turn lava into obsidian should vaporize. This prevents players from making the nether safe with a single bucket. Based onBucketItem.emptyContents(Player, Level, BlockPos, BlockHitResult)
- Parameters:
fluidStack
- The fluidStack is trying to be placed.- Returns:
- true if this fluid should vaporize in dimensions where water vaporizes when placed.
-
vaporize
Called instead of placing the fluid block ifDimensionType.ultraWarm()
anddoesVaporize(BlockAndTintGetter, BlockPos, FluidStack)
are true. Override this to make your explosive liquid blow up instead of the default smoke, etc. Based onBucketItem.emptyContents(Player, Level, BlockPos, BlockHitResult)
- Parameters:
player
- Player who tried to place the fluid. May be null for blocks like dispensers.worldIn
- World to vaporize the fluid in.pos
- The position in the world the fluid block was going to be placed.fluidStack
- The fluidStack that was going to be placed.
-
getDisplayName
Returns the localized name of this fluid. -
getTranslationKey
A FluidStack sensitive version of getTranslationKey -
getTranslationKey
Returns the translation key of this fluid. -
getLuminosity
public final int getLuminosity() -
getDensity
public final int getDensity() -
getTemperature
public final int getTemperature() -
getViscosity
public final int getViscosity() -
isGaseous
public final boolean isGaseous() -
getRarity
-
getColor
public int getColor() -
getStillTexture
-
getFlowingTexture
-
getOverlayTexture
-
getFillSound
-
getEmptySound
-
getLuminosity
-
getDensity
-
getTemperature
-
getViscosity
-
isGaseous
-
getRarity
-
getColor
-
getStillTexture
-
getFlowingTexture
-
getFillSound
-
getEmptySound
-
getLuminosity
-
getDensity
-
getTemperature
-
getViscosity
-
isGaseous
-
getRarity
-
getColor
-
getStillTexture
-
getFlowingTexture
-
getFillSound
-
getEmptySound
-
builder
public static FluidAttributes.Builder builder(ResourceLocation stillTexture, ResourceLocation flowingTexture) -
getTextures
-