Hello All :), I am relatively new to minecraft modding so I might be a bit unsure about certain things. I have a basic grasp on Java programming so I would say I somewhat understand how the code works and I'm constantly trying to learn but I've hit a snag. Basically I'm trying to make a basic sword that fires lightning bolts on right click however I can't seem to get the code to work. This is currently what I'm using:
public BoltSword(String unlocalizedName, ToolMaterial material) {
super(unlocalizedName, material);
}
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
if (worldIn.isRemote) {
RayTraceResult result = playerIn.rayTrace(100, 1F);
int x = result.getBlockPos().getX();
int y = result.getBlockPos().getY();
int z = result.getBlockPos().getZ();
EntityLightningBolt lightning = new EntityLightningBolt(worldIn, x, y, z, false);
worldIn.addWeatherEffect(lightning);
}
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
I've tried searching endless posts and this was the furthest I've gotten however it still won't work. I will appreciate any help given and I'm open to any suggestions you guys may recommend me. Thanks!