Posted August 31, 20196 yr 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.
August 31, 20196 yr 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.