Jump to content

[1.11.2] making a vary short range attack


Friend2Creepers

Recommended Posts

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));
      
    
    } 
}

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.