Skip to content

Commit

Permalink
Fixed jumpto command
Browse files Browse the repository at this point in the history
  • Loading branch information
SIsilicon committed Dec 2, 2024
1 parent cb47b50 commit 36c3b56
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/server/commands/navigation/jumpto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlayerUtil } from "@modules/player_util.js";
import { RawText } from "@notbeer-api";
import { RawText, Vector } from "@notbeer-api";
import { getCommandFunc, registerCommand } from "../register_commands.js";
import config from "config.js";

Expand All @@ -11,8 +11,13 @@ const registerInformation = {
};

registerCommand(registerInformation, function (session, builder) {
const hit = PlayerUtil.traceForBlock(builder, config.traceDistance - 1);
builder.teleport(hit.offset(0.5, 0, 0.5), { dimension: builder.dimension });
getCommandFunc("unstuck")(session, builder, new Map());
const hit = PlayerUtil.traceForBlock(builder);
if (hit) {
builder.teleport(hit.offset(0.5, 0, 0.5), { dimension: builder.dimension });
getCommandFunc("unstuck")(session, builder, new Map());
} else {
const teleportTo = Vector.add(builder.location, Vector.mul(builder.getViewDirection(), config.traceDistance));
builder.runCommand(`tp ${teleportTo.x.toFixed(3)} ${teleportTo.y.toFixed(3)} ${teleportTo.z.toFixed(3)}`);
}
return RawText.translate("commands.wedit:jumpto.explain");
});

0 comments on commit 36c3b56

Please sign in to comment.