Guest User

BlueLightsaber

a guest
Oct 20th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. package Seroemod.Lightsabers;
  2.  
  3.  
  4. import Seroemod.SeroeMod;
  5. import cpw.mods.fml.relauncher.Side;
  6. import cpw.mods.fml.relauncher.SideOnly;
  7. import net.minecraft.client.renderer.texture.IconRegister;
  8. import net.minecraft.creativetab.CreativeTabs;
  9. import net.minecraft.entity.Entity;
  10. import net.minecraft.entity.EntityLivingBase;
  11. import net.minecraft.entity.player.EntityPlayer;
  12. import net.minecraft.item.EnumAction;
  13. import net.minecraft.item.EnumToolMaterial;
  14. import net.minecraft.item.Item;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.item.ItemSword;
  17. import net.minecraft.item.ItemTool;
  18. import net.minecraft.potion.Potion;
  19. import net.minecraft.potion.PotionEffect;
  20. import net.minecraft.world.World;
  21.  
  22. public class BlueLightsaber extends ItemSword
  23. {
  24.  
  25.  
  26. public BlueLightsaber(int par1, EnumToolMaterial par2EnumToolMaterial) {
  27. super(par1, par2EnumToolMaterial);
  28. this.setUnlocalizedName("blue_lightsaber");
  29. this.setCreativeTab(CreativeTabs.tabCombat);
  30. this.canRepair = true;
  31. }
  32.  
  33. /**
  34. * Adds the shiny effect
  35. */
  36. public boolean hasEffect(ItemStack par1ItemStack)
  37. {
  38. return true;
  39. }
  40.  
  41. // Adds a potion effect when the item is held
  42. public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5, EntityPlayer par6)
  43. {
  44. if(par6.getCurrentEquippedItem().equals(getUnlocalizedName()))
  45. {
  46. par6.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 100, 3, true));
  47. }
  48. else
  49. {
  50. par6.curePotionEffects(par1ItemStack);
  51. }
  52. }
  53.  
  54.  
  55. @Override
  56. public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
  57. {
  58. par2World.playSoundAtEntity(par3EntityPlayer, "seroemod:return", 500.0F, 1.0F);
  59. return new ItemStack(SeroeMod.hiltBlueLightsaber, 1 , par1ItemStack.getItemDamage());
  60. }
  61.  
  62.  
  63. @Override
  64. public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
  65. {
  66. par1ItemStack.damageItem(1, par3EntityLivingBase);
  67. par2EntityLivingBase.worldObj.playSoundAtEntity(par2EntityLivingBase, "seroemod:swing", 500.0F, 1.0F);
  68.  
  69.  
  70. return true;
  71. }
  72.  
  73. @SideOnly(Side.CLIENT)
  74. public void registerIcons(IconRegister reg)
  75. {
  76. this.itemIcon = reg.registerIcon("seroemod:blue_lightsaber");
  77. }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment