Unique Item Attributes - 1.8
A lot of subcode that items have isn't actually required to be typed out. This page gives examples of a few things that you can look at for item effects.
The following options go inside the constructor. Example of the super is below.
public MyFirstItem()
{
super();
setCreativeTab(Tutorial.myFirstTab);
setMaxStackSize(20); //default is 64, don't make it above that
setMaxDamage(420);
}
CreativeTab = the creative tab it will be in.
MaxStackSize is how many items can be in one stack.
MaxDamage is the amount of uses an item will have. Mainly used for tools.
@Override
@SideOnly(Side.CLIENT)
public EnumRarity getRarity(ItemStack itemstack)
{
return EnumRarity.rare;
}
EnumRarity gets the items name to change color. The types of rarities are common, uncommon, rare and epic. Common is just the default white lettering.
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool)
{
list.add(EnumChatFormatting.RED + "Oops, forgot a piece of redstone here...");
list.add("Never can have enough can you?");
}
addInformation will give your item a little box and description or message. You can also incorporate colors by using the EnumChatFormatting class. By adding multiple entries it will create multiple lines.
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
{
return itemstack;
}
This will run some code when the item is right clicked.
public boolean hitEntity(ItemStack itemstack, EntityLiving hitEntity, EntityLiving userEntity)
{
return false;
}
If you return true, this will run some code if you hit a mob with your item.
public boolean onBlockDestroyed(ItemStack itemstack, World world, int posX, int posY, int posZ, int metadata, EntityLiving userEntity)
{
return false;
}
If you return true, this will run some code if you break a block with your item.
public boolean shouldRotateAroundWhenRendering()
{
return false;
}
This will make your item rotate by 180 degrees when held by a player, but not in the inventory.
public boolean onDroppedByPlayer(ItemStack itemstack, EntityPlayer player)
{
return true;
}
If you return true, runs some code if the item is dropped from the hands of the player.
public boolean shouldPassSneakingClickToBlock(World world, int posX, int posY, int posZ)
{
return false;
}
If false, the item won't interact with a storage/activatable (<===== fake word) block when you are sneaking.
These are all the simple additions. More complicated ones will show up later. Let's check out sounds!
The following options go inside the constructor. Example of the super is below.
public MyFirstItem()
{
super();
setCreativeTab(Tutorial.myFirstTab);
setMaxStackSize(20); //default is 64, don't make it above that
setMaxDamage(420);
}
CreativeTab = the creative tab it will be in.
MaxStackSize is how many items can be in one stack.
MaxDamage is the amount of uses an item will have. Mainly used for tools.
@Override
@SideOnly(Side.CLIENT)
public EnumRarity getRarity(ItemStack itemstack)
{
return EnumRarity.rare;
}
EnumRarity gets the items name to change color. The types of rarities are common, uncommon, rare and epic. Common is just the default white lettering.
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool)
{
list.add(EnumChatFormatting.RED + "Oops, forgot a piece of redstone here...");
list.add("Never can have enough can you?");
}
addInformation will give your item a little box and description or message. You can also incorporate colors by using the EnumChatFormatting class. By adding multiple entries it will create multiple lines.
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
{
return itemstack;
}
This will run some code when the item is right clicked.
public boolean hitEntity(ItemStack itemstack, EntityLiving hitEntity, EntityLiving userEntity)
{
return false;
}
If you return true, this will run some code if you hit a mob with your item.
public boolean onBlockDestroyed(ItemStack itemstack, World world, int posX, int posY, int posZ, int metadata, EntityLiving userEntity)
{
return false;
}
If you return true, this will run some code if you break a block with your item.
public boolean shouldRotateAroundWhenRendering()
{
return false;
}
This will make your item rotate by 180 degrees when held by a player, but not in the inventory.
public boolean onDroppedByPlayer(ItemStack itemstack, EntityPlayer player)
{
return true;
}
If you return true, runs some code if the item is dropped from the hands of the player.
public boolean shouldPassSneakingClickToBlock(World world, int posX, int posY, int posZ)
{
return false;
}
If false, the item won't interact with a storage/activatable (<===== fake word) block when you are sneaking.
These are all the simple additions. More complicated ones will show up later. Let's check out sounds!