Skip to content

Commit

Permalink
Merge pull request #5046 from SiverDX/fix/dragon_waking_speed
Browse files Browse the repository at this point in the history
Fix player controlled dragon walking speed
  • Loading branch information
TheBv authored Dec 25, 2023
2 parents efb2d40 + e5e427b commit 925c3d6
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ public void travel(@NotNull Vec3 pTravelVector) {
// Note: when motion is handled by the client no server side setDeltaMovement() should be called
// otherwise the movement will halt
// Todo: move wrongly fix
float flyingSpeed;

if (allowLocalMotionControl && this.getControllingPassenger() != null) {
LivingEntity rider = this.getControllingPassenger();
if (rider == null) {
Expand All @@ -2085,8 +2085,7 @@ public void travel(@NotNull Vec3 pTravelVector) {
double strafing = rider.xxa;
double vertical = 0;
float speed = (float) this.getAttributeValue(Attributes.MOVEMENT_SPEED);
// Bigger difference in speed for young and elder dragons
// float airSpeedModifier = (float) (5.2f + 1.0f * Mth.map(Math.min(this.getAgeInDays(), 125), 0, 125, 0f, 1.5f));

float airSpeedModifier = (float) (5.2f + 1.0f * Mth.map(speed, this.minimumSpeed, this.maximumSpeed, 0f, 1.5f));
// Apply speed mod
speed *= airSpeedModifier;
Expand Down Expand Up @@ -2205,7 +2204,7 @@ else if (isInWater() || isInLava()) {
// Walking control
else {
double forward = rider.zza;
double strafing = rider.xxa;
double strafing = rider.xxa * 0.5f;
// Inherit y motion for dropping
double vertical = pTravelVector.y;
float speed = (float) this.getAttributeValue(Attributes.MOVEMENT_SPEED);
Expand All @@ -2218,21 +2217,16 @@ else if (isInWater() || isInLava()) {
forward *= rider.isSprinting() ? 1.2f : 1.0f;
// Slower going back
forward *= rider.zza > 0 ? 1.0f : 0.2f;
// Slower going sideway
strafing *= 0.05f;

if (this.isControlledByLocalInstance()) {
flyingSpeed = speed * 0.1F;
this.setSpeed(flyingSpeed);

this.setSpeed(speed);
// Vanilla walking behavior includes going up steps
super.travel(new Vec3(strafing, vertical, forward));
} else {
this.setDeltaMovement(Vec3.ZERO);
}
this.tryCheckInsideBlocks();
this.updatePitch(this.yOld - this.getY());
return;
}
}
// No rider move control
Expand Down

0 comments on commit 925c3d6

Please sign in to comment.