Class FluidKey
- Direct Known Subclasses:
ColouredFluidKey
,NormalFluidKey
,PotionFluidKey
,SimpleFluidKey
,WeightedFluidKey
public abstract class FluidKey
extends java.lang.Object
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 Modifier and Type Class Description static class
FluidKey.FluidKeyBuilder
-
Field Summary
Fields Modifier and Type Field Description FluidAmount
cohesion
How much this fluid will spread itself around.static FluidAmount
DEFAULT_GAS_COHESION
The defaultcohesion
that gases use: 1/24static FluidAmount
DEFAULT_GAS_DENSITY
The defaultdensity
(andthermalCapacity
) that gases use: 1/160.static FluidAmount
DEFAULT_GAS_VISCOSITY
The defaultviscosity
that gases use: 1/24.FluidAmount
density
How dense this fluid is.static com.google.gson.JsonDeserializer<FluidKey>
DESERIALIZER
FluidEntry
entry
The identifier for thisFluidKey
.ExactFluidFilter
exactFilter
AFluidFilter
that only matches thisFluidKey
.net.minecraft.util.Identifier
flowingSpriteId
Fallback forDefaultFluidVolumeRenderer
to use if it can't find one itself.boolean
gaseous
True if this represents a gas, false if this represents a liquid.int
luminosity
The amount of block light emitted from this fluid.net.minecraft.text.Text
name
The name to use when displaying tooltips for thisFluidKey
specifically.FluidAmount
netherCohesion
Special-case property for fluids to have differentcohesion
values in the nether.FluidAmount
netherViscosity
Special-case property for fluids to have differentviscosity
values in the nether.int
renderColor
The colour to use when rendering thisFluidKey
's specifically.net.minecraft.util.Identifier
spriteId
Fallback forDefaultFluidVolumeRenderer
to use if it can't find one itself.FluidAmount
thermalCapacity
How much energy is required to make this fluid change it's temperature.FluidUnit
unit
Deprecated.Because most of the time you should useunitSet
rather than this.FluidUnitSet
unitSet
All units to use when displaying amounts, capacities, and flow rates to the player.FluidAmount
viscosity
How much this fluid resists attempts to move it around. -
Constructor Summary
Constructors Constructor Description FluidKey(FluidKey.FluidKeyBuilder builder)
-
Method Summary
Modifier and Type Method Description void
addFullTooltip(java.util.List<net.minecraft.text.Text> tooltip, FluidTooltipContext context)
void
addTooltipExtras(FluidTooltipContext context, java.util.List<net.minecraft.text.Text> tooltip)
Add extra data to the tooltip.void
addTooltipExtras(java.util.List<net.minecraft.text.Text> tooltip)
Add extra data to the tooltip.void
addTooltipProperties(FluidTooltipContext context, java.util.List<net.minecraft.text.Text> tooltip)
void
addTooltipProperties(java.util.List<net.minecraft.text.Text> tooltip)
void
addTooltipTemperature(FluidTooltipContext context, java.util.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
equals(java.lang.Object obj)
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.CompoundTag tag)
FluidVolume
fromWorld(net.minecraft.world.WorldView world, net.minecraft.util.math.BlockPos pos)
Called when this is pumped out from the world.java.util.List<net.minecraft.text.Text>
getFullTooltip()
java.util.List<net.minecraft.text.Text>
getFullTooltip(FluidTooltipContext context)
java.util.SortedSet<FluidProperty<?>>
getProperties()
net.minecraft.fluid.Fluid
getRawFluid()
FluidTemperature
getTemperature()
int
hashCode()
boolean
isEmpty()
FluidVolume
readVolume(com.google.gson.JsonObject json)
abstract FluidVolume
readVolume(net.minecraft.nbt.CompoundTag tag)
FluidVolume
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)
.java.lang.String
toString()
net.minecraft.nbt.CompoundTag
toTag()
net.minecraft.nbt.CompoundTag
toTag(net.minecraft.nbt.CompoundTag tag)
java.lang.String
tryRegisterProperty(FluidProperty<?> property)
FluidVolume
withAmount(int amount)
Deprecated.FluidVolume
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.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
-
Method Details
-
fromTag
-
toTag
public final net.minecraft.nbt.CompoundTag toTag() -
toTag
public final net.minecraft.nbt.CompoundTag toTag(net.minecraft.nbt.CompoundTag 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
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getTemperature
- Returns:
- The
FluidTemperature
for this fluid, or null if neither this fluid nor any of it's properties provide the temperature.
-
tryRegisterProperty
@Nullable @CheckReturnValue public final java.lang.String tryRegisterProperty(FluidProperty<?> property)- 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. -
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
public final java.util.List<net.minecraft.text.Text> 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(java.util.List<net.minecraft.text.Text> tooltip, FluidTooltipContext context) -
addTooltipExtras
public final void addTooltipExtras(java.util.List<net.minecraft.text.Text> tooltip)Add extra data to the tooltip. -
addTooltipExtras
public void addTooltipExtras(FluidTooltipContext context, java.util.List<net.minecraft.text.Text> tooltip)Add extra data to the tooltip. -
addTooltipTemperature
public final void addTooltipTemperature(FluidTooltipContext context, java.util.List<net.minecraft.text.Text> tooltip) -
addTooltipProperties
public final void addTooltipProperties(java.util.List<net.minecraft.text.Text> tooltip) -
addTooltipProperties
public final void addTooltipProperties(FluidTooltipContext context, java.util.List<net.minecraft.text.Text> tooltip) -
equals
public final boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public final int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-