Jump to content

Trying to apply motion to Player 1.12


Blaez

Recommended Posts

I'm Trying to apply a Similar Effect to the Code below Where by on hit of an entity the player is bounced backwards in the opposite direction the player is facing.

Although the below code is for 1.7.2 so its not of much use as reference I figured it would help convey the point. 

public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
    {
        Entity entity =  par3EntityLivingBase;

        Vec3 look = par3EntityLivingBase.getLookVec();


        par3EntityLivingBase.motionX = look.xCoord ;
        par3EntityLivingBase.motionZ = look.zCoord ;
        par3EntityLivingBase.motionY = look.yCoord ;
        par3EntityLivingBase.lastTickPosZ = look.xCoord;
        par3EntityLivingBase.lastTickPosX = look.zCoord;


        set_Item_State(par1ItemStack, false);
        par1ItemStack.damageItem(1, par3EntityLivingBase);
        return true;
    }
Link to comment
Share on other sites

4 hours ago, Blaez said:

I'm more so asking how to go about do it as you can no longer use getlookvec with Entityliving or Player Classes

 

You can still get a look vector. They just renamed the method to getLook(). You can figure this out yourself (i.e. when something changes between versions) but looking at the type hierarchy for the class and seeing of any of the methods have a name that suggest it is equivalent behavior.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.