Class FluidUnit
java.lang.Object
alexiil.mc.lib.attributes.fluid.volume.FluidUnitBase
alexiil.mc.lib.attributes.fluid.volume.FluidUnit
- All Implemented Interfaces:
java.lang.Comparable<FluidUnit>
public final class FluidUnit extends FluidUnitBase implements java.lang.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
Fields Modifier and Type Field Description static FluidUnitBOTTLEstatic FluidUnitBUCKETstatic java.lang.StringLOCALE_KEY_PREFIXstatic java.lang.StringLOCALE_KEY_SUFFIX_MULTIPLEstatic java.lang.StringLOCALE_KEY_SUFFIX_SINGLEstatic java.lang.StringLOCALE_KEY_SUFFIX_SYMBOL -
Constructor Summary
Constructors Constructor Description FluidUnit(int unitAmount, java.lang.String key)Deprecated.Replaced byFluidUnit(FluidAmount, String).FluidUnit(FluidAmount unitAmount, java.lang.String key) -
Method Summary
Modifier and Type Method Description intcompareTo(FluidUnit o)net.minecraft.text.TextgetAmount(FluidAmount amount, boolean forceSingular, net.minecraft.text.Text fluidName, FluidTooltipContext ctx)net.minecraft.text.TextgetEmptyTank(FluidAmount capacity, FluidTooltipContext ctx)net.minecraft.text.TextgetFlowRate(FluidAmount amountPerTick, net.minecraft.text.Text fluidName, FluidTooltipContext ctx)net.minecraft.text.TextgetFullTank(FluidAmount capacity, net.minecraft.text.Text fluidName, FluidTooltipContext ctx)net.minecraft.text.TextgetPartialTank(FluidAmount amount, FluidAmount capacity, net.minecraft.text.Text fluidName, FluidTooltipContext ctx)java.lang.StringlocalizeAmount(FluidAmount amount, boolean forceSingular, net.minecraft.text.Text fluidName, FluidTooltipContext ctx)java.lang.StringlocalizeEmptyTank(FluidAmount capacity, FluidTooltipContext ctx)java.lang.StringlocalizeFlowRate(FluidAmount amountPerTick, net.minecraft.text.Text fluidName, FluidTooltipContext ctx)java.lang.StringlocalizeFullTank(FluidAmount capacity, net.minecraft.text.Text fluidName, FluidTooltipContext ctx)java.lang.StringlocalizePartialTank(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
public static final java.lang.String LOCALE_KEY_PREFIX- See Also:
- Constant Field Values
-
LOCALE_KEY_SUFFIX_SINGLE
public static final java.lang.String LOCALE_KEY_SUFFIX_SINGLE- See Also:
- Constant Field Values
-
LOCALE_KEY_SUFFIX_MULTIPLE
public static final java.lang.String LOCALE_KEY_SUFFIX_MULTIPLE- See Also:
- Constant Field Values
-
LOCALE_KEY_SUFFIX_SYMBOL
public static final java.lang.String LOCALE_KEY_SUFFIX_SYMBOL- See Also:
- Constant Field Values
-
BUCKET
-
BOTTLE
-
-
Constructor Details
-
FluidUnit
@Deprecated public FluidUnit(int unitAmount, java.lang.String key)Deprecated.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:
(But replace "KEY" with the string you pass in here).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 java.lang.String localizeAmount(FluidAmount amount, boolean forceSingular, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx)- Specified by:
localizeAmountin classFluidUnitBase
-
getAmount
public net.minecraft.text.Text getAmount(FluidAmount amount, boolean forceSingular, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx)- Specified by:
getAmountin classFluidUnitBase
-
localizeEmptyTank
- Specified by:
localizeEmptyTankin classFluidUnitBase
-
getEmptyTank
- Specified by:
getEmptyTankin classFluidUnitBase
-
localizeFullTank
public java.lang.String localizeFullTank(FluidAmount capacity, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx)- Specified by:
localizeFullTankin classFluidUnitBase
-
getFullTank
public net.minecraft.text.Text getFullTank(FluidAmount capacity, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx)- Specified by:
getFullTankin classFluidUnitBase
-
localizePartialTank
public java.lang.String localizePartialTank(FluidAmount amount, FluidAmount capacity, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx)- Specified by:
localizePartialTankin classFluidUnitBase
-
getPartialTank
public net.minecraft.text.Text getPartialTank(FluidAmount amount, FluidAmount capacity, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx)- Specified by:
getPartialTankin classFluidUnitBase
-
localizeFlowRate
public java.lang.String localizeFlowRate(FluidAmount amountPerTick, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx)- Specified by:
localizeFlowRatein classFluidUnitBase
-
getFlowRate
public net.minecraft.text.Text getFlowRate(FluidAmount amountPerTick, @Nullable net.minecraft.text.Text fluidName, FluidTooltipContext ctx)- Specified by:
getFlowRatein classFluidUnitBase
-
compareTo
- Specified by:
compareToin interfacejava.lang.Comparable<FluidUnit>
-