So im trying to make my custom lightsaber item play a sound when hitting an entity. I got it to work with the method onItemRightClick, but i cant get it to work with hitEntity. Im rather new to modding and id like to get help.
Here is the working code
public class ItemModLightsaber extends ItemSword {
public ItemModLightsaber(ToolMaterial Kyber, String unlocalizedName) {
super(Kyber);
this.setUnlocalizedName(unlocalizedName);
this.setCreativeTab(IRCrTab.tabIRItems);
this.setTextureName("mod:" + unlocalizedName);
}
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase hitEntity, EntityLivingBase attackingEntity) {
hitEntity.setFire(4);
return true;
}
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
world.playSoundAtEntity(player, "mod:lightsaberswing", 1.0F, 1.0F);
return itemStack;
}
}