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
-
Field Summary
Modifier and TypeFieldDescriptionfinal FluidAmount
How much this fluid will spread itself around.static final FluidAmount
The defaultcohesion
that gases use: 1/24static final FluidAmount
The defaultdensity
(andthermalCapacity
) that gases use: 1/160.static final FluidAmount
The defaultviscosity
that gases use: 1/24.final FluidAmount
How dense this fluid is.static final com.google.gson.JsonDeserializer<FluidKey>
final FluidEntry
The identifier for thisFluidKey
.final ExactFluidFilter
AFluidFilter
that only matches thisFluidKey
.final net.minecraft.util.Identifier
Fallback forDefaultFluidVolumeRenderer
to use if it can't find one itself.final boolean
True if this represents a gas, false if this represents a liquid.final int
The amount of block light emitted from this fluid.final net.minecraft.text.Text
The name to use when displaying tooltips for thisFluidKey
specifically.final FluidAmount
Special-case property for fluids to have differentcohesion
values in the nether.final FluidAmount
Special-case property for fluids to have differentviscosity
values in the nether.final int
The colour to use when rendering thisFluidKey
's specifically.final net.minecraft.util.Identifier
Fallback forDefaultFluidVolumeRenderer
to use if it can't find one itself.final FluidAmount
How much energy is required to make this fluid change it's temperature.final FluidUnit
Deprecated, for removal: This API element is subject to removal in a future version.final FluidUnitSet
All units to use when displaying amounts, capacities, and flow rates to the player.final FluidAmount
How much this fluid resists attempts to move it around. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addFullTooltip
(List<net.minecraft.text.Text> tooltip, FluidTooltipContext context) void
addTooltipExtras
(FluidTooltipContext context, List<net.minecraft.text.Text> tooltip) Add extra data to the tooltip.final void
addTooltipExtras
(List<net.minecraft.text.Text> tooltip) Add extra data to the tooltip.final void
addTooltipProperties
(FluidTooltipContext context, List<net.minecraft.text.Text> tooltip) final void
addTooltipProperties
(List<net.minecraft.text.Text> tooltip) final void
addTooltipTemperature
(FluidTooltipContext context, List<net.minecraft.text.Text> tooltip) protected FluidVolume
createFromMcBuffer
(net.minecraft.network.PacketByteBuf buffer, FluidAmount amount) Creates a newFluidVolume
and reads it from the buffer withFluidVolume.fromMcBufferInternal(PacketByteBuf)
.final boolean
final void
forceRegisterProperty
(FluidProperty<?> property) Forcibly attempts to register the given property, throwing an exception if the registration fails.static FluidKey
fromJson
(com.google.gson.JsonObject json) static FluidKey
fromMcBuffer
(net.minecraft.network.PacketByteBuf buffer) Reads aFluidKey
from a vanilla minecraftPacketByteBuf
.static FluidKey
fromTag
(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.Fluid
final FluidTemperature
final int
hashCode()
final boolean
isEmpty()
readVolume
(com.google.gson.JsonObject json) abstract FluidVolume
readVolume
(net.minecraft.nbt.NbtCompound tag) final FluidVolume
readVolume
(net.minecraft.network.PacketByteBuf buffer) Reads aFluidVolume
from thePacketByteBuf
.final void
register()
final com.google.gson.JsonObject
toJson()
The inverse offromJson(JsonObject)
.final void
toJson
(com.google.gson.JsonObject json) The inverse offromJson(JsonObject)
.final void
toMcBuffer
(net.minecraft.network.PacketByteBuf buffer) Writes thisFluidKey
to a vanilla minecraftPacketByteBuf
, such that it can be read withfromMcBuffer(PacketByteBuf)
.toString()
final net.minecraft.nbt.NbtCompound
toTag()
final net.minecraft.nbt.NbtCompound
toTag
(net.minecraft.nbt.NbtCompound tag) final String
tryRegisterProperty
(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 defaultviscosity
that gases use: 1/24. -
DEFAULT_GAS_COHESION
The defaultcohesion
that 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 useunitSet
rather 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 forDefaultFluidVolumeRenderer
to use if it can't find one itself. -
flowingSpriteId
public final net.minecraft.util.Identifier flowingSpriteIdFallback forDefaultFluidVolumeRenderer
to 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 thisFluidKey
specifically.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
, andcohesion
than 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 differentviscosity
values 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 differentcohesion
values 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
AFluidFilter
that 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
- TheJsonObject
to modify.
-
fromMcBuffer
Reads aFluidKey
from a vanilla minecraftPacketByteBuf
. -
toMcBuffer
public final void toMcBuffer(net.minecraft.network.PacketByteBuf buffer) Writes thisFluidKey
to a vanilla minecraftPacketByteBuf
, such that it can be read withfromMcBuffer(PacketByteBuf)
. -
register
public final void register()Registers thisFluidKey
into theFluidKeys
registry.You should only ever register a
FluidKey
'sFluidEntry
into the registry once, so it may not be necessary to call this method. As such you should only call this onFluidKey
s that you have created. -
getRawFluid
@Nullable public net.minecraft.fluid.Fluid getRawFluid() -
toString
-
getTemperature
- Returns:
- The
FluidTemperature
for this fluid, or null if neither this fluid nor any of it's properties provide the temperature.
-
tryRegisterProperty
- Returns:
- Null if the
FluidProperty
was 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
FluidProperty
that as beenregistered
to 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 aFluidVolume
from thePacketByteBuf
. Unfortunately this method is not particularly efficient at encoding -
createFromMcBuffer
protected FluidVolume createFromMcBuffer(net.minecraft.network.PacketByteBuf buffer, FluidAmount amount) Creates a newFluidVolume
and 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()
-
unitSet
rather than this.