Package net.minecraftforge.fluids
Class FluidStack
java.lang.Object
net.minecraftforge.fluids.FluidStack
ItemStack substitute for Fluids.
 NOTE: Equality is based on the Fluid, not the amount. Use
 
isFluidStackIdentical(FluidStack) to determine if FluidID, Amount and NBT Tag are all
 equal.- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate intstatic final com.mojang.serialization.Codec<FluidStack>static final FluidStackprivate Holder.Reference<Fluid>private booleanprivate static final org.apache.logging.log4j.Loggerprivate CompoundTag
- 
Constructor SummaryConstructorsConstructorDescriptionFluidStack(Fluid fluid, int amount) FluidStack(Fluid fluid, int amount, CompoundTag nbt) FluidStack(FluidStack stack, int amount) 
- 
Method SummaryModifier and TypeMethodDescriptionstatic booleanareFluidStackTagsEqual(@NotNull FluidStack stack1, @NotNull FluidStack stack2) Determines if the NBT Tags are equal.booleancontainsFluid(@NotNull FluidStack other) Determines if the Fluids are equal and this stack is larger.copy()final booleanDefault equality comparison for a FluidStack.intgetChildTag(String childName) final FluidgetFluid()getOrCreateChildTag(String childName) final FluidgetTag()voidgrow(int amount) final inthashCode()booleanhasTag()booleanisEmpty()booleanisFluidEqual(@NotNull ItemStack other) Determines if the FluidIDs and NBT Tags are equal compared to a registered container ItemStack.booleanisFluidEqual(@NotNull FluidStack other) Determines if the FluidIDs and NBT Tags are equal.booleanisFluidStackIdentical(FluidStack other) Determines if the FluidIDs, Amounts, and NBT Tags are all equal.private booleanisFluidStackTagEqual(FluidStack other) static FluidStackThis provides a safe method for retrieving a FluidStack - if the Fluid is invalid, the stack will return as null.static FluidStackvoidremoveChildTag(String childName) voidsetAmount(int amount) voidsetTag(CompoundTag tag) voidshrink(int amount) protected voidwriteToNBT(CompoundTag nbt) void
- 
Field Details- 
LOGGERprivate static final org.apache.logging.log4j.Logger LOGGER
- 
EMPTY
- 
CODEC
- 
isEmptyprivate boolean isEmpty
- 
amountprivate int amount
- 
tag
- 
fluidDelegate
 
- 
- 
Constructor Details- 
FluidStack
- 
FluidStack
- 
FluidStack
 
- 
- 
Method Details- 
loadFluidStackFromNBTThis provides a safe method for retrieving a FluidStack - if the Fluid is invalid, the stack will return as null.
- 
writeToNBT
- 
writeToPacket
- 
readFromPacket
- 
getFluid
- 
getRawFluid
- 
isEmptypublic boolean isEmpty()
- 
updateEmptyprotected void updateEmpty()
- 
getAmountpublic int getAmount()
- 
setAmountpublic void setAmount(int amount) 
- 
growpublic void grow(int amount) 
- 
shrinkpublic void shrink(int amount) 
- 
hasTagpublic boolean hasTag()
- 
getTag
- 
setTag
- 
getOrCreateTag
- 
getChildTag
- 
getOrCreateChildTag
- 
removeChildTag
- 
getDisplayName
- 
getTranslationKey
- 
copy- Returns:
- A copy of this FluidStack
 
- 
isFluidEqualDetermines if the FluidIDs and NBT Tags are equal. This does not check amounts.- Parameters:
- other- The FluidStack for comparison
- Returns:
- true if the Fluids (IDs and NBT Tags) are the same
 
- 
isFluidStackTagEqual
- 
areFluidStackTagsEqualpublic static boolean areFluidStackTagsEqual(@NotNull @NotNull FluidStack stack1, @NotNull @NotNull FluidStack stack2) Determines if the NBT Tags are equal. Useful if the FluidIDs are known to be equal.
- 
containsFluidDetermines if the Fluids are equal and this stack is larger.- Returns:
- true if this FluidStack contains the other FluidStack (same fluid and >= amount)
 
- 
isFluidStackIdenticalDetermines if the FluidIDs, Amounts, and NBT Tags are all equal.- Parameters:
- other- - the FluidStack for comparison
- Returns:
- true if the two FluidStacks are exactly the same
 
- 
isFluidEqualDetermines if the FluidIDs and NBT Tags are equal compared to a registered container ItemStack. This does not check amounts.- Parameters:
- other- The ItemStack for comparison
- Returns:
- true if the Fluids (IDs and NBT Tags) are the same
 
- 
hashCodepublic final int hashCode()
- 
equalsDefault equality comparison for a FluidStack. Same functionality as isFluidEqual(). This is included for use in data structures.
 
-