Class FluidKey
- Direct Known Subclasses:
ColouredFluidKey,NormalFluidKey,PotionFluidKey,SimpleFluidKey,WeightedFluidKey
FluidVolume instances. Identifying whether two FluidKey's are equal is always done via
the object identity comparison (== rather than equals(Object) - although FluidKey final-overrides
equals and hashCode to perform identity comparison anyway).-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal FluidAmountHow much this fluid will spread itself around.static final FluidAmountThe defaultcohesionthat gases use: 1/24static final FluidAmountThe defaultdensity(andthermalCapacity) that gases use: 1/160.static final FluidAmountThe defaultviscositythat gases use: 1/24.final FluidAmountHow dense this fluid is.static final com.google.gson.JsonDeserializer<FluidKey>final FluidEntryThe identifier for thisFluidKey.final ExactFluidFilterAFluidFilterthat only matches thisFluidKey.final net.minecraft.util.IdentifierFallback forDefaultFluidVolumeRendererto use if it can't find one itself.final booleanTrue if this represents a gas, false if this represents a liquid.final intThe amount of block light emitted from this fluid.final net.minecraft.text.TextThe name to use when displaying tooltips for thisFluidKeyspecifically.final FluidAmountSpecial-case property for fluids to have differentcohesionvalues in the nether.final FluidAmountSpecial-case property for fluids to have differentviscosityvalues in the nether.final intThe colour to use when rendering thisFluidKey's specifically.final net.minecraft.util.IdentifierFallback forDefaultFluidVolumeRendererto use if it can't find one itself.final FluidAmountHow much energy is required to make this fluid change it's temperature.final FluidUnitDeprecated, for removal: This API element is subject to removal in a future version.final FluidUnitSetAll units to use when displaying amounts, capacities, and flow rates to the player.final FluidAmountHow much this fluid resists attempts to move it around. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddFullTooltip(List<net.minecraft.text.Text> tooltip, FluidTooltipContext context) voidaddTooltipExtras(FluidTooltipContext context, List<net.minecraft.text.Text> tooltip) Add extra data to the tooltip.final voidaddTooltipExtras(List<net.minecraft.text.Text> tooltip) Add extra data to the tooltip.final voidaddTooltipProperties(FluidTooltipContext context, List<net.minecraft.text.Text> tooltip) final voidaddTooltipProperties(List<net.minecraft.text.Text> tooltip) final voidaddTooltipTemperature(FluidTooltipContext context, List<net.minecraft.text.Text> tooltip) protected FluidVolumecreateFromMcBuffer(net.minecraft.network.PacketByteBuf buffer, FluidAmount amount) Creates a newFluidVolumeand reads it from the buffer withFluidVolume.fromMcBufferInternal(PacketByteBuf).final booleanfinal voidforceRegisterProperty(FluidProperty<?> property) Forcibly attempts to register the given property, throwing an exception if the registration fails.static FluidKeyfromJson(com.google.gson.JsonObject json) static FluidKeyfromMcBuffer(net.minecraft.network.PacketByteBuf buffer) Reads aFluidKeyfrom a vanilla minecraftPacketByteBuf.static FluidKeyfromTag(net.minecraft.nbt.NbtCompound tag) fromWorld(net.minecraft.world.WorldView world, net.minecraft.util.math.BlockPos pos) Called when this is pumped out from the world.final List<net.minecraft.text.Text>final List<net.minecraft.text.Text>getFullTooltip(FluidTooltipContext context) final SortedSet<FluidProperty<?>>net.minecraft.fluid.Fluidfinal FluidTemperaturefinal inthashCode()final booleanisEmpty()readVolume(com.google.gson.JsonObject json) abstract FluidVolumereadVolume(net.minecraft.nbt.NbtCompound tag) final FluidVolumereadVolume(net.minecraft.network.PacketByteBuf buffer) Reads aFluidVolumefrom thePacketByteBuf.final voidregister()final com.google.gson.JsonObjecttoJson()The inverse offromJson(JsonObject).final voidtoJson(com.google.gson.JsonObject json) The inverse offromJson(JsonObject).final voidtoMcBuffer(net.minecraft.network.PacketByteBuf buffer) Writes thisFluidKeyto a vanilla minecraftPacketByteBuf, such that it can be read withfromMcBuffer(PacketByteBuf).toString()final net.minecraft.nbt.NbtCompoundtoTag()final net.minecraft.nbt.NbtCompoundtoTag(net.minecraft.nbt.NbtCompound tag) final StringtryRegisterProperty(FluidProperty<?> property) withAmount(int amount) Deprecated, for removal: This API element is subject to removal in a future version.withAmount(FluidAmount amount)
-
Field Details
-
DEFAULT_GAS_VISCOSITY
The defaultviscositythat gases use: 1/24. -
DEFAULT_GAS_COHESION
The defaultcohesionthat gases use: 1/24 -
DEFAULT_GAS_DENSITY
The defaultdensity(andthermalCapacity) that gases use: 1/160. -
DESERIALIZER
-
entry
The identifier for thisFluidKey. Primarily used during serialisation. -
unit
Deprecated, for removal: This API element is subject to removal in a future version.Because most of the time you should useunitSetrather than this.The singular (main) unit to use when displaying amounts, capacities, and flow rates to the player. -
unitSet
All units to use when displaying amounts, capacities, and flow rates to the player. -
spriteId
public final net.minecraft.util.Identifier spriteIdFallback forDefaultFluidVolumeRendererto use if it can't find one itself. -
flowingSpriteId
public final net.minecraft.util.Identifier flowingSpriteIdFallback forDefaultFluidVolumeRendererto use if it can't find one itself. -
renderColor
public final int renderColorThe colour to use when rendering thisFluidKey's specifically.Note that this might differ from the one returned by
FluidVolume.getRenderColor()! -
name
public final net.minecraft.text.Text nameThe name to use when displaying tooltips for thisFluidKeyspecifically.Note that this might differ from the one returned by
FluidVolume.getName()! -
gaseous
public final boolean gaseousTrue if this represents a gas, false if this represents a liquid.it is generally recommended that a gas will have much lower
density,thermalCapacity,viscosity, andcohesionthan any liquid, however this is not technically required. -
viscosity
How much this fluid resists attempts to move it around. For fluid blocks this should generally be the tick-rate of the block, divided by 5. (So for water this is 1, and for lava in the overworld it is 6).It is always an error for any fluid to have a negative (or null) viscosity.
This isn't in any particular unit, and is instead relative to minecraft's water (which LBA declares as
FluidAmount.ONE). -
netherViscosity
Special-case property for fluids to have differentviscosityvalues in the nether.The same rules apply to this field as to
viscosity.(Doing this properly would require a full-on dynamic fluid properties system that could take into account the temperature of the air around it, and would add a lot of complexity before this system has had any testing, so instead we'll just special-case the nether).
-
cohesion
How much this fluid will spread itself around. For fluid blocks this should generally be 8 divided by the block spread distance. (For water this will be 1, and for lava this will be 2).It is always an error for any fluid to have a negative (or null) cohesion.
This isn't in any particular unit, and is instead relative to minecraft's water (which LBA declares as
FluidAmount.ONE). -
netherCohesion
Special-case property for fluids to have differentcohesionvalues in the nether.The same rules apply to this field as to
cohesion.(Doing this properly would require a full-on dynamic fluid properties system that could take into account the temperature of the air around it, and would add a lot of complexity before this system has had any testing, so instead we'll just special-case the nether).
-
density
How dense this fluid is.This isn't in any particular unit, and is instead relative to minecraft's water (which LBA declares as
FluidAmount.ONE). -
thermalCapacity
How much energy is required to make this fluid change it's temperature.LBA doesn't declare any temperature scale (or constant temperature values for specific fluid keys) itself due to the very different approaches that mods might wish to take to temperature.
This isn't in any particular unit, and is instead relative to minecraft's water (which LBA declares as
FluidAmount.ONE). -
luminosity
public final int luminosityThe amount of block light emitted from this fluid. 0-15. (Fluid tanks may use this to emit light, but it's not required). -
exactFilter
AFluidFilterthat only matches thisFluidKey.
-
-
Constructor Details
-
FluidKey
-
-
Method Details
-
fromTag
-
toTag
public final net.minecraft.nbt.NbtCompound toTag() -
toTag
public final net.minecraft.nbt.NbtCompound toTag(net.minecraft.nbt.NbtCompound tag) -
fromJson
public static FluidKey fromJson(com.google.gson.JsonObject json) throws com.google.gson.JsonSyntaxException - Throws:
com.google.gson.JsonSyntaxException
-
toJson
public final com.google.gson.JsonObject toJson()The inverse offromJson(JsonObject). -
toJson
public final void toJson(com.google.gson.JsonObject json) The inverse offromJson(JsonObject).- Parameters:
json- TheJsonObjectto modify.
-
fromMcBuffer
Reads aFluidKeyfrom a vanilla minecraftPacketByteBuf. -
toMcBuffer
public final void toMcBuffer(net.minecraft.network.PacketByteBuf buffer) Writes thisFluidKeyto a vanilla minecraftPacketByteBuf, such that it can be read withfromMcBuffer(PacketByteBuf). -
register
public final void register()Registers thisFluidKeyinto theFluidKeysregistry.You should only ever register a
FluidKey'sFluidEntryinto the registry once, so it may not be necessary to call this method. As such you should only call this onFluidKeys that you have created. -
getRawFluid
@Nullable public net.minecraft.fluid.Fluid getRawFluid() -
toString
-
getTemperature
- Returns:
- The
FluidTemperaturefor this fluid, or null if neither this fluid nor any of it's properties provide the temperature.
-
tryRegisterProperty
- Returns:
- Null if the
FluidPropertywas registered successfully, or a non-null error message containing the reason why it couldn't be added.
-
forceRegisterProperty
Forcibly attempts to register the given property, throwing an exception if the registration fails. -
getProperties
- Returns:
- Every
FluidPropertythat as beenregisteredto thisFluidKey. The returned set is ordered byFluidProperty.id.toString(), to allow server-client sync to happen correctly.
-
readVolume
-
readVolume
public FluidVolume readVolume(com.google.gson.JsonObject json) throws com.google.gson.JsonSyntaxException - Throws:
com.google.gson.JsonSyntaxException
-
readVolume
Reads aFluidVolumefrom thePacketByteBuf. Unfortunately this method is not particularly efficient at encoding -
createFromMcBuffer
protected FluidVolume createFromMcBuffer(net.minecraft.network.PacketByteBuf buffer, FluidAmount amount) Creates a newFluidVolumeand reads it from the buffer withFluidVolume.fromMcBufferInternal(PacketByteBuf). This should not attempt to read properties. -
isEmpty
public final boolean isEmpty() -
withAmount
Deprecated, for removal: This API element is subject to removal in a future version. -
withAmount
-
fromWorld
public FluidVolume fromWorld(net.minecraft.world.WorldView world, net.minecraft.util.math.BlockPos pos) Called when this is pumped out from the world. -
getFullTooltip
- Returns:
- The full tooltip for this
FluidKey. This returns an empty list if this is the empty fluid, or the name and then the extra data fromaddTooltipExtras(List).
-
getFullTooltip
- Returns:
- The full tooltip for this
FluidKey. This returns an empty list if this is the empty fluid, or the name and then the extra data fromaddTooltipExtras(FluidTooltipContext, List).
-
addFullTooltip
public final void addFullTooltip(List<net.minecraft.text.Text> tooltip, FluidTooltipContext context) -
addTooltipExtras
Add extra data to the tooltip. -
addTooltipExtras
Add extra data to the tooltip. -
addTooltipTemperature
public final void addTooltipTemperature(FluidTooltipContext context, List<net.minecraft.text.Text> tooltip) -
addTooltipProperties
-
addTooltipProperties
public final void addTooltipProperties(FluidTooltipContext context, List<net.minecraft.text.Text> tooltip) -
equals
-
hashCode
public final int hashCode()
-
unitSetrather than this.