From ae5c55d4047b6a2a7fe969123d43cb0c4f83968e Mon Sep 17 00:00:00 2001 From: Blade <28675825+MrXBlade@users.noreply.github.com> Date: Mon, 4 Nov 2024 01:50:37 +0100 Subject: [PATCH] Moa acceleration + stat changes Made the values a bit less extreme, and also re-did the movement, from my testing it seems to do be more stable than before and feels a bit better too --- .../entities/passive/moa/MoaAttributes.java | 6 +-- .../entities/passive/moa/MoaEntity.java | 43 ++++++++++++------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/id/paradiselost/entities/passive/moa/MoaAttributes.java b/src/main/java/net/id/paradiselost/entities/passive/moa/MoaAttributes.java index ed26f8cc4..0734ad776 100644 --- a/src/main/java/net/id/paradiselost/entities/passive/moa/MoaAttributes.java +++ b/src/main/java/net/id/paradiselost/entities/passive/moa/MoaAttributes.java @@ -3,12 +3,12 @@ import net.id.paradiselost.component.MoaGenes; public enum MoaAttributes { - GROUND_SPEED(0.24F, 0.8F, 0.1F), - GLIDING_SPEED(0.07F, 0.25F, 0.03F), + GROUND_SPEED(0.3F, 0.5F, 0.1F), + GLIDING_SPEED(0.15F, 0.25F, 0.03F), GLIDING_DECAY(0.5F, 0.8F, 0.06F), JUMPING_STRENGTH(0.18F, 0.28F, 0.02F), DROP_MULTIPLIER(1, 6, 1), - MAX_HEALTH(10, 40, 5); + MAX_HEALTH(15, 40, 5); public final float min, max, gradeInterval; diff --git a/src/main/java/net/id/paradiselost/entities/passive/moa/MoaEntity.java b/src/main/java/net/id/paradiselost/entities/passive/moa/MoaEntity.java index c9088fa0c..297f7adc8 100644 --- a/src/main/java/net/id/paradiselost/entities/passive/moa/MoaEntity.java +++ b/src/main/java/net/id/paradiselost/entities/passive/moa/MoaEntity.java @@ -448,16 +448,32 @@ public LivingEntity getControllingPassenger() { } } + float curGroundSpeed = 0F; + float curFlyingSpeed = 0; + final float groundAcceleration = 0.004F; + final float flyingAcceleration = 0.04F; + protected Vec3d getControlledMovementInput(PlayerEntity controllingPlayer, Vec3d movementInput) { float f = controllingPlayer.sidewaysSpeed * 0.5F; float g = controllingPlayer.forwardSpeed; if (g <= 0.0F) { g *= 0.25F; } - return new Vec3d(f, 0.0, g); } + private void calcAcceleration(PlayerEntity controllingPlayer) { + float f = controllingPlayer.sidewaysSpeed * 0.5F; + float g = controllingPlayer.forwardSpeed; + if (g == 0 && f == 0) { + curGroundSpeed = Math.clamp(curGroundSpeed - 0.1f, (getGenes().getAttribute(MoaAttributes.GROUND_SPEED) - 0.2f) * 0.4f, getGenes().getAttribute(MoaAttributes.GROUND_SPEED) * 0.4f); + curFlyingSpeed = Math.clamp(curFlyingSpeed - 0.01f, 0.4f, getGenes().getAttribute(MoaAttributes.GLIDING_SPEED) * 5.0F); + } else { + curGroundSpeed = Math.clamp(curGroundSpeed + groundAcceleration, (getGenes().getAttribute(MoaAttributes.GROUND_SPEED) - 0.2f) * 0.4f, getGenes().getAttribute(MoaAttributes.GROUND_SPEED) * 0.4f); + curFlyingSpeed = Math.clamp(curFlyingSpeed + flyingAcceleration, 0.4f, getGenes().getAttribute(MoaAttributes.GLIDING_SPEED) * 5.0F); + } + } + @Override protected void tickControlled(PlayerEntity controllingPlayer, Vec3d movementInput) { if (this.isAlive()) { @@ -469,11 +485,7 @@ protected void tickControlled(PlayerEntity controllingPlayer, Vec3d movementInpu this.bodyYaw = this.getYaw(); this.headYaw = this.bodyYaw; var movement = getControlledMovementInput(controllingPlayer, movementInput); - - final float groundAcceleration = 0.006F; - final float flyingAcceleration = 0.001F; - final float maxGroundSpeed = 0.5F; - final float maxFlyingSpeed = 0.7F; + calcAcceleration(controllingPlayer); if (this.jumpStrength > 0.0F && !this.isInAir && this.isOnGround()) { double d = 0.1F * (double) this.jumpStrength * (double) this.getJumpVelocityMultiplier(); @@ -505,19 +517,18 @@ protected void tickControlled(PlayerEntity controllingPlayer, Vec3d movementInpu isInAir = false; } // acceleration + if (this.isLogicalSideForUpdatingMovement()) { //this.rise(); - float currentSpeed = 0; - if (!this.isGliding()) { - currentSpeed = getMovementSpeed(); - currentSpeed = Math.min(currentSpeed + groundAcceleration, maxGroundSpeed); +/* if (!this.isGliding()) { + this.setMovementSpeed(curGroundSpeed); + System.out.println(curGroundSpeed); } else { - currentSpeed = getMovementSpeed(); - currentSpeed = Math.min(currentSpeed + flyingAcceleration, maxFlyingSpeed); - } + this.setMovementSpeed(curFlyingSpeed); + System.out.println(curFlyingSpeed); + }*/ //System.out.println(currentSpeed); - this.setMovementSpeed(currentSpeed); - super.travel(new Vec3d(movement.x * currentSpeed, movementInput.y, movement.z * currentSpeed)); + super.travel(new Vec3d(movement.x, movementInput.y, movement.z)); } else { this.setVelocity(Vec3d.ZERO); } @@ -539,7 +550,7 @@ public float getMountedMoveSpeed() { @Override public float getMovementSpeed() { - return isGliding() ? getGenes().getAttribute(MoaAttributes.GLIDING_SPEED) * 10.0F : getGenes().getAttribute(MoaAttributes.GROUND_SPEED) * 0.60F; + return isGliding() ? curFlyingSpeed : curGroundSpeed; } @Override