Posted August 31, 20178 yr I've been working on a "assassin's knife" for a while, the main idea being if you get very close to a mob you can do around ~50 damage. Unfortuanatley I don't exactly know how to do this. I would love some help with finding a way to make this close range attack work. here is my code: package com.idtech.item; import com.idtech.BaseMod; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntitySnowball; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.SoundCategory; import net.minecraft.world.World; //advmod public class ItemAssassinsKnife extends ItemSword { public final static String name="knife"; public ItemAssassinsKnife() { super(ItemMod.PhaKni); this.setUnlocalizedName(BaseMod.MODID+"_"+name); this.setCreativeTab(CreativeTabs.COMBAT); // TODO Auto-generated constructor stub } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (!worldIn.isRemote){ EntitySnowball entitySwipe=new EntitySnowball(worldIn,playerIn); entitySwipe.setHeadingFromThrower( playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); worldIn.spawnEntity(entitySwipe); // TODO placeholder } return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } }
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.