-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathPitch40.kt
More file actions
104 lines (92 loc) · 2.8 KB
/
Pitch40.kt
File metadata and controls
104 lines (92 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright 2025 Lambda
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lambda.module.modules.movement
import com.lambda.event.events.TickEvent
import com.lambda.event.listener.SafeListener.Companion.listen
import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.util.Communication.info
import com.lambda.util.SpeedUnit
import net.minecraft.client.network.ClientPlayerEntity
import net.minecraft.text.Text.literal
import net.minecraft.util.math.Vec3d
/*
* @author IceTank
* @since 07.12.2025
*/
object Pitch40 : Module(
name = "Pitch40",
description = "Allows you to fly forever",
tag = ModuleTag.MOVEMENT
) {
val logHeightGain by setting("Log Height Gain", true, "Logs the height gained each cycle to the chat")
val PitchUpDefault = -49f // Start angle when going back up. negative pitch = looking up
val PitchDownDefault = 33f // Best angle for getting speed
val PitchAngleChangeSpeed = 0.5f
val PitchUpSpeedThreshold = 45f
var state = Pitch40State.GainSpeed
var lastAngle = PitchUpDefault
var lastPos = Vec3d.ZERO
var lastY = 0.0
init {
listen<TickEvent.Pre> {
when (state) {
Pitch40State.GainSpeed -> {
player.pitch = PitchDownDefault
if (player.flySpeed() > PitchUpSpeedThreshold) {
state = Pitch40State.PitchUp
}
}
Pitch40State.PitchUp -> {
lastAngle -= 5f
player.pitch = lastAngle
if (lastAngle <= PitchUpDefault) {
state = Pitch40State.FlyUp
}
}
Pitch40State.FlyUp -> {
lastAngle += PitchAngleChangeSpeed
player.pitch = lastAngle
if (lastAngle >= 0f) {
state = Pitch40State.GainSpeed
if (logHeightGain)
info(literal("Height gained this cycle: %.2f meters".format(player.pos.y - lastY)))
lastY = player.pos.y
}
}
}
lastPos = player.pos
}
onEnable {
state = Pitch40State.GainSpeed
lastPos = player.pos
lastAngle = PitchUpDefault
}
}
/**
* Get the player's current speed in meters per second.
*/
fun ClientPlayerEntity.flySpeed(): Float {
val delta = this.pos.subtract(lastPos)
return SpeedUnit.MetersPerSecond.convertFromMinecraft(delta.length()).toFloat()
}
enum class Pitch40State {
GainSpeed,
PitchUp,
FlyUp,
}
}