Package com.ldtteam.structurize.api
Class ItemStackUtils
java.lang.Object
com.ldtteam.structurize.api.ItemStackUtils
Utility methods for the inventories.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancompareItemStacksIgnoreStackSize(net.minecraft.world.item.ItemStack itemStack1, net.minecraft.world.item.ItemStack itemStack2) Method to compare to stacks, ignoring their stacksize.static booleancompareItemStacksIgnoreStackSize(net.minecraft.world.item.ItemStack itemStack1, net.minecraft.world.item.ItemStack itemStack2, boolean matchDamage, boolean matchNBT) Method to compare to stacks, ignoring their stacksize.static booleancompareItemStacksIgnoreStackSize(net.minecraft.world.item.ItemStack itemStack1, net.minecraft.world.item.ItemStack itemStack2, boolean matchDamage, boolean matchNBT, boolean min) Method to compare to stacks, ignoring their stacksize.static Set<net.neoforged.neoforge.items.IItemHandler>getItemHandlersFromProvider(net.minecraft.world.level.block.entity.BlockEntity provider) Method to get all the IItemHandlers from a given Provider.static List<net.minecraft.world.item.ItemStack>getItemStacksOfTileEntity(net.minecraft.nbt.CompoundTag compound, net.minecraft.world.level.block.state.BlockState state) Get itemStack of tileEntityData.static List<net.minecraft.world.item.ItemStack>getListOfStackForEntity(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos) Get the list of required resources for entities.static intgetSize(net.minecraft.world.item.ItemStack stack) get the size of the stack.static booleanisEmpty(@Nullable net.minecraft.world.item.ItemStack stack) Wrapper method to check if a stack is empty.
-
Method Details
-
getItemStacksOfTileEntity
public static List<net.minecraft.world.item.ItemStack> getItemStacksOfTileEntity(net.minecraft.nbt.CompoundTag compound, net.minecraft.world.level.block.state.BlockState state) Get itemStack of tileEntityData. Retrieve the data from the tileEntity.- Parameters:
compound- the tileEntity stored in a compound.state- the block.- Returns:
- the list of itemstacks.
-
getItemHandlersFromProvider
public static Set<net.neoforged.neoforge.items.IItemHandler> getItemHandlersFromProvider(net.minecraft.world.level.block.entity.BlockEntity provider) Method to get all the IItemHandlers from a given Provider.- Parameters:
provider- The provider to get the IItemHandlers from.- Returns:
- A list with all the unique IItemHandlers a provider has.
-
isEmpty
public static boolean isEmpty(@Nullable @Nullable net.minecraft.world.item.ItemStack stack) Wrapper method to check if a stack is empty. Used for easy updating to 1.11.- Parameters:
stack- The stack to check.- Returns:
- True when the stack is empty, false when not.
-
getSize
public static int getSize(net.minecraft.world.item.ItemStack stack) get the size of the stack. This is for compatibility between 1.10 and 1.11- Parameters:
stack- to get the size from- Returns:
- the size of the stack
-
getListOfStackForEntity
public static List<net.minecraft.world.item.ItemStack> getListOfStackForEntity(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos) Get the list of required resources for entities.- Parameters:
entity- the entity object.pos- the placer pos..- Returns:
- a list of stacks.
-
compareItemStacksIgnoreStackSize
public static boolean compareItemStacksIgnoreStackSize(net.minecraft.world.item.ItemStack itemStack1, net.minecraft.world.item.ItemStack itemStack2) Method to compare to stacks, ignoring their stacksize.- Parameters:
itemStack1- The left stack to compare.itemStack2- The right stack to compare.- Returns:
- True when they are equal except the stacksize, false when not.
-
compareItemStacksIgnoreStackSize
public static boolean compareItemStacksIgnoreStackSize(net.minecraft.world.item.ItemStack itemStack1, net.minecraft.world.item.ItemStack itemStack2, boolean matchDamage, boolean matchNBT) Method to compare to stacks, ignoring their stacksize.- Parameters:
itemStack1- The left stack to compare.itemStack2- The right stack to compare.matchDamage- Set to true to match damage data.matchNBT- Set to true to match nbt- Returns:
- True when they are equal except the stacksize, false when not.
-
compareItemStacksIgnoreStackSize
public static boolean compareItemStacksIgnoreStackSize(net.minecraft.world.item.ItemStack itemStack1, net.minecraft.world.item.ItemStack itemStack2, boolean matchDamage, boolean matchNBT, boolean min) Method to compare to stacks, ignoring their stacksize.- Parameters:
itemStack1- The left stack to compare.itemStack2- The right stack to compare.matchDamage- Set to true to match damage data.matchNBT- Set to true to match nbtmin- if the count of stack2 has to be at least the same as stack1.- Returns:
- True when they are equal except the stacksize, false when not.
-