类 FluidStack
java.lang.Object
net.neoforged.neoforge.fluids.FluidStack
- 所有已实现的接口:
DataComponentGetter
,DataComponentHolder
,IDataComponentHolderExtension
,MutableDataComponentHolder
ItemStack
equivalent for fluids.
The main difference is that a fluid stack is always required to have an amount, while an item stack defaults to 1.
Another difference is that the component prototype of a fluid stack is currently always empty, while an item stack gets its component prototype from the item.
Most methods in this class are adapted from ItemStack
.
-
字段概要
字段修饰符和类型字段说明private int
static final com.mojang.serialization.Codec
<FluidStack> A standard codec for fluid stacks that does not accept empty stacks.private final PatchedDataComponentMap
static final FluidStack
private final Fluid
private static final org.slf4j.Logger
static final com.mojang.serialization.MapCodec
<FluidStack> A standard map codec for fluid stacks that does not accept empty stacks.static final com.mojang.serialization.Codec
<FluidStack> A standard codec for fluid stacks that accepts empty stacks, serializing them as{}
.static final StreamCodec
<RegistryFriendlyByteBuf, FluidStack> A stream codec for fluid stacks that accepts empty stacks.static final StreamCodec
<RegistryFriendlyByteBuf, FluidStack> A stream codec for fluid stacks that does not accept empty stacks. -
构造器概要
构造器限定符构造器说明private
FluidStack
(@Nullable Void unused) FluidStack
(Holder<Fluid> fluid, int amount) FluidStack
(Holder<Fluid> fluid, int amount, DataComponentPatch patch) FluidStack
(Fluid fluid, int amount) private
FluidStack
(Fluid fluid, int amount, PatchedDataComponentMap components) -
方法概要
修饰符和类型方法说明void
applyComponents
(DataComponentMap components) Applies a set of component changes to this stack.void
Applies a set of component changes to this stack.copy()
Creates a copy of this fluid stack.Creates a copy of this stack with0
amount.copyWithAmount
(int amount) Creates a copy of this fluid stack with the given amount.static com.mojang.serialization.Codec
<FluidStack> fixedAmountCodec
(int amount) A standard codec for fluid stacks that always deserializes with a fixed amount, and does not accept empty stacks.int
Returns the amount of this stack.Returns thedescription id
of this stack.getFluid()
Returns the fluid in this stack, orFluids.EMPTY
if this stack is empty.Returns the fluid type of this stack.Returns the hover name of this stack.getTags()
void
grow
(int addedAmount) Adds the given amount to this stack.static int
hashFluidAndComponents
(@Nullable FluidStack stack) Hashes the fluid and components of this stack, ignoring the amount.boolean
boolean
boolean
boolean
boolean
boolean
Check if the fluid type of this stack is equal to the given fluid type.boolean
boolean
isEmpty()
Checks if this fluid stack is empty.static boolean
isSameFluid
(FluidStack first, FluidStack second) Checks if the two fluid stacks have the same fluid.static boolean
isSameFluidSameComponents
(FluidStack first, FluidStack second) Checks if the two fluid stacks have the same fluid and components.static com.mojang.serialization.MapCodec
<FluidStack> lenientOptionalFieldOf
(String fieldName) void
limitSize
(int amount) Limits the amount of this stack is at most the given amount.static boolean
matches
(FluidStack first, FluidStack second) Checks if the two fluid stacks are equal.<T> T
remove
(DataComponentType<? extends T> type) Removes a data component.<T> T
set
(DataComponentType<T> type, T component) Sets a data component.void
setAmount
(int amount) Sets the amount of this stack.void
shrink
(int removedAmount) Removes the given amount from this stack.split
(int amount) Splits off a stack of the given amount of this stack and reduces this stack by the amount.toString()
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 net.minecraft.core.component.DataComponentGetter
get, getOrDefault, getTyped, has
从接口继承的方法 net.minecraft.core.component.DataComponentHolder
get, getAllOfType, getOrDefault, has
从接口继承的方法 net.neoforged.neoforge.common.extensions.IDataComponentHolderExtension
addToTooltip, addToTooltip
-
字段详细资料
-
FLUID_NON_EMPTY_CODEC
-
MAP_CODEC
A standard map codec for fluid stacks that does not accept empty stacks. -
CODEC
A standard codec for fluid stacks that does not accept empty stacks. -
OPTIONAL_CODEC
A standard codec for fluid stacks that accepts empty stacks, serializing them as{}
. -
OPTIONAL_STREAM_CODEC
A stream codec for fluid stacks that accepts empty stacks. -
STREAM_CODEC
A stream codec for fluid stacks that does not accept empty stacks. -
LOGGER
private static final org.slf4j.Logger LOGGER -
EMPTY
-
amount
private int amount -
fluid
-
components
-
-
构造器详细资料
-
FluidStack
-
FluidStack
-
FluidStack
-
FluidStack
-
FluidStack
-
-
方法详细资料
-
fixedAmountCodec
A standard codec for fluid stacks that always deserializes with a fixed amount, and does not accept empty stacks.Fluid equivalent of
ItemStack.SINGLE_ITEM_CODEC
. -
getComponents
- 指定者:
getComponents
在接口中DataComponentHolder
-
getComponentsPatch
-
immutableComponents
-
isComponentsPatchEmpty
public boolean isComponentsPatchEmpty() -
isEmpty
public boolean isEmpty()Checks if this fluid stack is empty. -
split
Splits off a stack of the given amount of this stack and reduces this stack by the amount. -
copyAndClear
Creates a copy of this stack with0
amount. -
getFluid
Returns the fluid in this stack, orFluids.EMPTY
if this stack is empty. -
getFluidHolder
-
is
-
is
-
is
-
is
-
is
-
getTags
-
copy
Creates a copy of this fluid stack. -
copyWithAmount
Creates a copy of this fluid stack with the given amount. -
matches
Checks if the two fluid stacks are equal. This checks the fluid, amount, and components.- 返回:
true
if the two fluid stacks have equal fluid, amount, and components
-
isSameFluid
Checks if the two fluid stacks have the same fluid. Ignores amount and components.- 返回:
true
if the two fluid stacks have the same fluid
-
isSameFluidSameComponents
Checks if the two fluid stacks have the same fluid and components. Ignores amount.- 返回:
true
if the two fluid stacks have the same fluid and components
-
lenientOptionalFieldOf
public static com.mojang.serialization.MapCodec<FluidStack> lenientOptionalFieldOf(String fieldName) -
hashFluidAndComponents
Hashes the fluid and components of this stack, ignoring the amount. -
getDescriptionId
Returns thedescription id
of this stack. -
toString
-
set
Sets a data component.- 指定者:
set
在接口中MutableDataComponentHolder
-
remove
Removes a data component.- 指定者:
remove
在接口中MutableDataComponentHolder
-
applyComponents
Applies a set of component changes to this stack.- 指定者:
applyComponents
在接口中MutableDataComponentHolder
-
applyComponents
Applies a set of component changes to this stack.- 指定者:
applyComponents
在接口中MutableDataComponentHolder
-
getHoverName
Returns the hover name of this stack. -
getAmount
public int getAmount()Returns the amount of this stack. -
setAmount
public void setAmount(int amount) Sets the amount of this stack. -
limitSize
public void limitSize(int amount) Limits the amount of this stack is at most the given amount. -
grow
public void grow(int addedAmount) Adds the given amount to this stack. -
shrink
public void shrink(int removedAmount) Removes the given amount from this stack. -
getFluidType
Returns the fluid type of this stack. -
is
Check if the fluid type of this stack is equal to the given fluid type.
-