default jump y velocity

Discussion in 'Spigot Plugin Development' started by NoobDoesMC, May 18, 2018 at 12:01 AM.

  1. when a player presses the space bar what's the vanilla y-velocity?

    I want to mimic the vanilla jump by using spigot's `setVelocity`, I need to know what y velocity I need to set to replicate the vanilla jump
     
  2. Try using the PlayerVelocityEvent and printing out the velocity when you jump, also check if the velocity has a positive y-value before printing it so you don't get spammed when walking. Profit?

    Unless that event doesn't do what I think it does.
     
  3. @OkDexter12 the PlayerVelocity event only gets triggered when you get pushed away by an explosion or so.
    @NoobDoesMC Sadly nothing seems to tell you what the default jump velocity is.
    But you can play around a bit and test different values until you get tve same result. Maybe you will end up with anything like y = 0.265 or so.
     
  4. Player walking/sprinting/jumping doesn't actually count as velocity to spigot.
     
  5. server related velocity altering is unwise. It will always look weird and jittery
     
    • Funny Funny x 1
  6. Try 0.42

    Edit: From MCP, the Jump code is:
    Code (Text):

        protected float getJumpUpwardsMotion()
        {
            return 0.42F;
        }

        /**
         * Causes this entity to do an upwards motion (jumping).
         */
        protected void jump()
        {
            this.motionY = (double)this.getJumpUpwardsMotion();

            if (this.isPotionActive(MobEffects.JUMP_BOOST))
            {
                this.motionY += (double)((float)(this.getActivePotionEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1) * 0.1F);
            }

            if (this.isSprinting())
            {
                float f = this.rotationYaw * 0.017453292F;
                this.motionX -= (double)(MathHelper.sin(f) * 0.2F);
                this.motionZ += (double)(MathHelper.cos(f) * 0.2F);
            }

            this.isAirBorne = true;
        }
     
    #6 Leemonade, May 18, 2018 at 3:13 PM
    Last edited: May 19, 2018 at 10:22 AM
    • Like Like x 2

Share This Page