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 intanimationsToGostatic java.text.DecimalFormatDECIMALFORMATintstackSize
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEnchantment(Enchantment ench, int level)+ Adds an enchantment with a desired level on the ItemStack.static booleanareItemsEqual(ItemStack stackA, ItemStack stackB)+ Compares Item and damage value of the two stacksstatic booleanareItemStacksEqual(ItemStack stackA, ItemStack stackB)+ compares ItemStack argument1 with ItemStack argument2; returns true if both ItemStacks are equalstatic booleanareItemStackTagsEqual(ItemStack stackA, ItemStack stackB)booleanattemptDamageItem(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.booleancanDestroy(Block blockIn)booleancanEditBlocks()booleancanHarvestBlock(Block blockIn)+ Check whether the given Block can be harvested using this ItemStack.booleancanPlaceOn(Block blockIn)voidclearCustomName()+ Clear any custom name set for this ItemStackItemStackcopy()+ Returns a new stack with the same properties.static ItemStackcopyItemStack(ItemStack stack)+ Creates a copy of a ItemStack, a null parameters will return a null.voiddamageItem(int amount, EntityLivingBase entityIn)+ Damages the item in the ItemStackvoidfromNBT(java.lang.String nbt)static ItemStackfromPluginData(BaseData data)Multimap<java.lang.String,AttributeModifier>getAttributeModifiers()IChatComponentgetChatComponent()+ Get a ChatComponent for this Item's display name that shows this Item on hoverjava.lang.StringgetDisplayName()+ returns the display name of the itemstackNBTTagListgetEnchantmentTagList()booleangetHasSubtypes()booleangetIsItemStackEqual(ItemStack parItemStack)ItemgetItem()+ Returns the object corresponding to the stack.intgetItemDamage()EntityItemFramegetItemFrame()+ Return the item frame this stack is on.EnumActiongetItemUseAction()java.lang.String[]getLore()intgetMaxDamage()+ Returns the max damage an item in the stack can take.intgetMaxItemUseDuration()intgetMaxStackSize()+ Returns maximum size of the stack.intgetMetadata()EnumRaritygetRarity()intgetRepairCost()+ Get this stack's repair cost, or 0 if no repair cost is defined.floatgetStrVsBlock(Block blockIn)NBTTagCompoundgetSubCompound(java.lang.String key, boolean create)+ Get an NBTTagCompound from this stack's NBT data.NBTTagCompoundgetTagCompound()+ 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.StringgetUnlocalizedName()booleanhasDisplayName()+ Returns true if the itemstack has a display namebooleanhasEffect()booleanhasTagCompound()+ Returns true if the ItemStack has an NBTTagCompound.voidhitEntity(EntityLivingBase entityIn, EntityPlayer playerIn)+ Calls the corresponding fct in dibooleaninteractWithEntity(EntityPlayer playerIn, EntityLivingBase entityIn)booleanisItemDamaged()+ returns true when a damageable item is damagedbooleanisItemEnchantable()+ True if it is a tool and has no enchantments to begin withbooleanisItemEnchanted()+ True if the item has enchantment databooleanisItemEqual(ItemStack other)+ compares ItemStack argument to the instance ItemStack; returns true if the Items contained in both ItemStacks are equalbooleanisItemStackDamageable()+ true if this itemStack is damageablebooleanisOnItemFrame()+ Return whether this stack is on an item frame.booleanisStackable()+ Returns true if the ItemStack can hold 2 or more units of the item.static ItemStackloadItemStackFromNBT(NBTTagCompound nbt)voidloadPluginData(BaseData data)PluginDatamakePluginData()voidonBlockDestroyed(World worldIn, Block blockIn, BlockPos pos, EntityPlayer playerIn)+ Called when a Block is destroyed using this ItemStackvoidonCrafting(World worldIn, EntityPlayer playerIn, int amount)booleanonItemUse(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).ItemStackonItemUseFinish(World worldIn, EntityPlayer playerIn)+ Called when the item in use count reach 0, e.g.voidonPlayerStoppedUsing(World worldIn, EntityPlayer playerIn, int timeLeft)+ Called when the player releases the use item button.voidreadFromNBT(NBTTagCompound nbt)+ Read the stack fields from a NBT object.voidsetItem(Item newItem)voidsetItemDamage(int meta)voidsetItemFrame(EntityItemFrame frame)+ Set the item frame this stack is on.voidsetLore(java.lang.String[] loreIn)voidsetRepairCost(int cost)+ Set this stack's repair cost.ItemStacksetStackDisplayName(java.lang.String displayName)voidsetTagCompound(NBTTagCompound nbt)+ Assigns a NBTTagCompound to the ItemStack, minecraft validates that only non-stackable items can have it.voidsetTagInfo(java.lang.String key, NBTBase value)ItemStacksplitStack(int amount)+ Splits off a stack of the given amount of this stack and reduces this stack by the amount.java.lang.StringtoNBT()java.lang.StringtoString()voidupdateAnimation(World worldIn, Entity entityIn, int inventorySlot, boolean isCurrentItem)+ Called each tick as long the ItemStack in on player inventory.ItemStackuseItemRightClick(World worldIn, EntityPlayer playerIn)+ Called whenever this item stack is equipped and right clicked.NBTTagCompoundwriteToNBT(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:
toStringin 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)
-
-