Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected final void launch(Point from, Point to, double power, double uncertain
}

Vec velocity = movement.mul(ServerFlag.SERVER_TICKS_PER_SECOND);
Pos spawnPosition = new Pos(from.x(), from.y(), from.z()).withDirection(movement);
Pos spawnPosition = withProjectileView(movement, from);
setInstance(instance, spawnPosition).whenComplete((ignored, throwable) -> {
if (throwable != null) {
remove();
Expand Down Expand Up @@ -232,9 +232,13 @@ public final boolean isInBlock() {

private void updateProjectileRotation(Vec movement) {
if (movement.isZero()) return;
position = withProjectileView(movement, position);
}

private static Pos withProjectileView(Vec movement, Point position) {
float yaw = (float) Math.toDegrees(Math.atan2(movement.x(), movement.z()));
float pitch = (float) Math.toDegrees(Math.atan2(movement.y(), Math.hypot(movement.x(), movement.z())));
position = position.withView(yaw, pitch);
return new Pos(position.x(), position.y(), position.z(), yaw, pitch);
}

private void callBlockCollision() {
Expand Down