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 TypeFieldDescriptionHow much this fluid will spread itself around.static FluidAmount
The defaultcohesion
that gases use: 1/24static FluidAmount
The defaultdensity
(andthermalCapacity
) that gases use: 1/160.static FluidAmount
The defaultviscosity
that gases use: 1/24.How dense this fluid is.static com.google.gson.JsonDeserializer<FluidKey>
The identifier for thisFluidKey
.AFluidFilter
that only matches thisFluidKey
.net.minecraft.util.Identifier
Fallback forDefaultFluidVolumeRenderer
to use if it can't find one itself.boolean
True if this represents a gas, false if this represents a liquid.int
The amount of block light emitted from this fluid.net.minecraft.text.Text
The name to use when displaying tooltips for thisFluidKey
specifically.Special-case property for fluids to have differentcohesion
values in the nether.Special-case property for fluids to have differentviscosity
values in the nether.int
The colour to use when rendering thisFluidKey
's specifically.net.minecraft.util.Identifier
Fallback forDefaultFluidVolumeRenderer
to use if it can't find one itself.How much energy is required to make this fluid change it's temperature.Deprecated, for removal: This API element is subject to removal in a future version.All units to use when displaying amounts, capacities, and flow rates to the player.How much this fluid resists attempts to move it around. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.void
addTooltipExtras(List<net.minecraft.text.Text> tooltip)
Add extra data to the tooltip.void
addTooltipProperties(FluidTooltipContext context, List<net.minecraft.text.Text> tooltip)
void
addTooltipProperties(List<net.minecraft.text.Text> tooltip)
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)
.boolean
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.List<net.minecraft.text.Text>
List<net.minecraft.text.Text>
getFullTooltip(FluidTooltipContext context)
net.minecraft.fluid.Fluid
int
hashCode()
boolean
isEmpty()
readVolume(com.google.gson.JsonObject json)
abstract FluidVolume
readVolume(net.minecraft.nbt.NbtCompound tag)
readVolume(net.minecraft.network.PacketByteBuf buffer)
Reads aFluidVolume
from thePacketByteBuf
.void
register()
com.google.gson.JsonObject
toJson()
The inverse offromJson(JsonObject)
.void
toJson(com.google.gson.JsonObject json)
The inverse offromJson(JsonObject)
.void
toMcBuffer(net.minecraft.network.PacketByteBuf buffer)
Writes thisFluidKey
to a vanilla minecraftPacketByteBuf
, such that it can be read withfromMcBuffer(PacketByteBuf)
.toString()
net.minecraft.nbt.NbtCompound
toTag()
net.minecraft.nbt.NbtCompound
toTag(net.minecraft.nbt.NbtCompound tag)
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.