Advertisement
Guest User

ItemRandomSword.java

a guest
Nov 25th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.02 KB | None | 0 0
  1. package com.boxtop.epicloot;
  2.  
  3. import cpw.mods.fml.common.Side;
  4. import cpw.mods.fml.common.asm.SideOnly;
  5. import net.minecraft.src.Block;
  6. import net.minecraft.src.CreativeTabs;
  7. import net.minecraft.src.Entity;
  8. import net.minecraft.src.EntityLiving;
  9. import net.minecraft.src.EntityPlayer;
  10. import net.minecraft.src.EnumAction;
  11. import net.minecraft.src.Item;
  12. import net.minecraft.src.ItemStack;
  13. import net.minecraft.src.EnumToolMaterial;
  14. import net.minecraft.src.Material;
  15. import net.minecraft.src.NBTTagCompound;
  16. import net.minecraft.src.NBTTagList;
  17. import net.minecraft.src.NBTTagString;
  18. import net.minecraft.src.World;
  19. import net.minecraftforge.client.MinecraftForgeClient;
  20. import net.minecraftforge.common.MinecraftForge;
  21.  
  22. public class ItemRandomSword extends Item {
  23.  
  24.     private int weaponDamage;
  25.     private EnumToolMaterial toolMaterial;
  26.  
  27.     public ItemRandomSword(int itemID, EnumToolMaterial par2EnumToolMaterial)
  28.     {
  29.          super(itemID);
  30.          this.toolMaterial = par2EnumToolMaterial;
  31.          this.maxStackSize = 1;
  32.          this.setMaxDamage(par2EnumToolMaterial.getMaxUses());
  33.          this.weaponDamage = 4 + par2EnumToolMaterial.getDamageVsEntity();
  34.          this.setTextureFile("/epicloot/gfx/items/swords.png");
  35.     }
  36.  
  37.      @SideOnly(Side.CLIENT)
  38.     public String getTextureFile()
  39.     {
  40.         return "/epicloot/gfx/items/swords.png";
  41.     }
  42.  
  43.     public void setEnumToolMaterial(EnumToolMaterial par2EnumToolMaterial)
  44.     {
  45.         this.toolMaterial = par2EnumToolMaterial;
  46.             this.maxStackSize = 1;
  47.         this.setMaxDamage(par2EnumToolMaterial.getMaxUses());
  48.             this.weaponDamage = 4 + par2EnumToolMaterial.getDamageVsEntity();
  49.     }
  50.  
  51.     public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
  52.     {
  53.                  return false;
  54.     }
  55.  
  56.     public int getItemEnchantability()
  57.         {
  58.         return 0;
  59.     }
  60.  
  61.     public int func_82803_g()
  62.     {
  63.         return this.toolMaterial.getDamageVsEntity();
  64.     }
  65.  
  66.          /**
  67.          * Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
  68.          * sword
  69.          */
  70.     public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
  71.         {
  72.                  if (par2Block.blockID == Block.web.blockID)
  73.                  {
  74.                          return 15.0F;
  75.                  }
  76.                  else
  77.                  {
  78.                          Material var3 = par2Block.blockMaterial;
  79.                          return var3 != Material.plants && var3 != Material.vine && var3 != Material.field_76261_t && var3 != Material.leaves && var3 != Material.pumpkin ? 1.0F : 1.5F;
  80.                  }
  81.          }
  82.  
  83.          /**
  84.          * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
  85.          * the damage on the stack.
  86.          */
  87.     public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
  88.     {
  89.                  par1ItemStack.damageItem(1, par3EntityLiving);
  90.                  return true;
  91.     }
  92.  
  93.          public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
  94.     {
  95.                  if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
  96.                  {
  97.                          par1ItemStack.damageItem(2, par7EntityLiving);
  98.                  }
  99.  
  100.                  return true;
  101.     }
  102.  
  103.          /**
  104.          * Returns the damage against a given entity.
  105.          */
  106.     public int getDamageVsEntity(Entity par1Entity)
  107.     {
  108.                  return this.weaponDamage;
  109.          }
  110.  
  111.     @SideOnly(Side.CLIENT)
  112.  
  113.          /**
  114.          * Returns True is the item is renderer in full 3D when hold.
  115.          */
  116.     public boolean isFull3D()
  117.          {
  118.                  return true;
  119.          }
  120.  
  121.          /**
  122.          * returns the action that specifies what animation to play when the items is being used
  123.          */
  124.     public EnumAction getItemUseAction(ItemStack par1ItemStack)
  125.          {
  126.                  return EnumAction.block;
  127.          }
  128.  
  129.          /**
  130.          * How long it takes to use or consume an item
  131.          */
  132.     public int getMaxItemUseDuration(ItemStack par1ItemStack)
  133.          {
  134.                  return 72000;
  135.          }
  136.  
  137.          /**
  138.          * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
  139.          */
  140.     public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
  141.          {
  142.         par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
  143.                  return par1ItemStack;
  144.          }
  145.  
  146.          /**
  147.          * Returns if the item (tool) can harvest results from the block type.
  148.          */
  149.     public boolean canHarvestBlock(Block par1Block)
  150.          {
  151.                  return par1Block.blockID == Block.web.blockID;
  152.          }
  153.  
  154.     public String func_77825_f()
  155.          {
  156.                  return this.toolMaterial.toString();
  157.          }
  158.  
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement