1+ /*
2+ * Copyright 2025 Lambda
3+ *
4+ * This program is free software: you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation, either version 3 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+ package com.lambda.command.commands
19+
20+ import com.lambda.Lambda.mc
21+ import com.lambda.brigadier.argument.double
22+ import com.lambda.brigadier.argument.value
23+ import com.lambda.brigadier.execute
24+ import com.lambda.brigadier.required
25+ import com.lambda.command.LambdaCommand
26+ import com.lambda.util.extension.CommandBuilder
27+ import net.minecraft.util.math.Vec2f
28+ import net.minecraft.util.math.Vec3d
29+
30+ object HClipCommand : LambdaCommand(
31+ name = " hclip" ,
32+ usage = " hclip <distance>" ,
33+ description = " Teleports the player forward a specified distance"
34+ ) {
35+ override fun CommandBuilder.create () {
36+ required(double(" distance" )) { distance ->
37+ execute {
38+ val player = mc.player ? : return @execute
39+ val dir = Vec3d .fromPolar(Vec2f (player.pitch, player.yaw)).normalize()
40+ val distance = distance().value()
41+ val xBlocks = dir.x * distance
42+ val zBlocks = dir.z * distance
43+ player.vehicle?.let { vehicle ->
44+ vehicle.setPos(vehicle.x + xBlocks, vehicle.y, vehicle.z + zBlocks)
45+ }
46+ player.setPos(player.x + xBlocks, player.y, player.z + zBlocks)
47+ }
48+ }
49+ }
50+ }
0 commit comments