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 classFluidKey.FluidKeyBuilder -
Field Summary
Fields Modifier and Type Field Description FluidAmountcohesionHow much this fluid will spread itself around.static FluidAmountDEFAULT_GAS_COHESIONThe defaultcohesionthat gases use: 1/24static FluidAmountDEFAULT_GAS_DENSITYThe defaultdensity(andthermalCapacity) that gases use: 1/160.static FluidAmountDEFAULT_GAS_VISCOSITYThe defaultviscositythat gases use: 1/24.FluidAmountdensityHow dense this fluid is.static com.google.gson.JsonDeserializer<FluidKey>DESERIALIZERFluidEntryentryThe identifier for thisFluidKey.ExactFluidFilterexactFilterAFluidFilterthat only matches thisFluidKey.net.minecraft.util.IdentifierflowingSpriteIdFallback forDefaultFluidVolumeRendererto use if it can't find one itself.booleangaseousTrue if this represents a gas, false if this represents a liquid.intluminosityThe amount of block light emitted from this fluid.net.minecraft.text.TextnameThe name to use when displaying tooltips for thisFluidKeyspecifically.FluidAmountnetherCohesionSpecial-case property for fluids to have differentcohesionvalues in the nether.FluidAmountnetherViscositySpecial-case property for fluids to have differentviscosityvalues in the nether.intrenderColorThe colour to use when rendering thisFluidKey's specifically.net.minecraft.util.IdentifierspriteIdFallback forDefaultFluidVolumeRendererto use if it can't find one itself.FluidAmountthermalCapacityHow much energy is required to make this fluid change it's temperature.FluidUnitunitDeprecated.Because most of the time you should useunitSetrather than this.FluidUnitSetunitSetAll units to use when displaying amounts, capacities, and flow rates to the player.FluidAmountviscosityHow 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 voidaddFullTooltip(java.util.List<net.minecraft.text.Text> tooltip, FluidTooltipContext context)voidaddTooltipExtras(FluidTooltipContext context, java.util.List<net.minecraft.text.Text> tooltip)Add extra data to the tooltip.voidaddTooltipExtras(java.util.List<net.minecraft.text.Text> tooltip)Add extra data to the tooltip.voidaddTooltipProperties(FluidTooltipContext context, java.util.List<net.minecraft.text.Text> tooltip)voidaddTooltipProperties(java.util.List<net.minecraft.text.Text> tooltip)voidaddTooltipTemperature(FluidTooltipContext context, java.util.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).booleanequals(java.lang.Object obj)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.CompoundTag tag)FluidVolumefromWorld(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.FluidgetRawFluid()FluidTemperaturegetTemperature()inthashCode()booleanisEmpty()FluidVolumereadVolume(com.google.gson.JsonObject json)abstract FluidVolumereadVolume(net.minecraft.nbt.CompoundTag tag)FluidVolumereadVolume(net.minecraft.network.PacketByteBuf buffer)Reads aFluidVolumefrom thePacketByteBuf.voidregister()com.google.gson.JsonObjecttoJson()The inverse offromJson(JsonObject).voidtoJson(com.google.gson.JsonObject json)The inverse offromJson(JsonObject).voidtoMcBuffer(net.minecraft.network.PacketByteBuf buffer)Writes thisFluidKeyto a vanilla minecraftPacketByteBuf, such that it can be read withfromMcBuffer(PacketByteBuf).java.lang.StringtoString()net.minecraft.nbt.CompoundTagtoTag()net.minecraft.nbt.CompoundTagtoTag(net.minecraft.nbt.CompoundTag tag)java.lang.StringtryRegisterProperty(FluidProperty<?> property)FluidVolumewithAmount(int amount)Deprecated.FluidVolumewithAmount(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.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
-
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- 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
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
getTemperature
- Returns:
- The
FluidTemperaturefor 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
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. -
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:
equalsin classjava.lang.Object
-
hashCode
public final int hashCode()- Overrides:
hashCodein classjava.lang.Object
-