Advertisement
Guest User

LightningStaff Class

a guest
Mar 1st, 2015
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. package mymod.items;
  2.  
  3. import net.minecraft.client.renderer.texture.IIconRegister;
  4. import net.minecraft.entity.effect.EntityLightningBolt;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.util.MathHelper;
  9. import net.minecraft.util.MovingObjectPosition;
  10. import net.minecraft.util.Vec3;
  11. import net.minecraft.world.World;
  12. import cpw.mods.fml.relauncher.Side;
  13. import cpw.mods.fml.relauncher.SideOnly;
  14.  
  15.  
  16. public class lightningStaff extends Item {
  17.  
  18. private String texturePath = "mymod:";
  19.  
  20. public lightningStaff(int ItemID, String textureName)
  21. {
  22. super();
  23. this.setUnlocalizedName(textureName);
  24. this.setCreativeTab(mymod.main.Main.infinicraftMagic);
  25. this.setMaxDamage(5000);
  26. texturePath += textureName;
  27. }
  28.  
  29. @Override
  30. @SideOnly(Side.CLIENT)
  31.  
  32. public void registerIcons(IIconRegister iconRegister)
  33. {
  34. this.itemIcon = iconRegister.registerIcon(texturePath);
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41. /**
  42.  
  43. * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
  44.  
  45. * @return
  46.  
  47. */
  48.  
  49. //shoots fireball //
  50. public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
  51. {
  52. double maxDistance = 50D;
  53. itemstack.damageItem(1, entityplayer);
  54.  
  55. {
  56. MovingObjectPosition movingobjectposition = entityplayer.rayTrace(75.0D, 0.0F);
  57. if(movingobjectposition == null)
  58. {
  59. return itemstack;
  60. }
  61. Vec3 vec3d = movingobjectposition.hitVec;
  62. double x = vec3d.xCoord;
  63. double y = vec3d.yCoord;
  64. double z = vec3d.zCoord;
  65. int i = MathHelper.floor_double(x);
  66. int j = MathHelper.floor_double(y);
  67. int k = MathHelper.floor_double(z);
  68. Vec3 look = entityplayer.getLookVec();
  69. EntityLightningBolt EntityLightningBolt = new EntityLightningBolt(world, 1, 1, 1);
  70. EntityLightningBolt.setLocationAndAngles(x, y, z, 0, 0.0F);
  71. world.spawnEntityInWorld(EntityLightningBolt);
  72.  
  73.  
  74. }
  75. return itemstack;
  76. }
  77.  
  78. /**
  79. * Returns True is the item is renderer in full 3D when hold.
  80. */
  81. @SideOnly(Side.CLIENT)
  82. public boolean isFull3D()
  83. {
  84. return true;
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement