public final class ItemStackUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areStacksEqual(net.minecraft.item.ItemStack firstStack,
net.minecraft.item.ItemStack secondStack,
boolean checkNBT)
Checks if two given ItemStack are equal.
|
static boolean |
areStacksSimilar(net.minecraft.item.ItemStack firstStack,
net.minecraft.item.ItemStack secondStack)
Checks to see if two ItemStacks are similar.
|
static boolean |
areStacksSimilarWithSize(net.minecraft.item.ItemStack firstStack,
net.minecraft.item.ItemStack secondStack)
Checks to see if two ItemStacks are similar.
|
static boolean |
compareStackToOreName(net.minecraft.item.ItemStack stack,
java.lang.String oreName)
Compares all ore dictionary names associated with an ItemStack, with the provided ore
dictionary name.
|
static net.minecraft.item.ItemStack |
consumeStack(net.minecraft.item.ItemStack stack)
Safely consumes an item from an ItemStack.
|
static net.minecraft.item.ItemStack |
copyStackWithSize(net.minecraft.item.ItemStack stack,
int size)
Copies an ItemStack with a new size value.
|
static net.minecraft.item.ItemStack |
createStackFromString(java.lang.String stackString)
Reads an ItemStack from a string This method is intended for use in reading information
from a configuration file.
|
static net.minecraft.item.ItemStack |
createStackFromTileEntity(net.minecraft.tileentity.TileEntity tile)
Creates an ItemStack which represents a TileEntity, and has all of the TileEntities
properties stored.
|
static net.minecraft.item.ItemStack |
decreaseStackSize(net.minecraft.item.ItemStack stack,
int amount)
Safely decreases the amount of items held by an ItemStack.
|
static boolean |
doStacksShareOreName(net.minecraft.item.ItemStack firstStack,
net.minecraft.item.ItemStack secondStack)
Compares all applicable ore dictionary names for two item stacks, to see if either have
a name in common.
|
static void |
dropStackInWorld(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.item.ItemStack stack)
Safely drops an ItemStack intot he world.
|
static net.minecraft.block.Block |
getBlockFromStack(net.minecraft.item.ItemStack stack)
Safely gets a block instance from an ItemStack.
|
static net.minecraft.item.ItemStack |
getStackFromState(net.minecraft.block.state.IBlockState state,
int size)
Creates an ItemStack representation of an IBlockState.
|
static java.lang.Object |
getThingByName(java.lang.String name)
A blend between the itemRegistry.getObject and bockRegistry.getObject methods.
|
static boolean |
isStackInArray(net.minecraft.item.ItemStack stack,
boolean checkNBT,
net.minecraft.item.ItemStack... stacks)
A check to see if an ItemStack exists within an array of other ItemStack.
|
static net.minecraft.nbt.NBTTagCompound |
prepareDataTag(net.minecraft.item.ItemStack stack)
Sets a stack compound to an ItemStack if it does not already have one.
|
static void |
readTileEntityFromStack(net.minecraft.tileentity.TileEntity tile,
net.minecraft.item.ItemStack stack)
Reads tile entity data from an ItemStack.
|
static net.minecraft.item.ItemStack |
setLore(net.minecraft.item.ItemStack stack,
java.lang.String[] lore)
Sets the lore for an ItemStack.
|
static net.minecraft.item.ItemStack |
writePotionEffectsToStack(net.minecraft.item.ItemStack stack,
net.minecraft.potion.PotionEffect[] effects) |
static java.lang.String |
writeStackToString(net.minecraft.item.ItemStack stack)
Writes an ItemStack as a String.
|
static void |
writeStackToTag(net.minecraft.item.ItemStack stack,
net.minecraft.nbt.NBTTagCompound tag,
java.lang.String tagName)
Writes an ItemStack as a sub NBTTagCompound on a larger NBTTagCompound.
|
public static net.minecraft.nbt.NBTTagCompound prepareDataTag(net.minecraft.item.ItemStack stack)
stackItemStack - having a tag set on it.public static net.minecraft.item.ItemStack setLore(net.minecraft.item.ItemStack stack,
java.lang.String[] lore)
stackAn - instance of an ItemStack to write the lore to.loreAn - array containing the lore to write. Each line is a new entry.public static java.lang.String writeStackToString(net.minecraft.item.ItemStack stack)
stackThe - instance of ItemStack to write.public static net.minecraft.item.ItemStack createStackFromString(java.lang.String stackString)
stackStringThe - string used to construct an ItemStack.public static boolean compareStackToOreName(net.minecraft.item.ItemStack stack,
java.lang.String oreName)
stackThe - ItemStack to compare against.oreNameThe - ore dictionary name to compare to.public static boolean doStacksShareOreName(net.minecraft.item.ItemStack firstStack,
net.minecraft.item.ItemStack secondStack)
firstStackThe - first ItemStack to compare.secondStackThe - second ItemStack to compare.public static boolean areStacksSimilar(@Nonnull
net.minecraft.item.ItemStack firstStack,
@Nonnull
net.minecraft.item.ItemStack secondStack)
firstStackThe - first stack to check.secondStackThe - second stack to check.public static boolean areStacksSimilarWithSize(@Nonnull
net.minecraft.item.ItemStack firstStack,
@Nonnull
net.minecraft.item.ItemStack secondStack)
firstStackThe - first stack to check.secondStackThe - second stack to check.public static net.minecraft.item.ItemStack writePotionEffectsToStack(@Nonnull
net.minecraft.item.ItemStack stack,
net.minecraft.potion.PotionEffect[] effects)
public static void writeStackToTag(@Nonnull
net.minecraft.item.ItemStack stack,
net.minecraft.nbt.NBTTagCompound tag,
java.lang.String tagName)
stackThe - ItemStack to write to the tag.tagThe - NBTTagCompound to write the stack to.tagNameThe - name for this new NBTTagCompound entry.public static net.minecraft.item.ItemStack decreaseStackSize(net.minecraft.item.ItemStack stack,
int amount)
stackThe - ItemStack to decrease the size of.amountThe - amount to decrease the stack size by.public static boolean areStacksEqual(net.minecraft.item.ItemStack firstStack,
net.minecraft.item.ItemStack secondStack,
boolean checkNBT)
firstStack - The first ItemStack to compare.secondStack - The second ItemStack to compare.checkNBT - Should NBT be checked as well?public static boolean isStackInArray(net.minecraft.item.ItemStack stack,
boolean checkNBT,
net.minecraft.item.ItemStack... stacks)
stackThe - ItemStack you are searching for.checkNBTShould - the stacks need the same NBT for them to be the same?stacksThe - array of ItemStack to search through.public static net.minecraft.item.ItemStack copyStackWithSize(net.minecraft.item.ItemStack stack,
int size)
stack - The ItemStack to copy.size - The new size to set for the stack.public static java.lang.Object getThingByName(java.lang.String name)
name - The ID of the thing you're looking for. Domains are often preferred.public static net.minecraft.block.Block getBlockFromStack(net.minecraft.item.ItemStack stack)
stack - The ItemStack to get a block from.public static net.minecraft.item.ItemStack consumeStack(net.minecraft.item.ItemStack stack)
stack - The stack to use.public static void dropStackInWorld(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
net.minecraft.item.ItemStack stack)
world - The world to drop the item in.pos - The base pos to drop the item.stack - The stack to drop.public static net.minecraft.item.ItemStack createStackFromTileEntity(net.minecraft.tileentity.TileEntity tile)
tile - The TileEntity to turn into an ItemStack.public static void readTileEntityFromStack(net.minecraft.tileentity.TileEntity tile,
net.minecraft.item.ItemStack stack)
createStackFromTileEntity(TileEntity).tile - The tile to apply the changes to.stack - The stack to read from.public static net.minecraft.item.ItemStack getStackFromState(net.minecraft.block.state.IBlockState state,
int size)
state - The state to use.size - The stack size to create.