public class StackUtil
extends java.lang.Object
ItemStack
, and multiples.Modifier and Type | Field and Description |
---|---|
static net.minecraft.item.ItemStack |
EMPTY
A non-null version of
ItemStack.EMPTY . |
Constructor and Description |
---|
StackUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
asNonNull(T obj)
Takes a
Nullable Object and checks to make sure that it is really Nonnull , like it is
everywhere else in the codebase. |
static net.minecraft.item.ItemStack |
asNonNullSoft(net.minecraft.item.ItemStack stack) |
static <T> T |
asNonNullSoft(T obj,
T fallback) |
static boolean |
canMerge(net.minecraft.item.ItemStack a,
net.minecraft.item.ItemStack b)
Checks to see if the two input stacks are equal in all but stack size.
|
static boolean |
canStacksOrListsMerge(net.minecraft.item.ItemStack stack1,
net.minecraft.item.ItemStack stack2) |
static boolean |
contains(IngredientStack ingredientStack,
net.minecraft.item.ItemStack stack)
Checks that passed stack meets stack definition requirements
|
static boolean |
contains(IngredientStack ingredientStack,
net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> stacks)
Checks that passed stack definition acceptable for stack collection
|
static boolean |
contains(net.minecraft.item.ItemStack required,
java.util.Collection<net.minecraft.item.ItemStack> containers)
Checks to see if the given required stack is contained fully in a single stack in a list.
|
static boolean |
contains(net.minecraft.item.ItemStack required,
net.minecraft.item.ItemStack container)
Checks to see if the given required stack is contained fully in the given container stack.
|
static boolean |
contains(StackDefinition stackDefinition,
net.minecraft.item.ItemStack stack)
Checks that passed stack meets stack definition requirements
|
static boolean |
contains(StackDefinition stackDefinition,
net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> stacks)
Checks that passed stack definition acceptable for stack collection
|
static boolean |
containsAll(java.util.Collection<net.minecraft.item.ItemStack> required,
java.util.Collection<net.minecraft.item.ItemStack> containers)
Checks to see if the given required stacks are all contained within the collection of containers.
|
static boolean |
doesEitherStackMatch(net.minecraft.item.ItemStack stackA,
net.minecraft.item.ItemStack stackB) |
static boolean |
doesStackNbtMatch(net.minecraft.item.ItemStack target,
net.minecraft.item.ItemStack with) |
static net.minecraft.item.ItemStack |
getItemStackForState(net.minecraft.block.state.IBlockState state)
Attempts to get an item stack that might place down the given blockstate.
|
static int |
hash(net.minecraft.item.ItemStack stack)
Computes a hash code for the given
ItemStack . |
static boolean |
isCraftingEquivalent(int[] oreIDs,
net.minecraft.item.ItemStack comparison) |
static boolean |
isCraftingEquivalent(net.minecraft.item.ItemStack base,
net.minecraft.item.ItemStack comparison,
boolean oreDictionary)
Determines whether the given ItemStack should be considered equivalent for crafting purposes.
|
static boolean |
isEqualItem(net.minecraft.item.ItemStack base,
net.minecraft.item.ItemStack comparison)
This variant also checks damage for damaged items.
|
static boolean |
isMatchingItem(net.minecraft.item.ItemStack base,
net.minecraft.item.ItemStack comparison)
Compares item id, damage and NBT.
|
static boolean |
isMatchingItem(net.minecraft.item.ItemStack base,
net.minecraft.item.ItemStack comparison,
boolean matchDamage,
boolean matchNBT)
Compares item id, and optionally damage and NBT.
|
static boolean |
isMatchingItemOrList(net.minecraft.item.ItemStack base,
net.minecraft.item.ItemStack comparison) |
static boolean |
isWildcard(int damage)
Checks to see if the given
ItemStack is considered to be a wildcard stack - that is any damage value on
the stack will be considered the same as this for recipe purposes. |
static boolean |
isWildcard(net.minecraft.item.ItemStack stack)
Checks to see if the given
ItemStack is considered to be a wildcard stack - that is any damage value on
the stack will be considered the same as this for recipe purposes. |
static net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> |
listOf() |
static net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> |
listOf(net.minecraft.item.ItemStack... stacks)
Creates a
NonNullList of ItemStack 's with the elements given in the order that they are given. |
static net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> |
mergeSameItems(java.util.List<net.minecraft.item.ItemStack> items) |
static int |
mergeStacks(net.minecraft.item.ItemStack mergeSource,
net.minecraft.item.ItemStack mergeTarget,
boolean doMerge)
Merges mergeSource into mergeTarget
|
static <E> java.util.stream.Collector<E,?,net.minecraft.util.NonNullList<E>> |
nonNullListCollector() |
static net.minecraft.nbt.NBTTagCompound |
stripNonFunctionNbt(net.minecraft.item.ItemStack from) |
@Nonnull public static final net.minecraft.item.ItemStack EMPTY
ItemStack.EMPTY
. When the original field adds an @Nonnull annotation this should
be inlined.public static boolean canMerge(@Nonnull net.minecraft.item.ItemStack a, @Nonnull net.minecraft.item.ItemStack b)
@Nonnull public static net.minecraft.item.ItemStack getItemStackForState(net.minecraft.block.state.IBlockState state)
public static boolean contains(@Nonnull net.minecraft.item.ItemStack required, @Nonnull net.minecraft.item.ItemStack container)
public static boolean contains(@Nonnull net.minecraft.item.ItemStack required, java.util.Collection<net.minecraft.item.ItemStack> containers)
public static boolean contains(@Nonnull StackDefinition stackDefinition, @Nonnull net.minecraft.item.ItemStack stack)
public static boolean contains(@Nonnull StackDefinition stackDefinition, @Nonnull net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> stacks)
public static boolean contains(@Nonnull IngredientStack ingredientStack, @Nonnull net.minecraft.item.ItemStack stack)
public static boolean contains(@Nonnull IngredientStack ingredientStack, @Nonnull net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> stacks)
public static boolean containsAll(java.util.Collection<net.minecraft.item.ItemStack> required, java.util.Collection<net.minecraft.item.ItemStack> containers)
public static net.minecraft.nbt.NBTTagCompound stripNonFunctionNbt(@Nonnull net.minecraft.item.ItemStack from)
public static boolean doesStackNbtMatch(@Nonnull net.minecraft.item.ItemStack target, @Nonnull net.minecraft.item.ItemStack with)
public static boolean doesEitherStackMatch(@Nonnull net.minecraft.item.ItemStack stackA, @Nonnull net.minecraft.item.ItemStack stackB)
public static boolean canStacksOrListsMerge(@Nonnull net.minecraft.item.ItemStack stack1, @Nonnull net.minecraft.item.ItemStack stack2)
public static int mergeStacks(@Nonnull net.minecraft.item.ItemStack mergeSource, @Nonnull net.minecraft.item.ItemStack mergeTarget, boolean doMerge)
mergeSource
- - The stack to merge into mergeTarget, this stack is not modifiedmergeTarget
- - The target merge, this stack is modified if doMerge is setdoMerge
- - To actually do the mergepublic static boolean isCraftingEquivalent(@Nonnull net.minecraft.item.ItemStack base, @Nonnull net.minecraft.item.ItemStack comparison, boolean oreDictionary)
base
- The stack to compare to.comparison
- The stack to compare.oreDictionary
- true to take the Forge OreDictionary into account.public static boolean isCraftingEquivalent(int[] oreIDs, net.minecraft.item.ItemStack comparison)
public static boolean isMatchingItemOrList(net.minecraft.item.ItemStack base, net.minecraft.item.ItemStack comparison)
public static boolean isMatchingItem(@Nonnull net.minecraft.item.ItemStack base, @Nonnull net.minecraft.item.ItemStack comparison)
base
- The stack to compare to.comparison
- The stack to compare.public static boolean isEqualItem(@Nonnull net.minecraft.item.ItemStack base, @Nonnull net.minecraft.item.ItemStack comparison)
public static boolean isMatchingItem(@Nonnull net.minecraft.item.ItemStack base, @Nonnull net.minecraft.item.ItemStack comparison, boolean matchDamage, boolean matchNBT)
base
- ItemStackcomparison
- ItemStackmatchDamage
- matchNBT
- public static boolean isWildcard(@Nonnull net.minecraft.item.ItemStack stack)
ItemStack
is considered to be a wildcard stack - that is any damage value on
the stack will be considered the same as this for recipe purposes.stack
- The stack to checkpublic static boolean isWildcard(int damage)
ItemStack
is considered to be a wildcard stack - that is any damage value on
the stack will be considered the same as this for recipe purposes.damage
- The damage to checkpublic static net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> listOf()
public static net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> listOf(net.minecraft.item.ItemStack... stacks)
NonNullList
of ItemStack
's with the elements given in the order that they are given.stacks
- The stacks to put into a listNonNullList
of all the given items. Note that the returned list of of a specified size, and
cannot be expanded.@Nonnull public static <T> T asNonNull(@Nullable T obj)
Nullable
Object
and checks to make sure that it is really Nonnull
, like it is
everywhere else in the codebase. This is only required if some classes do not use the Nonnull
annotation
on return values.obj
- The (potentially) null object.Nonnull
object, which will be the input objectjava.lang.NullPointerException
- if the input object was actually null (Although this should never happen, this is
more to catch bugs in dev.)@Nonnull public static <T> T asNonNullSoft(@Nullable T obj, @Nonnull T fallback)
@Nonnull public static net.minecraft.item.ItemStack asNonNullSoft(@Nullable net.minecraft.item.ItemStack stack)
public static <E> java.util.stream.Collector<E,?,net.minecraft.util.NonNullList<E>> nonNullListCollector()
Collector
that will collect the input elements into a NonNullList
public static int hash(@Nonnull net.minecraft.item.ItemStack stack)
ItemStack
. This is based off of ItemStack.serializeNBT()
,
except if ItemStack.isEmpty()
returns true, in which case the hash will be 0.public static net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> mergeSameItems(java.util.List<net.minecraft.item.ItemStack> items)