Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I am trying to make an entity that is basically a horse, and I want the riding player to be able to jump.

Currently I implemented IJumpingMount, and copied the Horse code (modified a bit).

Current travel method:

@Override
    public void travel(Vec3d movement) {
        if (this.isBeingRidden() && !isSitting()) {
            LivingEntity livingentity = (LivingEntity) this.getPassengers().get(0);
            this.rotationYaw = livingentity.rotationYaw;
            this.prevRotationYaw = this.rotationYaw;
            this.rotationPitch = livingentity.rotationPitch * 0.5F;
            this.setRotation(this.rotationYaw, this.rotationPitch);
            this.renderYawOffset = this.rotationYaw;
            this.rotationYawHead = this.renderYawOffset;
            float f = livingentity.moveStrafing * 0.5F;
            float f1 = livingentity.moveForward;
            if (f1 <= 0.0F) {
                f1 *= 0.25F;
            }

            if (this.jumpPower > 0 && !this.isJumping && onGround) {
                double d0 = 0.85f * (double) this.jumpPower;
                double d1;
                if (this.isPotionActive(Effects.JUMP_BOOST)) {
                    d1 = d0 + (double) ((float) (this.getActivePotionEffect(Effects.JUMP_BOOST).getAmplifier() + 1) * 0.1F);
                } else {
                    d1 = d0;
                }

                Vec3d vec3d = this.getMotion();
                this.setMotion(vec3d.x, d1, vec3d.z);
                this.setJumping(true);
                this.isAirBorne = true;
                if (f1 > 0.0F) {
                    float f2 = MathHelper.sin(this.rotationYaw * ((float) Math.PI / 180F));
                    float f3 = MathHelper.cos(this.rotationYaw * ((float) Math.PI / 180F));
                    this.setMotion(this.getMotion().add(-0.4F * f2 * this.jumpPower, 0.0D, (0.4F * f3 * this.jumpPower)));
                    this.playSound(SoundEvents.ENTITY_HORSE_JUMP, 0.4F, 1.0F);
                }

                this.jumpPower = 0.0F;
            }

            this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;
            if (this.canPassengerSteer()) {
                this.setAIMoveSpeed((float) this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getValue());
                super.travel(new Vec3d(f, movement.y, f1));
            } else if (livingentity instanceof PlayerEntity) {
                this.setMotion(Vec3d.ZERO);
            }

            if (this.onGround) {
                this.jumpPower = 0.0F;
                this.setJumping(false);
            }

            this.prevLimbSwingAmount = this.limbSwingAmount;
            double d2 = this.posX - this.prevPosX;
            double d3 = this.posZ - this.prevPosZ;
            float f4 = MathHelper.sqrt(d2 * d2 + d3 * d3) * 4.0F;
            if (f4 > 1.0F) {
                f4 = 1.0F;
            }

            this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
            this.limbSwing += this.limbSwingAmount;
        } else {
            this.jumpMovementFactor = 0.02F;
            super.travel(movement);
        }
    }

I know the y motion is set to .85, but the animal is not jumping. They can move around correctly when I press WSAD, but not jump.

  • Author

I tried setting d0 to 0 outside of the if, and using 

super.travel(new Vec3d(f, movement.y+d0, f1));

but still no y movement.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.