Posted February 5, 20178 yr 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; } }
February 5, 20178 yr Author Yes, thats the problem, this is how it works with onItemRightClick, im trying to get it to work with hitEntity, but i have no idea how.
February 5, 20178 yr Author this doesnt work either, and i have no idea why public ItemStack hitEntity(ItemStack itemStack, World world, EntityPlayer player) { world.playSoundAtEntity(player, "mod:lightsaberswing", 1.0F, 1.0F); return itemStack; }
February 5, 20178 yr Author Spoiler Like i said, im a complete beginner and only know the really basic stuff, im learning it as i go i suppose. Do you know a good source where i can learn the basic java needed for modding(or just writing java in general), so i dont have to bother anyone like this ?
February 5, 20178 yr http://lmgtfy.com/?q=basic+java+tutorial Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.