Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mymod.items;
- import net.minecraft.client.renderer.texture.IIconRegister;
- import net.minecraft.entity.effect.EntityLightningBolt;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.MathHelper;
- import net.minecraft.util.MovingObjectPosition;
- import net.minecraft.util.Vec3;
- import net.minecraft.world.World;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- public class lightningStaff extends Item {
- private String texturePath = "mymod:";
- public lightningStaff(int ItemID, String textureName)
- {
- super();
- this.setUnlocalizedName(textureName);
- this.setCreativeTab(mymod.main.Main.infinicraftMagic);
- this.setMaxDamage(5000);
- texturePath += textureName;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(IIconRegister iconRegister)
- {
- this.itemIcon = iconRegister.registerIcon(texturePath);
- }
- /**
- * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
- * @return
- */
- //shoots fireball //
- public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
- {
- double maxDistance = 50D;
- itemstack.damageItem(1, entityplayer);
- {
- MovingObjectPosition movingobjectposition = entityplayer.rayTrace(75.0D, 0.0F);
- if(movingobjectposition == null)
- {
- return itemstack;
- }
- Vec3 vec3d = movingobjectposition.hitVec;
- double x = vec3d.xCoord;
- double y = vec3d.yCoord;
- double z = vec3d.zCoord;
- int i = MathHelper.floor_double(x);
- int j = MathHelper.floor_double(y);
- int k = MathHelper.floor_double(z);
- Vec3 look = entityplayer.getLookVec();
- EntityLightningBolt EntityLightningBolt = new EntityLightningBolt(world, 1, 1, 1);
- EntityLightningBolt.setLocationAndAngles(x, y, z, 0, 0.0F);
- world.spawnEntityInWorld(EntityLightningBolt);
- }
- return itemstack;
- }
- /**
- * Returns True is the item is renderer in full 3D when hold.
- */
- @SideOnly(Side.CLIENT)
- public boolean isFull3D()
- {
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement