Class FluidUnit
java.lang.Object
alexiil.mc.lib.attributes.fluid.volume.FluidUnitBase
alexiil.mc.lib.attributes.fluid.volume.FluidUnit
- All Implemented Interfaces:
Comparable<FluidUnit>
A single unit that a
There is also a
FluidVolume
may be expressed as, for example a bucket or a bottle.
Units are localised according to the key given, prefixed with LOCALE_KEY_PREFIX
("libblockattributes.fluid_unit."), and suffixed with either LOCALE_KEY_SUFFIX_SINGLE
(".singular"),
LOCALE_KEY_SUFFIX_MULTIPLE
(".plural"), or LOCALE_KEY_SUFFIX_SYMBOL
(".symbol").
Their are several methods for localising fluid amounts, summarised here:
Name | Description | Example (long names) |
---|---|---|
FluidUnitBase.localizeAmount(FluidAmount) |
Unit name and amount together. The plural name will be used if the amount doesn't equal the unit. | 15 Buckets |
FluidUnitBase.localizeAmount(FluidAmount, boolean) |
Similar to the above, but allows you to force the usage of the singular name. | 1 Buckets |
FluidUnitBase.localizeEmptyTank(FluidAmount) |
A tank with no fluid contained. | Empty 10 Bucket Tank |
FluidUnitBase.localizeFullTank(FluidAmount) |
A tank which is completely full. | Full 10 Bucket Tank |
FluidUnitBase.localizeTank(FluidAmount, FluidAmount) |
General-purpose method for all tanks. (If the amount is zero then this delegates to
FluidUnitBase.localizeEmptyTank(FluidAmount) , and if the amount is equal to the capacity then this delegates to
FluidUnitBase.localizeFullTank(FluidAmount) ). |
3 Buckets in a 10 Bucket Tank |
FluidUnitBase.localizeFlowRate(FluidAmount) |
Flow rate of a fluid, in ticks. (This may use seconds if this has been configured to do so, but the passed amount should always be in ticks, or a 1/20 of a second). | 3 Buckets per second |
Text
based version of every method above. (For each of the 2 method variants there's also one
for each which takes a 1620 fixed-fraction integer-based value (old LBA style)).-
Field Summary
-
Constructor Summary
ConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.FluidUnit
(FluidAmount unitAmount, String key) -
Method Summary
Modifier and TypeMethodDescriptionint
net.minecraft.text.Text
getAmount
(FluidAmount amount, boolean forceSingular, net.minecraft.text.Text fluidName, FluidTooltipContext ctx) net.minecraft.text.Text
getEmptyTank
(FluidAmount capacity, FluidTooltipContext ctx) net.minecraft.text.Text
getFlowRate
(FluidAmount amountPerTick, net.minecraft.text.Text fluidName, FluidTooltipContext ctx) net.minecraft.text.Text
getFullTank
(FluidAmount capacity, net.minecraft.text.Text fluidName, FluidTooltipContext ctx) net.minecraft.text.Text
getPartialTank
(FluidAmount amount, FluidAmount capacity, net.minecraft.text.Text fluidName, FluidTooltipContext ctx) localizeAmount
(FluidAmount amount, boolean forceSingular, net.minecraft.text.Text fluidName, FluidTooltipContext ctx) localizeEmptyTank
(FluidAmount capacity, FluidTooltipContext ctx) localizeFlowRate
(FluidAmount amountPerTick, net.minecraft.text.Text fluidName, FluidTooltipContext ctx) localizeFullTank
(FluidAmount capacity, net.minecraft.text.Text fluidName, FluidTooltipContext ctx) localizePartialTank
(FluidAmount amount, FluidAmount capacity, net.minecraft.text.Text fluidName, FluidTooltipContext ctx) Methods inherited from class alexiil.mc.lib.attributes.fluid.volume.FluidUnitBase
getAmount, getAmount, getAmount, getAmount, getAmount, getAmount, getAmount, getEmptyTank, getFlowRate, getFlowRate, getFlowRate, getFullTank, getFullTank, getFullTank, getPartialTank, getPartialTank, getPartialTank, getTank, getTank, getTank, getTank, localizeAmount, localizeAmount, localizeAmount, localizeAmount, localizeAmount, localizeAmount, localizeAmount, localizeEmptyTank, localizeFlowRate, localizeFlowRate, localizeFlowRate, localizeFullTank, localizeFullTank, localizeFullTank, localizePartialTank, localizePartialTank, localizePartialTank, localizeTank, localizeTank, localizeTank, localizeTank
-
Field Details
-
LOCALE_KEY_PREFIX
- See Also:
-
LOCALE_KEY_SUFFIX_SINGLE
- See Also:
-
LOCALE_KEY_SUFFIX_MULTIPLE
- See Also:
-
LOCALE_KEY_SUFFIX_SYMBOL
- See Also:
-
BUCKET
-
BOTTLE
-
-
Constructor Details
-
FluidUnit
Deprecated, for removal: This API element is subject to removal in a future version.Replaced byFluidUnit(FluidAmount, String)
.- Parameters:
key
- The name for this unit. (Please refer toFluidUnit(FluidAmount, String)
for the full description of what language keys you need to add).
-
FluidUnit
- Parameters:
key
- The name for this unit. You should add 3 language keys to your language file for each separate key you make:Name Locale Key Example for Buckets Example for Ingots Singular "libblockattributes.fluid_unit.KEY.singular" Bucket Ingot Plural "libblockattributes.fluid_unit.KEY.plural" Buckets Ingots Singular "libblockattributes.fluid_unit.KEY.symbol" B I
-
-
Method Details
-
localizeAmount
public String localizeAmount(FluidAmount amount, boolean forceSingular, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx) - Specified by:
localizeAmount
in classFluidUnitBase
-
getAmount
public net.minecraft.text.Text getAmount(FluidAmount amount, boolean forceSingular, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx) - Specified by:
getAmount
in classFluidUnitBase
-
localizeEmptyTank
- Specified by:
localizeEmptyTank
in classFluidUnitBase
-
getEmptyTank
- Specified by:
getEmptyTank
in classFluidUnitBase
-
localizeFullTank
public String localizeFullTank(FluidAmount capacity, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx) - Specified by:
localizeFullTank
in classFluidUnitBase
-
getFullTank
public net.minecraft.text.Text getFullTank(FluidAmount capacity, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx) - Specified by:
getFullTank
in classFluidUnitBase
-
localizePartialTank
public String localizePartialTank(FluidAmount amount, FluidAmount capacity, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx) - Specified by:
localizePartialTank
in classFluidUnitBase
-
getPartialTank
public net.minecraft.text.Text getPartialTank(FluidAmount amount, FluidAmount capacity, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx) - Specified by:
getPartialTank
in classFluidUnitBase
-
localizeFlowRate
public String localizeFlowRate(FluidAmount amountPerTick, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx) - Specified by:
localizeFlowRate
in classFluidUnitBase
-
getFlowRate
public net.minecraft.text.Text getFlowRate(FluidAmount amountPerTick, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx) - Specified by:
getFlowRate
in classFluidUnitBase
-
compareTo
- Specified by:
compareTo
in interfaceComparable<FluidUnit>
-
FluidUnit(FluidAmount, String)
.