Hi im trying to make an item that when right clicked will make lightning strike where the player is pointing
Here is my current code the problem is that for some reason lightning also strikes the player
package net.minecraft.src;
public class ItemUraniumRod extends Item
{
public ItemUraniumRod(int var1)
{
super(var1);
this.maxStackSize = 1;
this.setTabToDisplayOn(CreativeTabs.tabMisc);
this.setMaxDamage(40);
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
MovingObjectPosition var4 = var3.rayTrace(250.0D, 1.0F);
if (var4 == null)
{
return var1;
}
else
{
Vec3 var5 = var4.hitVec;
double var6 = var5.xCoord;
double var8 = var5.yCoord;
double var10 = var5.zCoord;
int var12 = MathHelper.floor_double(var6);
int var13 = MathHelper.floor_double(var8);
int var14 = MathHelper.floor_double(var10);
var2.addWeatherEffect(new EntityLightningBolt(var2, var6, var8, var10));
if (!var3.capabilities.isCreativeMode)
{
var1.damageItem(2, var3);
}
return var1;
}
}
}
Here is my current code the problem is that for some reason lightning also strikes the player
yeah but it still shuldnt create two lightning bolts
should fix the problem. (I wasnt having it so i didnt think it was a problem)
so like this. (if this doesn't work its a glitch)