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.
|
private static java.util.Map<Block,Item> |
BLOCK_TO_ITEM |
private Item |
containerItem |
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 |
private int |
maxDamage
Maximum damage an item can handle.
|
protected int |
maxStackSize
Maximum size of the stack.
|
private java.lang.String |
potionEffect
The string representing this item's effect on a potion when used as an ingredient.
|
private CreativeTabs |
tabToDisplayOn |
private java.lang.String |
unlocalizedName
The unlocalized name of this item.
|
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 |
canItemEditBlocks()
Returns true if players can use this item to affect the world (e.g.
|
static Item |
getByNameOrId(java.lang.String id)
Tries to get an Item by it's name (e.g.
|
int |
getColorFromItemStack(ItemStack stack,
int renderPass) |
Item |
getContainerItem() |
CreativeTabs |
getCreativeTab()
gets the CreativeTab this item is displayed on
|
boolean |
getHasSubtypes() |
static int |
getIdFromItem(Item itemIn) |
boolean |
getIsRepairable(ItemStack toRepair,
ItemStack repair)
Return whether this item is repairable in an anvil.
|
com.google.common.collect.Multimap<java.lang.String,AttributeModifier> |
getItemAttributeModifiers() |
static Item |
getItemById(int id) |
int |
getItemEnchantability()
Return the enchantability factor of the item, most of the time is based on material.
|
static Item |
getItemFromBlock(Block blockIn) |
java.lang.String |
getItemStackDisplayName(ItemStack stack) |
int |
getItemStackLimit()
Returns the maximum size of the stack for a specific item.
|
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 |
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).
|
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
|
boolean |
getShareTag()
If this function returns true (or the item is damageable), the ItemStack's NBT tag will be sent to the client.
|
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.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()
True if this Item has a container item (a.k.a.
|
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.
|
boolean |
isDamageable() |
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 |
itemInteractionForEntity(ItemStack stack,
EntityPlayer playerIn,
EntityLivingBase target)
Returns true if the item can be used on the given entity, e.g.
|
boolean |
onBlockDestroyed(ItemStack stack,
World worldIn,
Block blockIn,
BlockPos pos,
EntityLivingBase playerIn)
Called when a Block is destroyed using this Item.
|
void |
onCreated(ItemStack stack,
World worldIn,
EntityPlayer playerIn)
Called when item is crafted/smelted.
|
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.
|
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.
|
private static void |
registerItem(int id,
ResourceLocation textualID,
Item itemIn) |
private static void |
registerItem(int id,
java.lang.String textualID,
Item itemIn) |
private static void |
registerItemBlock(Block blockIn)
Register a default ItemBlock for the given Block.
|
protected static void |
registerItemBlock(Block blockIn,
Item itemIn)
Register the given Item as the ItemBlock for the given Block.
|
static void |
registerItems() |
Item |
setContainerItem(Item containerItem) |
Item |
setCreativeTab(CreativeTabs tab)
returns this;
|
Item |
setFull3D()
Sets bFull3D to True and return the object.
|
protected Item |
setHasSubtypes(boolean hasSubtypes) |
protected Item |
setMaxDamage(int maxDamageIn)
set max damage of an Item
|
Item |
setMaxStackSize(int maxStackSize) |
protected Item |
setPotionEffect(java.lang.String potionEffect)
Sets the string representing this item's effect on a potion when used as an ingredient.
|
Item |
setUnlocalizedName(java.lang.String unlocalizedName)
Sets the unlocalized name of this item to the string passed as the parameter, prefixed by "item."
|
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 |
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
private CreativeTabs tabToDisplayOn
protected static java.util.Random itemRand
protected int maxStackSize
private int maxDamage
protected boolean bFull3D
protected boolean hasSubtypes
private Item containerItem
private java.lang.String potionEffect
private java.lang.String unlocalizedName
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)
public int getItemStackLimit()
public int getMetadata(int damage)
public boolean getHasSubtypes()
protected Item setHasSubtypes(boolean hasSubtypes)
public int getMaxDamage()
protected 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()
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)
protected 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 CreativeTabs getCreativeTab()
public Item setCreativeTab(CreativeTabs tab)
public boolean canItemEditBlocks()
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
public com.google.common.collect.Multimap<java.lang.String,AttributeModifier> getItemAttributeModifiers()
public static void registerItems()
private static void registerItemBlock(Block blockIn)
protected static void registerItemBlock(Block blockIn, Item itemIn)
private static void registerItem(int id, java.lang.String textualID, Item itemIn)
private static void registerItem(int id, ResourceLocation textualID, Item itemIn)