public class Item
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Item.ToolMaterial |
Modifier and Type | Field and Description |
---|---|
protected boolean |
bFull3D
If true, render the object in full 3D, like weapons and tools.
|
protected boolean |
canRepair |
RegistryDelegate<Item> |
delegate |
protected boolean |
hasSubtypes
Some items (like dyes) have multiple subtypes on same item, this is field define this behavior
|
protected static java.util.UUID |
itemModifierUUID |
protected static java.util.Random |
itemRand
The RNG used by the Item subclasses.
|
static RegistryNamespaced<ResourceLocation,Item> |
itemRegistry |
protected int |
maxStackSize
Maximum size of the stack.
|
Constructor and Description |
---|
Item() |
Modifier and Type | Method and Description |
---|---|
void |
addInformation(ItemStack stack,
EntityPlayer playerIn,
java.util.List<java.lang.String> tooltip,
boolean advanced)
allows items to add custom lines of information to the mouseover description
|
boolean |
canHarvestBlock(Block blockIn)
Check whether this Item can harvest the given Block
|
boolean |
canHarvestBlock(Block par1Block,
ItemStack itemStack)
ItemStack sensitive version of
canHarvestBlock(Block) |
boolean |
canItemEditBlocks()
Returns true if players can use this item to affect the world (e.g. placing blocks, placing ender eyes in portal)
when not in creative
|
Entity |
createEntity(World world,
Entity location,
ItemStack itemstack)
This function should return a new entity to replace the dropped item.
|
boolean |
doesSneakBypassUse(World world,
BlockPos pos,
EntityPlayer player)
Should this item, when held, allow sneak-clicks to pass through to the underlying block?
|
ModelBiped |
getArmorModel(EntityLivingBase entityLiving,
ItemStack itemStack,
int armorSlot)
Deprecated.
Use 4-argument version.
|
ModelBiped |
getArmorModel(EntityLivingBase entityLiving,
ItemStack itemStack,
int armorSlot,
ModelBiped _default)
Override this method to have an item handle its own armor rendering.
|
java.lang.String |
getArmorTexture(ItemStack stack,
Entity entity,
int slot,
java.lang.String type)
Called by RenderBiped and RenderPlayer to determine the armor texture that
should be use for the currently equipped item.
|
<any> |
getAttributeModifiers(ItemStack stack)
ItemStack sensitive version of getItemAttributeModifiers
|
static Item |
getByNameOrId(java.lang.String id)
Tries to get an Item by it's name (e.g. minecraft:apple) or a String representation of a numerical ID.
|
WeightedRandomChestContent |
getChestGenBase(ChestGenHooks chest,
java.util.Random rnd,
WeightedRandomChestContent original)
Generates the base Random item for a specific instance of the chest gen,
Enchanted books use this to pick a random enchantment.
|
int |
getColorFromItemStack(ItemStack stack,
int renderPass) |
Item |
getContainerItem() |
ItemStack |
getContainerItem(ItemStack itemStack)
ItemStack sensitive version of getContainerItem.
|
CreativeTabs |
getCreativeTab()
gets the CreativeTab this item is displayed on
|
CreativeTabs[] |
getCreativeTabs()
Gets a list of tabs that items belonging to this class can display on,
combined properly with getSubItems allows for a single item to span
many sub-items across many tabs.
|
int |
getDamage(ItemStack stack)
Return the itemDamage represented by this ItemStack.
|
float |
getDigSpeed(ItemStack itemstack,
IBlockState state)
Metadata-sensitive version of getStrVsBlock
|
double |
getDurabilityForDisplay(ItemStack stack)
Queries the percentage of the 'Durability' bar that should be drawn.
|
int |
getEntityLifespan(ItemStack itemStack,
World world)
Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem.
|
FontRenderer |
getFontRenderer(ItemStack stack)
Returns the font renderer used to render tooltips and overlays for this item.
|
int |
getHarvestLevel(ItemStack stack,
java.lang.String toolClass)
Queries the harvest level of this item stack for the specifred tool class,
Returns -1 if this tool is not of the specified type
|
boolean |
getHasSubtypes() |
java.lang.String |
getHighlightTip(ItemStack item,
java.lang.String displayName)
Allow the item one last chance to modify its name used for the
tool highlight useful for adding something extra that can't be removed
by a user in the displayed name, such as a mode of operation.
|
static int |
getIdFromItem(Item itemIn) |
boolean |
getIsRepairable(ItemStack toRepair,
ItemStack repair)
Return whether this item is repairable in an anvil.
|
<any> |
getItemAttributeModifiers()
Deprecated.
|
static Item |
getItemById(int id) |
int |
getItemEnchantability()
Return the enchantability factor of the item, most of the time is based on material.
|
int |
getItemEnchantability(ItemStack stack)
ItemStack sensitive version of getItemEnchantability
|
static Item |
getItemFromBlock(Block blockIn) |
java.lang.String |
getItemStackDisplayName(ItemStack stack) |
int |
getItemStackLimit()
Deprecated.
|
int |
getItemStackLimit(ItemStack stack)
Gets the maximum number of items that this stack should be able to hold.
|
EnumAction |
getItemUseAction(ItemStack stack)
returns the action that specifies what animation to play when the items is being used
|
int |
getMaxDamage()
Returns the maximum damage an item can take.
|
int |
getMaxDamage(ItemStack stack)
Return the maxDamage for this ItemStack.
|
int |
getMaxItemUseDuration(ItemStack stack)
How long it takes to use or consume an item
|
int |
getMetadata(int damage)
Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is
placed as a Block (mostly used with ItemBlocks).
|
int |
getMetadata(ItemStack stack)
This used to be 'display damage' but its really just 'aux' data in the ItemStack, usually shares the same variable as damage.
|
ModelResourceLocation |
getModel(ItemStack stack,
EntityPlayer player,
int useRemaining)
Player, Render pass, and item usage sensitive version of getIconIndex.
|
protected MovingObjectPosition |
getMovingObjectPositionFromPlayer(World worldIn,
EntityPlayer playerIn,
boolean useLiquids) |
java.lang.String |
getPotionEffect(ItemStack stack) |
EnumRarity |
getRarity(ItemStack stack)
Return an item rarity from EnumRarity
|
java.lang.String |
getRegistryName()
A unique identifier for this block, if this block is registered in the game registry it will return that name.
|
boolean |
getShareTag()
If this function returns true (or the item is damageable), the ItemStack's NBT tag will be sent to the client.
|
float |
getSmeltingExperience(ItemStack item)
Determines the base experience for a player when they remove this item from a furnace slot.
|
float |
getStrVsBlock(ItemStack stack,
Block block) |
void |
getSubItems(Item itemIn,
CreativeTabs tab,
java.util.List<ItemStack> subItems)
returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
|
java.util.Set<java.lang.String> |
getToolClasses(ItemStack stack) |
java.lang.String |
getUnlocalizedName()
Returns the unlocalized name of this item.
|
java.lang.String |
getUnlocalizedName(ItemStack stack)
Returns the unlocalized name of this item.
|
java.lang.String |
getUnlocalizedNameInefficiently(ItemStack stack)
Translates the unlocalized name of this item, but without the .name suffix, so the translation fails and the
unlocalized name itself is returned.
|
boolean |
hasContainerItem()
Deprecated.
|
boolean |
hasContainerItem(ItemStack stack)
ItemStack sensitive version of hasContainerItem
|
boolean |
hasCustomEntity(ItemStack stack)
Determines if this Item has a special entity for when they are in the world.
|
boolean |
hasEffect(ItemStack stack) |
boolean |
hitEntity(ItemStack stack,
EntityLivingBase target,
EntityLivingBase attacker)
Current implementations of this method in child classes do not use the entry argument beside ev.
|
ICapabilityProvider |
initCapabilities(ItemStack stack,
NBTTagCompound nbt)
Called from ItemStack.setItem, will hold extra data for the life of this ItemStack.
|
boolean |
isBeaconPayment(ItemStack stack)
Whether this Item can be used as a payment to activate the vanilla beacon.
|
boolean |
isBookEnchantable(ItemStack stack,
ItemStack book)
Allow or forbid the specific book/item combination as an anvil enchant
|
boolean |
isDamageable() |
boolean |
isDamaged(ItemStack stack)
Return if this itemstack is damaged.
|
boolean |
isFull3D()
Returns True is the item is renderer in full 3D when hold.
|
boolean |
isItemTool(ItemStack stack)
Checks isDamagable and if it cannot be stacked
|
boolean |
isMap()
false for all Items except sub-classes of ItemMapBase
|
boolean |
isPotionIngredient(ItemStack stack) |
boolean |
isRepairable()
Called by CraftingManager to determine if an item is reparable.
|
boolean |
isValidArmor(ItemStack stack,
int armorType,
Entity entity)
Determines if the specific ItemStack can be placed in the specified armor slot.
|
boolean |
itemInteractionForEntity(ItemStack stack,
EntityPlayer playerIn,
EntityLivingBase target)
Returns true if the item can be used on the given entity, e.g. shears on sheep.
|
void |
onArmorTick(World world,
EntityPlayer player,
ItemStack itemStack)
Called to tick armor in the armor slot.
|
boolean |
onBlockDestroyed(ItemStack stack,
World worldIn,
Block blockIn,
BlockPos pos,
EntityLivingBase playerIn)
Called when a Block is destroyed using this Item.
|
boolean |
onBlockStartBreak(ItemStack itemstack,
BlockPos pos,
EntityPlayer player)
Called before a block is broken.
|
void |
onCreated(ItemStack stack,
World worldIn,
EntityPlayer playerIn)
Called when item is crafted/smelted.
|
boolean |
onDroppedByPlayer(ItemStack item,
EntityPlayer player)
Called when a player drops the item into the world,
returning false from this will prevent the item from
being removed from the players inventory and spawning
in the world
|
boolean |
onEntityItemUpdate(EntityItem entityItem)
Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner
control over the update of the item without having to write a subclass.
|
boolean |
onEntitySwing(EntityLivingBase entityLiving,
ItemStack stack)
Called when a entity tries to play the 'swing' animation.
|
ItemStack |
onItemRightClick(ItemStack itemStackIn,
World worldIn,
EntityPlayer playerIn)
Called whenever this item is equipped and the right mouse button is pressed.
|
boolean |
onItemUse(ItemStack stack,
EntityPlayer playerIn,
World worldIn,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ)
Called when a Block is right-clicked with this Item
|
ItemStack |
onItemUseFinish(ItemStack stack,
World worldIn,
EntityPlayer playerIn)
Called when the player finishes using this Item (E.g. finishes eating.).
|
boolean |
onItemUseFirst(ItemStack stack,
EntityPlayer player,
World world,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ)
This is called when the item is used, before the block is activated.
|
boolean |
onLeftClickEntity(ItemStack stack,
EntityPlayer player,
Entity entity)
Called when the player Left Clicks (attacks) an entity.
|
void |
onPlayerStoppedUsing(ItemStack stack,
World worldIn,
EntityPlayer playerIn,
int timeLeft)
Called when the player stops using an Item (stops holding the right mouse button).
|
void |
onUpdate(ItemStack stack,
World worldIn,
Entity entityIn,
int itemSlot,
boolean isSelected)
Called each tick as long the item is on a player inventory.
|
void |
onUsingTick(ItemStack stack,
EntityPlayer player,
int count)
Called each tick while using an item.
|
protected static void |
registerItemBlock(Block blockIn,
Item itemIn)
Register the given Item as the ItemBlock for the given Block.
|
static void |
registerItems() |
void |
renderHelmetOverlay(ItemStack stack,
EntityPlayer player,
ScaledResolution resolution,
float partialTicks)
Called when the client starts rendering the HUD, for whatever item the player currently has as a helmet.
|
Item |
setContainerItem(Item containerItem) |
Item |
setCreativeTab(CreativeTabs tab)
returns this;
|
void |
setDamage(ItemStack stack,
int damage)
Set the damage for this itemstack.
|
Item |
setFull3D()
Sets bFull3D to True and return the object.
|
void |
setHarvestLevel(java.lang.String toolClass,
int level)
Sets or removes the harvest level for the specified tool class.
|
Item |
setHasSubtypes(boolean hasSubtypes) |
Item |
setMaxDamage(int maxDamageIn)
set max damage of an Item
|
Item |
setMaxStackSize(int maxStackSize) |
Item |
setNoRepair()
Call to disable repair recipes.
|
Item |
setPotionEffect(java.lang.String potionEffect)
Sets the string representing this item's effect on a potion when used as an ingredient.
|
Item |
setRegistryName(ResourceLocation name) |
Item |
setRegistryName(java.lang.String name)
Sets a unique name for this Item.
|
Item |
setRegistryName(java.lang.String modID,
java.lang.String name) |
Item |
setUnlocalizedName(java.lang.String unlocalizedName)
Sets the unlocalized name of this item to the string passed as the parameter, prefixed by "item."
|
boolean |
shouldCauseReequipAnimation(ItemStack oldStack,
ItemStack newStack,
boolean slotChanged)
Determine if the player switching between these two item stacks
|
boolean |
shouldRotateAroundWhenRendering()
Returns true if this item should be rotated by 180 degrees around the Y axis when being held in an entities
hands.
|
boolean |
showDurabilityBar(ItemStack stack)
Determines if the durability bar should be rendered for this item.
|
boolean |
updateItemStackNBT(NBTTagCompound nbt)
Called when an ItemStack with NBT data is read to potentially that ItemStack's NBT data
|
public static final RegistryNamespaced<ResourceLocation,Item> itemRegistry
protected static final java.util.UUID itemModifierUUID
protected static java.util.Random itemRand
protected int maxStackSize
protected boolean bFull3D
protected boolean hasSubtypes
public final RegistryDelegate<Item> delegate
protected boolean canRepair
public static int getIdFromItem(Item itemIn)
public static Item getItemById(int id)
public static Item getByNameOrId(java.lang.String id)
public boolean updateItemStackNBT(NBTTagCompound nbt)
public Item setMaxStackSize(int maxStackSize)
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
@Deprecated public int getItemStackLimit()
public int getMetadata(int damage)
public boolean getHasSubtypes()
public Item setHasSubtypes(boolean hasSubtypes)
public int getMaxDamage()
public Item setMaxDamage(int maxDamageIn)
public boolean isDamageable()
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn)
public boolean canHarvestBlock(Block blockIn)
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
public Item setFull3D()
public boolean isFull3D()
public boolean shouldRotateAroundWhenRendering()
public Item setUnlocalizedName(java.lang.String unlocalizedName)
public java.lang.String getUnlocalizedNameInefficiently(ItemStack stack)
public java.lang.String getUnlocalizedName()
public java.lang.String getUnlocalizedName(ItemStack stack)
public boolean getShareTag()
public Item getContainerItem()
@Deprecated public boolean hasContainerItem()
public int getColorFromItemStack(ItemStack stack, int renderPass)
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn)
public boolean isMap()
public EnumAction getItemUseAction(ItemStack stack)
public int getMaxItemUseDuration(ItemStack stack)
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft)
public Item setPotionEffect(java.lang.String potionEffect)
public java.lang.String getPotionEffect(ItemStack stack)
public boolean isPotionIngredient(ItemStack stack)
public void addInformation(ItemStack stack, EntityPlayer playerIn, java.util.List<java.lang.String> tooltip, boolean advanced)
public java.lang.String getItemStackDisplayName(ItemStack stack)
public boolean hasEffect(ItemStack stack)
public EnumRarity getRarity(ItemStack stack)
public boolean isItemTool(ItemStack stack)
protected MovingObjectPosition getMovingObjectPositionFromPlayer(World worldIn, EntityPlayer playerIn, boolean useLiquids)
public int getItemEnchantability()
public void getSubItems(Item itemIn, CreativeTabs tab, java.util.List<ItemStack> subItems)
public Item setCreativeTab(CreativeTabs tab)
public CreativeTabs getCreativeTab()
public boolean canItemEditBlocks()
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
@Deprecated public <any> getItemAttributeModifiers()
public <any> getAttributeModifiers(ItemStack stack)
public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player)
player
- The player that dropped the itemitem
- The item stack, before the item is removed.public java.lang.String getHighlightTip(ItemStack item, java.lang.String displayName)
item
- the ItemStack for the item.the
- name that will be displayed unless it is changed in this method.public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
stack
- The Item Stackplayer
- The Player that used the itemworld
- The Current Worldpos
- Target positionside
- The side of the target hitpublic float getDigSpeed(ItemStack itemstack, IBlockState state)
itemstack
- The Item Stackstate
- The block statepublic boolean isRepairable()
public Item setNoRepair()
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player)
itemstack
- The current ItemStackpos
- Block's position in worldplayer
- The Player that is wielding the itempublic void onUsingTick(ItemStack stack, EntityPlayer player, int count)
stack
- The Item being usedplayer
- The Player using the itemcount
- The amount of time in tick the item has been used for continuouslypublic boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
stack
- The Item being usedplayer
- The player that is attackingentity
- The entity being attackedpublic ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
stack
- The item stack to get the icon for.player
- The player holding the itemuseRemaining
- The ticks remaining for the active item.public ItemStack getContainerItem(ItemStack itemStack)
itemStack
- The current ItemStackpublic boolean hasContainerItem(ItemStack stack)
stack
- The current item stackpublic int getEntityLifespan(ItemStack itemStack, World world)
itemStack
- The current ItemStackworld
- The world the entity is inpublic boolean hasCustomEntity(ItemStack stack)
stack
- The current item stackpublic Entity createEntity(World world, Entity location, ItemStack itemstack)
world
- The world objectlocation
- The EntityItem object, useful for getting the position of the entityitemstack
- The current item stackpublic boolean onEntityItemUpdate(EntityItem entityItem)
entityItem
- The entity Itempublic CreativeTabs[] getCreativeTabs()
public float getSmeltingExperience(ItemStack item)
item
- The item stack the player is picking up.public WeightedRandomChestContent getChestGenBase(ChestGenHooks chest, java.util.Random rnd, WeightedRandomChestContent original)
chest
- The chest category to generate forrnd
- World RNGoriginal
- Original result registered with the chest gen hooks.public boolean doesSneakBypassUse(World world, BlockPos pos, EntityPlayer player)
world
- The worldpos
- Block position in worldplayer
- The Player that is wielding the itempublic void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
stack
- The ItemStackarmorType
- Armor slot ID: 0: Helmet, 1: Chest, 2: Legs, 3: Bootsentity
- The entity trying to equip the armorpublic boolean isBookEnchantable(ItemStack stack, ItemStack book)
stack
- The itembook
- The bookpublic java.lang.String getArmorTexture(ItemStack stack, Entity entity, int slot, java.lang.String type)
stack
- ItemStack for the equipped armorentity
- The entity wearing the armorslot
- The slot the armor is intype
- The subtype, can be null or "overlay"public FontRenderer getFontRenderer(ItemStack stack)
stack
- The current item stack@Deprecated public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot, ModelBiped _default)
entityLiving
- The entity wearing the armoritemStack
- The itemStack to render the model ofarmorSlot
- 0=head, 1=torso, 2=legs, 3=feet_default
- Original armor model. Will have attributes set.public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
entityLiving
- The entity swinging the item.stack
- The Item stackpublic void renderHelmetOverlay(ItemStack stack, EntityPlayer player, ScaledResolution resolution, float partialTicks)
stack
- The ItemStack that is equippedplayer
- Reference to the current client entityresolution
- Resolution information about the current viewport and configured GUI ScalepartialTicks
- Partial ticks for the renderer, useful for interpolationpublic int getDamage(ItemStack stack)
stack
- The itemstack that is damagedpublic int getMetadata(ItemStack stack)
stack
- public boolean showDurabilityBar(ItemStack stack)
stack
- The current Item Stackpublic double getDurabilityForDisplay(ItemStack stack)
stack
- The current ItemStackpublic int getMaxDamage(ItemStack stack)
stack
- The itemstack that is damagedpublic boolean isDamaged(ItemStack stack)
isDamageable()
is true.stack
- the stackpublic void setDamage(ItemStack stack, int damage)
stack
- the stackdamage
- the new damage valuepublic boolean canHarvestBlock(Block par1Block, ItemStack itemStack)
canHarvestBlock(Block)
par1Block
- The block trying to harvestitemStack
- The itemstack used to harvest the blockpublic int getItemStackLimit(ItemStack stack)
stack
- The ItemStackpublic void setHarvestLevel(java.lang.String toolClass, int level)
toolClass
- Classlevel
- Harvest level:
Wood: 0
Stone: 1
Iron: 2
Diamond: 3
Gold: 0public java.util.Set<java.lang.String> getToolClasses(ItemStack stack)
public int getHarvestLevel(ItemStack stack, java.lang.String toolClass)
stack
- This item stack instancetoolClass
- Tool Classpublic int getItemEnchantability(ItemStack stack)
stack
- The ItemStackpublic boolean isBeaconPayment(ItemStack stack)
stack
- the ItemStackpublic boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
oldStack
- The old stack that was equippednewStack
- The new stackslotChanged
- If the current equipped slot was changed,
Vanilla does not play the animation if you switch between two
slots that hold the exact same item.public final Item setRegistryName(java.lang.String name)
name
- Unique registry namepublic final Item setRegistryName(ResourceLocation name)
public final Item setRegistryName(java.lang.String modID, java.lang.String name)
public final java.lang.String getRegistryName()
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
stack
- The ItemStacknbt
- NBT of this item serialized, or null.public static void registerItems()