Package net.minecraftforge.fluids
Class FluidAttributes
- java.lang.Object
-
- net.minecraftforge.fluids.FluidAttributes
-
- Direct Known Subclasses:
FluidAttributes.Water
public class FluidAttributes extends java.lang.Object
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
Nested Classes Modifier and Type Class Description static class
FluidAttributes.Builder
static class
FluidAttributes.Water
-
Field Summary
Fields Modifier and Type Field Description static int
BUCKET_VOLUME
private int
color
Color used by universal bucket and the ModelFluid baked model.private int
density
Density of the fluid - completely arbitrary; negative density indicates that the fluid is lighter than air.private SoundEvent
emptySound
private SoundEvent
fillSound
private ResourceLocation
flowingTexture
private boolean
isGaseous
This indicates if the fluid is gaseous.private int
luminosity
The light level emitted by this fluid.private ResourceLocation
overlayTexture
private Rarity
rarity
The rarity of the fluid.private ResourceLocation
stillTexture
private int
temperature
Temperature of the fluid - completely arbitrary; higher temperature indicates that the fluid is hotter than air.private java.lang.String
translationKey
private int
viscosity
Viscosity ("thickness") of the fluid - completely arbitrary; negative values are not permissible.
-
Constructor Summary
Constructors Modifier Constructor Description protected
FluidAttributes(FluidAttributes.Builder builder, Fluid fluid)
-
Method Summary
-
-
-
Field Detail
-
BUCKET_VOLUME
public static final int BUCKET_VOLUME
- See Also:
- Constant Field Values
-
translationKey
private java.lang.String translationKey
-
stillTexture
private final ResourceLocation stillTexture
-
flowingTexture
private final ResourceLocation flowingTexture
-
overlayTexture
@Nullable private final ResourceLocation overlayTexture
-
fillSound
private final SoundEvent fillSound
-
emptySound
private final SoundEvent emptySound
-
luminosity
private final int luminosity
The light level emitted by this fluid. Default value is 0, as most fluids do not actively emit light.
-
density
private final int density
Density 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 temperature
Temperature 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 viscosity
Viscosity ("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 isGaseous
This indicates if the fluid is gaseous. Generally this is associated with negative density fluids.
-
rarity
private final Rarity rarity
The rarity of the fluid. Used primarily in tool tips.
-
color
private final int color
Color 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 Detail
-
FluidAttributes
protected FluidAttributes(FluidAttributes.Builder builder, Fluid fluid)
-
-
Method Detail
-
getBucket
public ItemStack getBucket(FluidStack stack)
-
getBlock
public BlockState getBlock(IBlockDisplayReader reader, BlockPos pos, FluidState state)
-
getStateForPlacement
public FluidState getStateForPlacement(IBlockDisplayReader reader, BlockPos pos, FluidStack state)
-
canBePlacedInWorld
public final boolean canBePlacedInWorld(IBlockDisplayReader reader, BlockPos pos, FluidState state)
-
canBePlacedInWorld
public final boolean canBePlacedInWorld(IBlockDisplayReader reader, BlockPos pos, FluidStack state)
-
isLighterThanAir
public final boolean isLighterThanAir()
-
doesVaporize
public boolean doesVaporize(IBlockDisplayReader reader, BlockPos pos, FluidStack fluidStack)
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 onnet.minecraft.item.BucketItem#tryPlaceContainedLiquid(PlayerEntity, World, BlockPos)
- Parameters:
fluidStack
- The fluidStack is trying to be placed.- Returns:
- true if this fluid should vaporize in dimensions where water vaporizes when placed.
-
vaporize
public void vaporize(@Nullable PlayerEntity player, World worldIn, BlockPos pos, FluidStack fluidStack)
Called instead of placing the fluid block ifnet.minecraft.world.dimension.Dimension#doesWaterVaporize()
and#doesVaporize(FluidStack)
are true. Override this to make your explosive liquid blow up instead of the default smoke, etc. Based onnet.minecraft.item.BucketItem#tryPlaceContainedLiquid(PlayerEntity, World, BlockPos)
- 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
public ITextComponent getDisplayName(FluidStack stack)
Returns the localized name of this fluid.
-
getTranslationKey
public java.lang.String getTranslationKey(FluidStack stack)
A FluidStack sensitive version of getTranslationKey
-
getTranslationKey
public java.lang.String 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
public Rarity getRarity()
-
getColor
public int getColor()
-
getStillTexture
public ResourceLocation getStillTexture()
-
getFlowingTexture
public ResourceLocation getFlowingTexture()
-
getOverlayTexture
@Nullable public ResourceLocation getOverlayTexture()
-
getFillSound
public SoundEvent getFillSound()
-
getEmptySound
public SoundEvent getEmptySound()
-
getLuminosity
public int getLuminosity(FluidStack stack)
-
getDensity
public int getDensity(FluidStack stack)
-
getTemperature
public int getTemperature(FluidStack stack)
-
getViscosity
public int getViscosity(FluidStack stack)
-
isGaseous
public boolean isGaseous(FluidStack stack)
-
getRarity
public Rarity getRarity(FluidStack stack)
-
getColor
public int getColor(FluidStack stack)
-
getStillTexture
public ResourceLocation getStillTexture(FluidStack stack)
-
getFlowingTexture
public ResourceLocation getFlowingTexture(FluidStack stack)
-
getFillSound
public SoundEvent getFillSound(FluidStack stack)
-
getEmptySound
public SoundEvent getEmptySound(FluidStack stack)
-
getLuminosity
public int getLuminosity(IBlockDisplayReader world, BlockPos pos)
-
getDensity
public int getDensity(IBlockDisplayReader world, BlockPos pos)
-
getTemperature
public int getTemperature(IBlockDisplayReader world, BlockPos pos)
-
getViscosity
public int getViscosity(IBlockDisplayReader world, BlockPos pos)
-
isGaseous
public boolean isGaseous(IBlockDisplayReader world, BlockPos pos)
-
getRarity
public Rarity getRarity(IBlockDisplayReader world, BlockPos pos)
-
getColor
public int getColor(IBlockDisplayReader world, BlockPos pos)
-
getStillTexture
public ResourceLocation getStillTexture(IBlockDisplayReader world, BlockPos pos)
-
getFlowingTexture
public ResourceLocation getFlowingTexture(IBlockDisplayReader world, BlockPos pos)
-
getFillSound
public SoundEvent getFillSound(IBlockDisplayReader world, BlockPos pos)
-
getEmptySound
public SoundEvent getEmptySound(IBlockDisplayReader world, BlockPos pos)
-
builder
public static FluidAttributes.Builder builder(ResourceLocation stillTexture, ResourceLocation flowingTexture)
-
getTextures
public java.util.stream.Stream<ResourceLocation> getTextures()
-
-