Record Class GenericStack
java.lang.Object
java.lang.Record
appeng.api.stacks.GenericStack
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final com.mojang.serialization.Codec<GenericStack> static final com.mojang.serialization.Codec<List<GenericStack>> static final com.mojang.serialization.Codec<List<@Nullable GenericStack>> static final com.mojang.serialization.MapCodec<GenericStack> static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, GenericStack> -
Constructor Summary
ConstructorsConstructorDescriptionGenericStack(AEKey what, long amount) Creates an instance of aGenericStackrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongamount()Returns the value of theamountrecord component.final booleanIndicates whether some other object is "equal to" this one.static @Nullable GenericStackfrom(net.neoforged.neoforge.transfer.fluid.FluidResource resource, long amount) Converts a given fluid resource and amount into a generic stack.static @Nullable GenericStackfrom(net.neoforged.neoforge.transfer.item.ItemResource resource, long amount) Converts a given item resource and amount into a generic stack.static @Nullable GenericStackfromFluidStack(net.neoforged.neoforge.fluids.FluidStack stack) Converts a given fluid stack into a generic stack.static @Nullable GenericStackfromItemStack(net.minecraft.world.item.ItemStack stack) Converts a given item stack into a generic stack, accounting for aGenericStackalready wrapped in anItemStack, unwrapping it automatically.static longgetStackSizeOrZero(@Nullable GenericStack stack) final inthashCode()Returns a hash code value for this object.static booleanisWrapped(net.minecraft.world.item.ItemStack stack) static @Nullable GenericStackreadBuffer(net.minecraft.network.RegistryFriendlyByteBuf buffer) static @Nullable GenericStackreadTag(net.minecraft.world.level.storage.ValueInput input) static GenericStacksum(GenericStack left, GenericStack right) final StringtoString()Returns a string representation of this record class.static GenericStackunwrapItemStack(net.minecraft.world.item.ItemStack stack) what()Returns the value of thewhatrecord component.static net.minecraft.world.item.ItemStackwrapInItemStack(@Nullable GenericStack stack) static net.minecraft.world.item.ItemStackwrapInItemStack(AEKey what, long amount) static voidwriteBuffer(@Nullable GenericStack stack, net.minecraft.network.RegistryFriendlyByteBuf buffer) static voidwriteTag(net.minecraft.world.level.storage.ValueOutput output, @Nullable GenericStack stack)
-
Field Details
-
AMOUNT_FIELD
- See Also:
-
MAP_CODEC
-
CODEC
-
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, GenericStack> STREAM_CODEC -
FAULT_TOLERANT_NULLABLE_LIST_CODEC
public static final com.mojang.serialization.Codec<List<@Nullable GenericStack>> FAULT_TOLERANT_NULLABLE_LIST_CODEC -
FAULT_TOLERANT_LIST_CODEC
-
-
Constructor Details
-
GenericStack
Creates an instance of aGenericStackrecord class.- Parameters:
what- the value for thewhatrecord componentamount- the value for theamountrecord component
-
-
Method Details
-
readBuffer
@Nullable public static @Nullable GenericStack readBuffer(net.minecraft.network.RegistryFriendlyByteBuf buffer) -
writeBuffer
public static void writeBuffer(@Nullable @Nullable GenericStack stack, net.minecraft.network.RegistryFriendlyByteBuf buffer) -
readTag
@Nullable public static @Nullable GenericStack readTag(net.minecraft.world.level.storage.ValueInput input) -
writeTag
public static void writeTag(net.minecraft.world.level.storage.ValueOutput output, @Nullable @Nullable GenericStack stack) -
fromItemStack
@Nullable public static @Nullable GenericStack fromItemStack(net.minecraft.world.item.ItemStack stack) Converts a given item stack into a generic stack, accounting for aGenericStackalready wrapped in anItemStack, unwrapping it automatically. If the item stack is empty, null is returned. -
fromFluidStack
@Nullable public static @Nullable GenericStack fromFluidStack(net.neoforged.neoforge.fluids.FluidStack stack) Converts a given fluid stack into a generic stack. If the fluid stack is empty, null is returned. -
from
@Nullable public static @Nullable GenericStack from(net.neoforged.neoforge.transfer.item.ItemResource resource, long amount) Converts a given item resource and amount into a generic stack. If the resource is empty, null is returned. -
from
@Nullable public static @Nullable GenericStack from(net.neoforged.neoforge.transfer.fluid.FluidResource resource, long amount) Converts a given fluid resource and amount into a generic stack. If the resource is empty, null is returned. -
getStackSizeOrZero
-
wrapInItemStack
public static net.minecraft.world.item.ItemStack wrapInItemStack(@Nullable @Nullable GenericStack stack) -
wrapInItemStack
-
isWrapped
public static boolean isWrapped(net.minecraft.world.item.ItemStack stack) -
unwrapItemStack
-
sum
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
what
Returns the value of thewhatrecord component.- Returns:
- the value of the
whatrecord component
-
amount
public long amount()Returns the value of theamountrecord component.- Returns:
- the value of the
amountrecord component
-