Skip to content

Commit cbd0a0a

Browse files
Teleport to block center instead of corner (#340)
1 parent ee55173 commit cbd0a0a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/TeleportCommand.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import net.minecraft.server.command.CommandManager
1212
import net.minecraft.server.world.ServerWorld
1313

1414
object TeleportCommand : BuildableCommand {
15+
private const val BLOCK_CENTER_OFFSET = 0.5
1516
override fun build(): LiteralNode =
1617
CommandManager.literal("tp")
1718
.requires(Permissions.require("ledger.commands.tp", CommandConsts.PERMISSION_LEVEL))
@@ -33,11 +34,15 @@ object TeleportCommand : BuildableCommand {
3334
private fun teleport(context: Context, world: ServerWorld, posArg: PosArgument): Int {
3435
val player = context.source.playerOrThrow
3536
val pos = posArg.toAbsoluteBlockPos(context.source)
37+
38+
val x = pos.x.toDouble() + BLOCK_CENTER_OFFSET
39+
val z = pos.z.toDouble() + BLOCK_CENTER_OFFSET
40+
3641
player.teleport(
3742
world,
38-
pos.x.toDouble(),
43+
x,
3944
pos.y.toDouble(),
40-
pos.z.toDouble(),
45+
z,
4146
emptySet(),
4247
player.yaw,
4348
player.pitch,

0 commit comments

Comments
 (0)