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.module.modules.movement
19+
20+ import com.lambda.event.events.TickEvent
21+ import com.lambda.event.listener.SafeListener.Companion.listen
22+ import com.lambda.module.Module
23+ import com.lambda.module.tag.ModuleTag
24+ import com.lambda.util.Communication.info
25+ import com.lambda.util.SpeedUnit
26+ import net.minecraft.client.network.ClientPlayerEntity
27+ import net.minecraft.text.Text.literal
28+ import net.minecraft.util.math.Vec3d
29+
30+
31+ /*
32+ * @author IceTank
33+ * @since 07.12.2025
34+ */
35+ object Pitch40 : Module(
36+ name = " Pitch40" ,
37+ description = " Allows you to fly forever" ,
38+ tag = ModuleTag .MOVEMENT
39+ ) {
40+ val logHeightGain by setting(" Log Height Gain" , true , " Logs the height gained each cycle to the chat" )
41+
42+ val PitchUpDefault = - 49f // Start angle when going back up. negative pitch = looking up
43+ val PitchDownDefault = 33f // Best angle for getting speed
44+ val PitchAngleChangeSpeed = 0.5f
45+ val PitchUpSpeedThreshold = 45f
46+
47+ var state = Pitch40State .GainSpeed
48+ var lastAngle = PitchUpDefault
49+
50+ var lastPos = Vec3d .ZERO
51+ var lastY = 0.0
52+
53+ init {
54+ listen<TickEvent .Pre > {
55+ when (state) {
56+ Pitch40State .GainSpeed -> {
57+ player.pitch = PitchDownDefault
58+ if (player.flySpeed() > PitchUpSpeedThreshold ) {
59+ state = Pitch40State .PitchUp
60+ }
61+ }
62+ Pitch40State .PitchUp -> {
63+ lastAngle - = 5f
64+ player.pitch = lastAngle
65+ if (lastAngle <= PitchUpDefault ) {
66+ state = Pitch40State .FlyUp
67+ }
68+ }
69+ Pitch40State .FlyUp -> {
70+ lastAngle + = PitchAngleChangeSpeed
71+ player.pitch = lastAngle
72+ if (lastAngle >= 0f ) {
73+ state = Pitch40State .GainSpeed
74+ if (logHeightGain)
75+ info(literal(" Height gained this cycle: %.2f meters" .format(player.pos.y - lastY)))
76+
77+ lastY = player.pos.y
78+ }
79+ }
80+ }
81+ lastPos = player.pos
82+ }
83+
84+ onEnable {
85+ state = Pitch40State .GainSpeed
86+ lastPos = player.pos
87+ lastAngle = PitchUpDefault
88+ }
89+ }
90+
91+ /* *
92+ * Get the player's current speed in meters per second.
93+ */
94+ fun ClientPlayerEntity.flySpeed (): Float {
95+ val delta = this .pos.subtract(lastPos)
96+ return SpeedUnit .MetersPerSecond .convertFromMinecraft(delta.length()).toFloat()
97+ }
98+
99+ enum class Pitch40State {
100+ GainSpeed ,
101+ PitchUp ,
102+ FlyUp ,
103+ }
104+ }
0 commit comments