Class FluidKey

java.lang.Object
alexiil.mc.lib.attributes.fluid.volume.FluidKey
Direct Known Subclasses:
ColouredFluidKey, NormalFluidKey, PotionFluidKey, SimpleFluidKey, WeightedFluidKey

public abstract class FluidKey
extends java.lang.Object
A factory for 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).
  • Field Details

    • DEFAULT_GAS_VISCOSITY

      public static final FluidAmount DEFAULT_GAS_VISCOSITY
      The default viscosity that gases use: 1/24.
    • DEFAULT_GAS_COHESION

      public static final FluidAmount DEFAULT_GAS_COHESION
      The default cohesion that gases use: 1/24
    • DEFAULT_GAS_DENSITY

      public static final FluidAmount DEFAULT_GAS_DENSITY
      The default density (and thermalCapacity) that gases use: 1/160.
    • DESERIALIZER

      public static final com.google.gson.JsonDeserializer<FluidKey> DESERIALIZER
    • entry

      public final FluidEntry entry
      The identifier for this FluidKey. Primarily used during serialisation.
    • unit

      @Deprecated public final FluidUnit unit
      Deprecated.
      Because most of the time you should use unitSet rather than this.
      The singular (main) unit to use when displaying amounts, capacities, and flow rates to the player.
    • unitSet

      public final FluidUnitSet unitSet
      All units to use when displaying amounts, capacities, and flow rates to the player.
    • spriteId

      public final net.minecraft.util.Identifier spriteId
      Fallback for DefaultFluidVolumeRenderer to use if it can't find one itself.
    • flowingSpriteId

      public final net.minecraft.util.Identifier flowingSpriteId
      Fallback for DefaultFluidVolumeRenderer to use if it can't find one itself.
    • renderColor

      public final int renderColor
      The colour to use when rendering this FluidKey's specifically.

      Note that this might differ from the one returned by FluidVolume.getRenderColor()!

    • name

      public final net.minecraft.text.Text name
      The name to use when displaying tooltips for this FluidKey specifically.

      Note that this might differ from the one returned by FluidVolume.getName()!

    • gaseous

      public final boolean gaseous
      True 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, and cohesion than any liquid, however this is not technically required.

    • viscosity

      public final FluidAmount 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

      public final FluidAmount netherViscosity
      Special-case property for fluids to have different viscosity 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

      public final FluidAmount 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

      public final FluidAmount netherCohesion
      Special-case property for fluids to have different cohesion 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

      public final FluidAmount 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

      public final FluidAmount 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 luminosity
      The amount of block light emitted from this fluid. 0-15. (Fluid tanks may use this to emit light, but it's not required).
    • exactFilter

      public final ExactFluidFilter exactFilter
      A FluidFilter that only matches this FluidKey.
  • Constructor Details

  • Method Details

    • fromTag

      public static FluidKey fromTag​(net.minecraft.nbt.CompoundTag tag)
    • 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 of fromJson(JsonObject).
    • toJson

      public final void toJson​(com.google.gson.JsonObject json)
      The inverse of fromJson(JsonObject).
      Parameters:
      json - The JsonObject to modify.
    • fromMcBuffer

      public static FluidKey fromMcBuffer​(net.minecraft.network.PacketByteBuf buffer)
      Reads a FluidKey from a vanilla minecraft PacketByteBuf.
    • toMcBuffer

      public final void toMcBuffer​(net.minecraft.network.PacketByteBuf buffer)
      Writes this FluidKey to a vanilla minecraft PacketByteBuf, such that it can be read with fromMcBuffer(PacketByteBuf).
    • register

      public final void register()
      Registers this FluidKey into the FluidKeys registry.

      You should only ever register a FluidKey's FluidEntry into the registry once, so it may not be necessary to call this method. As such you should only call this on FluidKeys that you have created.

    • getRawFluid

      @Nullable public net.minecraft.fluid.Fluid getRawFluid()
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getTemperature

      public final FluidTemperature 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

      public final void forceRegisterProperty​(FluidProperty<?> property)
      Forcibly attempts to register the given property, throwing an exception if the registration fails.
    • getProperties

      public final java.util.SortedSet<FluidProperty<?>> getProperties()
      Returns:
      Every FluidProperty that as been registered to this FluidKey. The returned set is ordered by FluidProperty.id.toString(), to allow server-client sync to happen correctly.
    • readVolume

      public abstract FluidVolume readVolume​(net.minecraft.nbt.CompoundTag tag)
    • readVolume

      public FluidVolume readVolume​(com.google.gson.JsonObject json) throws com.google.gson.JsonSyntaxException
      Throws:
      com.google.gson.JsonSyntaxException
    • readVolume

      public final FluidVolume readVolume​(net.minecraft.network.PacketByteBuf buffer)
      Reads a FluidVolume from the PacketByteBuf. Unfortunately this method is not particularly efficient at encoding
    • createFromMcBuffer

      protected FluidVolume createFromMcBuffer​(net.minecraft.network.PacketByteBuf buffer, FluidAmount amount)
      Creates a new FluidVolume and reads it from the buffer with FluidVolume.fromMcBufferInternal(PacketByteBuf). This should not attempt to read properties.
    • isEmpty

      public final boolean isEmpty()
    • withAmount

      @Deprecated public FluidVolume withAmount​(int amount)
      Deprecated.
    • withAmount

      public FluidVolume withAmount​(FluidAmount amount)
    • 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 from addTooltipExtras(List).
    • getFullTooltip

      public final java.util.List<net.minecraft.text.Text> getFullTooltip​(FluidTooltipContext context)
      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 from addTooltipExtras(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 class java.lang.Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class java.lang.Object