Skip to content

Commit f69781f

Browse files
committed
Fix previous commit (1b41242)
Previous "fix" was misinformed
1 parent 1b41242 commit f69781f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/me/nullicorn/hytale/stormserpent/npc/movement/BodyMotionSerpentBallistic.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.hypixel.hytale.component.ComponentAccessor;
44
import com.hypixel.hytale.component.Ref;
55
import com.hypixel.hytale.math.vector.Vector3dUtil;
6+
import com.hypixel.hytale.server.core.modules.debug.DebugUtils;
67
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
78
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
89
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
@@ -64,7 +65,7 @@ public void activate(
6465
this.startPosition = new Vector3d(selfTransform.getPosition());
6566
this.targetPosition = new Vector3d(targetTransform.getPosition());
6667
this.targetHorizontalDistance = Vector2d.distance(this.startPosition.x, this.startPosition.z, this.targetPosition.x, this.targetPosition.z);
67-
this.peakHorizontalDistance = this.targetHorizontalDistance * Math.sqrt(Math.abs(this.arcHeight)) / (Math.sqrt(Math.abs(this.arcHeight)) + Math.sqrt(Math.abs((this.targetPosition.y + this.arcHeight) - this.startPosition.y)));
68+
this.peakHorizontalDistance = this.targetHorizontalDistance * Math.sqrt(Math.abs(this.arcHeight)) / (Math.sqrt(Math.abs(this.arcHeight)) + Math.sqrt(Math.abs(this.startPosition.y + this.arcHeight - this.targetPosition.y)));
6869
this.horizontalDirection = new Vector3d(this.targetPosition.x, 0, this.targetPosition.z).sub(this.startPosition.x, 0, this.startPosition.z).normalize();
6970
this.t = 0;
7071

@@ -107,7 +108,7 @@ public boolean computeSteering(
107108
final double x1 = this.peakHorizontalDistance;
108109
final double x2 = this.targetHorizontalDistance;
109110
final double y0 = this.startPosition.y;
110-
final double y1 = y0 + this.arcHeight;
111+
final double y1 = this.targetPosition.y + this.arcHeight;
111112
final double y2 = this.targetPosition.y;
112113
final double l0 = ((x - x1) * (x - x2)) / ((x0 - x1) * (x0 - x2));
113114
final double l1 = ((x - x0) * (x - x2)) / ((x1 - x0) * (x1 - x2));
@@ -127,6 +128,7 @@ public boolean computeSteering(
127128
desiredSteering.setTranslation(new Vector3d(difference).normalize());
128129
desiredSteering.setTranslationRelativeSpeed(speed);
129130
desiredSteering.setRelativeTurnSpeed(this.relativeTurnSpeed);
131+
130132
return true;
131133
}
132134
}

0 commit comments

Comments
 (0)