Jump to content

[1.10.2] [SOLVED] Checking for the Jump Boost level?


Differentiation

Recommended Posts

Hey!

So for example, if I have to launch the player when they right click, I would launch them a certain amount, like so:

	@Override
    public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
    {
        //Just showing an example, I know this looks stupid...
        player.motionY = 0.5D;
        player.fallDistance = 0;
        
        return new ActionResult<>(EnumActionResult.SUCCESS, stack);
    }

But how do I edit the amount to satisfy all the levels of Jump Boost if the potion effect is active? (Level I, II, III, etc.)

Please help :/

Edited by Differentiation
Link to comment
Share on other sites

No. I am telling you to not call getActivePotionEffect twice. Simple as that.

PotionEffect effect = player.getActivePotionEffect(MobEffects.JUMP_BOOST);
                    
if (effect != null)
{
	double amplifier = effect.getAmplifier();
                    	
	player.motionY = ((amplifier + 0.45D) * 1.25D) - (amplifier * 1.15D);
}
else
{
	player.motionY = 0.45D;
}

 

Edited by Differentiation
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.