Skip to content

Commit

Permalink
Moa acceleration + stat changes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MrXBlade committed Nov 4, 2024
1 parent 6204a3a commit ae5c55d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
Expand All @@ -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
Expand Down

0 comments on commit ae5c55d

Please sign in to comment.