Skip to content

Commit 87d13ab

Browse files
committed
hclip and vclip commands
1 parent 20c94bf commit 87d13ab

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
28+
object VClipCommand : LambdaCommand(
29+
name = "vclip",
30+
usage = "vclip <distance>",
31+
description = "Teleports the player up a specified distance"
32+
) {
33+
override fun CommandBuilder.create() {
34+
required(double("distance")) { distance ->
35+
execute {
36+
val player = mc.player ?: return@execute
37+
val distance = distance().value()
38+
player.vehicle?.let { vehicle ->
39+
vehicle.setPos(vehicle.x, vehicle.y + distance, vehicle.z)
40+
}
41+
player.setPos(player.x, player.y + distance, player.z)
42+
}
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)