Package net.minecraft.item
Class ItemStack
- java.lang.Object
-
- net.zxmushroom63.plugins.BaseData
-
- net.zxmushroom63.plugins.PluginData
-
- net.minecraft.item.ItemStack
-
- All Implemented Interfaces:
org.teavm.jso.JSObject
public final class ItemStack extends PluginData
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.zxmushroom63.plugins.BaseData
BaseData.BooleanCallback, BaseData.BooleanCallbackArr, BaseData.DataBooleanCallback, BaseData.DataBooleanCallbackArr, BaseData.DataDoubleCallback, BaseData.DataDoubleCallbackArr, BaseData.DataFloatCallback, BaseData.DataFloatCallbackArr, BaseData.DataIntCallback, BaseData.DataIntCallbackArr, BaseData.DataObjectCallback, BaseData.DataObjectCallbackArr, BaseData.DataStringCallback, BaseData.DataStringCallbackArr, BaseData.DataVoidCallback, BaseData.DoubleCallback, BaseData.DoubleCallbackArr, BaseData.FloatCallback, BaseData.FloatCallbackArr, BaseData.IntCallback, BaseData.IntCallbackArr, BaseData.ObjectCallback, BaseData.ObjectCallbackArr, BaseData.StringCallback, BaseData.StringCallbackArr, BaseData.VoidCallback
-
-
Field Summary
Fields Modifier and Type Field Description int
animationsToGo
static java.text.DecimalFormat
DECIMALFORMAT
int
stackSize
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEnchantment(Enchantment ench, int level)
+ Adds an enchantment with a desired level on the ItemStack.static boolean
areItemsEqual(ItemStack stackA, ItemStack stackB)
+ Compares Item and damage value of the two stacksstatic boolean
areItemStacksEqual(ItemStack stackA, ItemStack stackB)
+ compares ItemStack argument1 with ItemStack argument2; returns true if both ItemStacks are equalstatic boolean
areItemStackTagsEqual(ItemStack stackA, ItemStack stackB)
boolean
attemptDamageItem(int amount, EaglercraftRandom rand)
+ Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment there is a chance for each point of damage to be negated.boolean
canDestroy(Block blockIn)
boolean
canEditBlocks()
boolean
canHarvestBlock(Block blockIn)
+ Check whether the given Block can be harvested using this ItemStack.boolean
canPlaceOn(Block blockIn)
void
clearCustomName()
+ Clear any custom name set for this ItemStackItemStack
copy()
+ Returns a new stack with the same properties.static ItemStack
copyItemStack(ItemStack stack)
+ Creates a copy of a ItemStack, a null parameters will return a null.void
damageItem(int amount, EntityLivingBase entityIn)
+ Damages the item in the ItemStackvoid
fromNBT(java.lang.String nbt)
static ItemStack
fromPluginData(BaseData data)
Multimap<java.lang.String,AttributeModifier>
getAttributeModifiers()
IChatComponent
getChatComponent()
+ Get a ChatComponent for this Item's display name that shows this Item on hoverjava.lang.String
getDisplayName()
+ returns the display name of the itemstackNBTTagList
getEnchantmentTagList()
boolean
getHasSubtypes()
boolean
getIsItemStackEqual(ItemStack parItemStack)
Item
getItem()
+ Returns the object corresponding to the stack.int
getItemDamage()
EntityItemFrame
getItemFrame()
+ Return the item frame this stack is on.EnumAction
getItemUseAction()
java.lang.String[]
getLore()
int
getMaxDamage()
+ Returns the max damage an item in the stack can take.int
getMaxItemUseDuration()
int
getMaxStackSize()
+ Returns maximum size of the stack.int
getMetadata()
EnumRarity
getRarity()
int
getRepairCost()
+ Get this stack's repair cost, or 0 if no repair cost is defined.float
getStrVsBlock(Block blockIn)
NBTTagCompound
getSubCompound(java.lang.String key, boolean create)
+ Get an NBTTagCompound from this stack's NBT data.NBTTagCompound
getTagCompound()
+ Returns the NBTTagCompound of the ItemStack.java.util.List<java.lang.String>
getTooltip(EntityPlayer playerIn, boolean advanced)
+ Return a list of strings containing information about the itemjava.lang.String
getUnlocalizedName()
boolean
hasDisplayName()
+ Returns true if the itemstack has a display nameboolean
hasEffect()
boolean
hasTagCompound()
+ Returns true if the ItemStack has an NBTTagCompound.void
hitEntity(EntityLivingBase entityIn, EntityPlayer playerIn)
+ Calls the corresponding fct in diboolean
interactWithEntity(EntityPlayer playerIn, EntityLivingBase entityIn)
boolean
isItemDamaged()
+ returns true when a damageable item is damagedboolean
isItemEnchantable()
+ True if it is a tool and has no enchantments to begin withboolean
isItemEnchanted()
+ True if the item has enchantment databoolean
isItemEqual(ItemStack other)
+ compares ItemStack argument to the instance ItemStack; returns true if the Items contained in both ItemStacks are equalboolean
isItemStackDamageable()
+ true if this itemStack is damageableboolean
isOnItemFrame()
+ Return whether this stack is on an item frame.boolean
isStackable()
+ Returns true if the ItemStack can hold 2 or more units of the item.static ItemStack
loadItemStackFromNBT(NBTTagCompound nbt)
void
loadPluginData(BaseData data)
PluginData
makePluginData()
void
onBlockDestroyed(World worldIn, Block blockIn, BlockPos pos, EntityPlayer playerIn)
+ Called when a Block is destroyed using this ItemStackvoid
onCrafting(World worldIn, EntityPlayer playerIn, int amount)
boolean
onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
+ Called when the player uses this ItemStack on a Block (right-click).ItemStack
onItemUseFinish(World worldIn, EntityPlayer playerIn)
+ Called when the item in use count reach 0, e.g.void
onPlayerStoppedUsing(World worldIn, EntityPlayer playerIn, int timeLeft)
+ Called when the player releases the use item button.void
readFromNBT(NBTTagCompound nbt)
+ Read the stack fields from a NBT object.void
setItem(Item newItem)
void
setItemDamage(int meta)
void
setItemFrame(EntityItemFrame frame)
+ Set the item frame this stack is on.void
setLore(java.lang.String[] loreIn)
void
setRepairCost(int cost)
+ Set this stack's repair cost.ItemStack
setStackDisplayName(java.lang.String displayName)
void
setTagCompound(NBTTagCompound nbt)
+ Assigns a NBTTagCompound to the ItemStack, minecraft validates that only non-stackable items can have it.void
setTagInfo(java.lang.String key, NBTBase value)
ItemStack
splitStack(int amount)
+ Splits off a stack of the given amount of this stack and reduces this stack by the amount.java.lang.String
toNBT()
java.lang.String
toString()
void
updateAnimation(World worldIn, Entity entityIn, int inventorySlot, boolean isCurrentItem)
+ Called each tick as long the ItemStack in on player inventory.ItemStack
useItemRightClick(World worldIn, EntityPlayer playerIn)
+ Called whenever this item stack is equipped and right clicked.NBTTagCompound
writeToNBT(NBTTagCompound nbt)
+ Write the stack fields to a NBT object.-
Methods inherited from class net.zxmushroom63.plugins.BaseData
execFuncBaseData, execFuncObject, execFuncString, getBaseData, getBaseDataArr, getBoolean, getBooleanArr, getByte, getByteArr, getChar, getCharArr, getDouble, getDoubleArr, getFloat, getFloatArr, getInt, getIntArr, getObject, getObjectArr, getShort, getShortArr, getString, getStringArr, has, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, setCallbackBoolean, setCallbackBooleanArr, setCallbackBooleanArrWithDataArg, setCallbackBooleanWithDataArg, setCallbackDouble, setCallbackDoubleArr, setCallbackDoubleArrWithDataArg, setCallbackDoubleWithDataArg, setCallbackFloat, setCallbackFloatArr, setCallbackFloatArrWithDataArg, setCallbackFloatWithDataArg, setCallbackInt, setCallbackIntArr, setCallbackIntArrWithDataArg, setCallbackIntWithDataArg, setCallbackObject, setCallbackObjectArr, setCallbackObjectArrWithDataArg, setCallbackObjectWithDataArg, setCallbackString, setCallbackStringArr, setCallbackStringArrWithDataArg, setCallbackStringWithDataArg, setCallbackVoid, setCallbackVoidWithDataArg, setNull
-
-
-
-
Constructor Detail
-
ItemStack
public ItemStack(Block blockIn)
-
ItemStack
public ItemStack(Block blockIn, int amount)
-
ItemStack
public ItemStack(Block blockIn, int amount, int meta)
-
ItemStack
public ItemStack(Item itemIn)
-
ItemStack
public ItemStack(Item itemIn, int amount)
-
ItemStack
public ItemStack(Item itemIn, int amount, int meta)
-
-
Method Detail
-
loadPluginData
public void loadPluginData(BaseData data)
-
makePluginData
public PluginData makePluginData()
-
loadItemStackFromNBT
public static ItemStack loadItemStackFromNBT(NBTTagCompound nbt)
-
splitStack
public ItemStack splitStack(int amount)
+ Splits off a stack of the given amount of this stack and reduces this stack by the amount.
-
getItem
public Item getItem()
+ Returns the object corresponding to the stack.
-
onItemUse
public boolean onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
+ Called when the player uses this ItemStack on a Block (right-click). Places blocks, etc. (Legacy name: tryPlaceItemIntoWorld)
-
getStrVsBlock
public float getStrVsBlock(Block blockIn)
-
useItemRightClick
public ItemStack useItemRightClick(World worldIn, EntityPlayer playerIn)
+ Called whenever this item stack is equipped and right clicked. Returns the new item stack to put in the position where this item is. Args: world, player
-
onItemUseFinish
public ItemStack onItemUseFinish(World worldIn, EntityPlayer playerIn)
+ Called when the item in use count reach 0, e.g. item food eaten. Return the new ItemStack. Args : world, entity
-
writeToNBT
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
+ Write the stack fields to a NBT object. Return the new NBT object.
-
toNBT
public java.lang.String toNBT()
-
fromNBT
public void fromNBT(java.lang.String nbt)
-
readFromNBT
public void readFromNBT(NBTTagCompound nbt)
+ Read the stack fields from a NBT object.
-
getMaxStackSize
public int getMaxStackSize()
+ Returns maximum size of the stack.
-
isStackable
public boolean isStackable()
+ Returns true if the ItemStack can hold 2 or more units of the item.
-
isItemStackDamageable
public boolean isItemStackDamageable()
+ true if this itemStack is damageable
-
getHasSubtypes
public boolean getHasSubtypes()
-
isItemDamaged
public boolean isItemDamaged()
+ returns true when a damageable item is damaged
-
getItemDamage
public int getItemDamage()
-
getMetadata
public int getMetadata()
-
setItemDamage
public void setItemDamage(int meta)
-
getMaxDamage
public int getMaxDamage()
+ Returns the max damage an item in the stack can take.
-
attemptDamageItem
public boolean attemptDamageItem(int amount, EaglercraftRandom rand)
+ Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment there is a chance for each point of damage to be negated. Returns true if it takes more damage than getMaxDamage(). Returns false otherwise or if the ItemStack can't be damaged or if all points of damage are negated.
-
damageItem
public void damageItem(int amount, EntityLivingBase entityIn)
+ Damages the item in the ItemStack
-
hitEntity
public void hitEntity(EntityLivingBase entityIn, EntityPlayer playerIn)
+ Calls the corresponding fct in di
-
onBlockDestroyed
public void onBlockDestroyed(World worldIn, Block blockIn, BlockPos pos, EntityPlayer playerIn)
+ Called when a Block is destroyed using this ItemStack
-
canHarvestBlock
public boolean canHarvestBlock(Block blockIn)
+ Check whether the given Block can be harvested using this ItemStack.
-
interactWithEntity
public boolean interactWithEntity(EntityPlayer playerIn, EntityLivingBase entityIn)
-
copy
public ItemStack copy()
+ Returns a new stack with the same properties.
-
areItemStackTagsEqual
public static boolean areItemStackTagsEqual(ItemStack stackA, ItemStack stackB)
-
areItemStacksEqual
public static boolean areItemStacksEqual(ItemStack stackA, ItemStack stackB)
+ compares ItemStack argument1 with ItemStack argument2; returns true if both ItemStacks are equal
-
areItemsEqual
public static boolean areItemsEqual(ItemStack stackA, ItemStack stackB)
+ Compares Item and damage value of the two stacks
-
isItemEqual
public boolean isItemEqual(ItemStack other)
+ compares ItemStack argument to the instance ItemStack; returns true if the Items contained in both ItemStacks are equal
-
getUnlocalizedName
public java.lang.String getUnlocalizedName()
-
copyItemStack
public static ItemStack copyItemStack(ItemStack stack)
+ Creates a copy of a ItemStack, a null parameters will return a null.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
updateAnimation
public void updateAnimation(World worldIn, Entity entityIn, int inventorySlot, boolean isCurrentItem)
+ Called each tick as long the ItemStack in on player inventory. Used to progress the pickup animation and update maps.
-
onCrafting
public void onCrafting(World worldIn, EntityPlayer playerIn, int amount)
-
getIsItemStackEqual
public boolean getIsItemStackEqual(ItemStack parItemStack)
-
getMaxItemUseDuration
public int getMaxItemUseDuration()
-
getItemUseAction
public EnumAction getItemUseAction()
-
onPlayerStoppedUsing
public void onPlayerStoppedUsing(World worldIn, EntityPlayer playerIn, int timeLeft)
+ Called when the player releases the use item button. Args: world, entityplayer, itemInUseCount
-
hasTagCompound
public boolean hasTagCompound()
+ Returns true if the ItemStack has an NBTTagCompound. Currently used to store enchantments.
-
getTagCompound
public NBTTagCompound getTagCompound()
+ Returns the NBTTagCompound of the ItemStack.
-
getSubCompound
public NBTTagCompound getSubCompound(java.lang.String key, boolean create)
+ Get an NBTTagCompound from this stack's NBT data.
-
getEnchantmentTagList
public NBTTagList getEnchantmentTagList()
-
setTagCompound
public void setTagCompound(NBTTagCompound nbt)
+ Assigns a NBTTagCompound to the ItemStack, minecraft validates that only non-stackable items can have it.
-
getDisplayName
public java.lang.String getDisplayName()
+ returns the display name of the itemstack
-
setStackDisplayName
public ItemStack setStackDisplayName(java.lang.String displayName)
-
setLore
public void setLore(java.lang.String[] loreIn)
-
getLore
public java.lang.String[] getLore()
-
clearCustomName
public void clearCustomName()
+ Clear any custom name set for this ItemStack
-
hasDisplayName
public boolean hasDisplayName()
+ Returns true if the itemstack has a display name
-
getTooltip
public java.util.List<java.lang.String> getTooltip(EntityPlayer playerIn, boolean advanced)
+ Return a list of strings containing information about the item
-
hasEffect
public boolean hasEffect()
-
getRarity
public EnumRarity getRarity()
-
isItemEnchantable
public boolean isItemEnchantable()
+ True if it is a tool and has no enchantments to begin with
-
addEnchantment
public void addEnchantment(Enchantment ench, int level)
+ Adds an enchantment with a desired level on the ItemStack.
-
isItemEnchanted
public boolean isItemEnchanted()
+ True if the item has enchantment data
-
setTagInfo
public void setTagInfo(java.lang.String key, NBTBase value)
-
canEditBlocks
public boolean canEditBlocks()
-
isOnItemFrame
public boolean isOnItemFrame()
+ Return whether this stack is on an item frame.
-
setItemFrame
public void setItemFrame(EntityItemFrame frame)
+ Set the item frame this stack is on.
-
getItemFrame
public EntityItemFrame getItemFrame()
+ Return the item frame this stack is on. Returns null if not on an item frame.
-
getRepairCost
public int getRepairCost()
+ Get this stack's repair cost, or 0 if no repair cost is defined.
-
setRepairCost
public void setRepairCost(int cost)
+ Set this stack's repair cost.
-
getAttributeModifiers
public Multimap<java.lang.String,AttributeModifier> getAttributeModifiers()
-
setItem
public void setItem(Item newItem)
-
getChatComponent
public IChatComponent getChatComponent()
+ Get a ChatComponent for this Item's display name that shows this Item on hover
-
canDestroy
public boolean canDestroy(Block blockIn)
-
canPlaceOn
public boolean canPlaceOn(Block blockIn)
-
-