package net.minecraft.item;
import com.google.common.collect.Multimap;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
public class ItemSword extends Item
{
private float field_150934_a;
private final Item.ToolMaterial repairMaterial;
private static final String __OBFID = "CL_00000072";
public ItemSword(Item.ToolMaterial p_i45356_1_)
{
this.repairMaterial = p_i45356_1_;
this.maxStackSize = 1;
this.setMaxDurability(p_i45356_1_.getMaxUses());
this.setCreativeTab(CreativeTabs.tabCombat);
this.field_150934_a = 4.0F + p_i45356_1_.getDamageVsEntity();
}
public float func_150931_i()
{
return this.repairMaterial.getDamageVsEntity();
}
public float getStrVsBlock(ItemStack p_150893_1_, Block p_150893_2_)
{
if (p_150893_2_ == Blocks.web)
{
return 15.0F;
}
else
{
Material material = p_150893_2_.getMaterial();
return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F;
}
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack stack, EntityLivingBase p_77644_2_, EntityLivingBase p_77644_3_)
{
stack.damageItem(1, p_77644_3_);
return true;
}
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, int p_150894_4_, int p_150894_5_, int p_150894_6_, EntityLivingBase p_150894_7_)
{
if ((double)blockIn.getBlockHardness(worldIn, p_150894_4_, p_150894_5_, p_150894_6_) != 0.0D)
{
stack.damageItem(2, p_150894_7_);
}
return true;
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack stack)
{
return EnumAction.block;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack p_77626_1_)
{
return 72000;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer player)
{
player.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
return itemStackIn;
}
/**
* Can this Item harvest passed block
*/
public boolean canItemHarvestBlock(Block p_150897_1_)
{
return p_150897_1_ == Blocks.web;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return this.repairMaterial.getEnchantability();
}
/**
* Return the name for this tool's material.
*/
public String getToolMaterialName()
{
return this.repairMaterial.toString();
}
/**
* Return whether this item is repairable in an anvil.
*/
public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_)
{
ItemStack mat = this.repairMaterial.getRepairItemStack();
if (mat != null && net.minecraftforge.oredict.OreDictionary.itemMatches(mat, p_82789_2_, false)) return true;
return super.getIsRepairable(p_82789_1_, p_82789_2_);
}
/**
* Gets a map of item attribute modifiers, used by ItemSword to increase hit damage.
*/
public Multimap getItemAttributeModifiers()
{
Multimap multimap = super.getItemAttributeModifiers();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", (double)this.field_150934_a, 0));
return multimap;
}
}