1
1
package com.lambda.client.module.modules.movement
2
2
3
- import com.lambda.client.event.SafeClientEvent
4
- import com.lambda.client.event.events.PacketEvent
5
- import com.lambda.client.event.listener.listener
6
- import com.lambda.client.manager.managers.PlayerPacketManager
7
- import com.lambda.client.mixin.extension.playerY
3
+ import com.lambda.client.manager.managers.TimerManager.modifyTimer
4
+ import com.lambda.client.manager.managers.TimerManager.resetTimer
8
5
import com.lambda.client.module.Category
9
6
import com.lambda.client.module.Module
10
- import com.lambda.client.module.modules.combat.Surround.inHoleCheck
11
- import com.lambda.client.setting.settings.impl.primitive.BooleanSetting
12
7
import com.lambda.client.util.BaritoneUtils
13
- import com.lambda.client.util.Bind
14
- import com.lambda.client.util.EntityUtils.isInOrAboveLiquid
15
- import com.lambda.client.util.text.MessageSendHelper
16
8
import com.lambda.client.util.threads.runSafe
17
9
import com.lambda.client.util.threads.safeListener
10
+ import net.minecraft.client.Minecraft
11
+ import net.minecraft.client.entity.EntityPlayerSP
18
12
import net.minecraft.network.play.client.CPacketPlayer
19
- import net.minecraftforge.fml.common.gameevent.InputEvent
20
- import net.minecraftforge.fml.common.gameevent.TickEvent
21
- import org.lwjgl.input.Keyboard
13
+ import net.minecraft.util.math.AxisAlignedBB
14
+ import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
15
+
22
16
23
17
/* *
24
- * The packet mode code is licensed under MIT and can be found here:
25
- * https://github.com/fr1kin/ForgeHax/blob/2011740/src/main/java/com/matt/forgehax/mods/StepMod.java
18
+ * @author Doogie13
19
+ * @since 20/09/2022
26
20
*/
27
21
object Step : Module(
28
22
name = " Step" ,
29
- description = " Changes the vanilla behavior for stepping up blocks" ,
30
23
category = Category .MOVEMENT ,
31
- modulePriority = 200
24
+ description = " Allows you to step up blocks" ,
25
+ modulePriority = 201
32
26
) {
33
- private val mode by setting(" Mode" , Mode .PACKET )
34
- private val upStep = setting(" Up Step" , true )
35
- private val downStep = setting(" Down Step" , false )
36
- private val entityStep by setting(" Entities" , true )
37
- private val checkHole by setting(" Check Hole" , false )
38
- private val height by setting(" Height" , 1.0f , 0.25f .. 2.0f , 0.25f )
39
- private val downSpeed by setting(" Down Speed" , 0.2f , 0.0f .. 1.0f , 0.05f )
40
- private val bindUpStep by setting(" Bind Up Step" , Bind ())
41
- private val bindDownStep by setting(" Bind Down Step" , Bind ())
42
-
43
- private const val defaultHeight = 0.6f
44
-
45
- private val ignoredPackets = HashSet <CPacketPlayer >()
46
- private var lastCollidedTick = 0
47
- private var onGroundTick = 0
48
-
49
- @Suppress(" UNUSED" )
27
+
28
+ private val mode by setting(" Mode" , Mode .NCP , description = " Anticheat step bypass" )
29
+ val strict by setting(" Strict" , false , description = " Bypass the new UpdatedNCP step checks" )
30
+ val upStep = setting(" Step Height" , 2.5f , 1f .. 2.5f , .5f , { ! strict }, description = " How high to step" )
31
+
50
32
private enum class Mode {
51
- VANILLA , PACKET
33
+ NCP , VANILLA
52
34
}
53
35
36
+ private var playerY = 0.0
37
+ private var timing = false
38
+
54
39
init {
40
+ upStep.valueListeners.add { _, _ ->
41
+ BaritoneUtils .settings?.assumeStep?.value = isEnabled
42
+ }
43
+
55
44
onDisable {
45
+ resetTimer()
56
46
runSafe {
57
- player.apply {
58
- stepHeight = defaultHeight
59
- ridingEntity?.stepHeight = 1.0f
60
- }
47
+ player.stepHeight = .6f
61
48
}
62
- ignoredPackets.clear()
63
49
}
64
50
65
- onToggle {
66
- BaritoneUtils .settings?.assumeStep?.value = it && upStep.value
51
+ safeListener<ClientTickEvent > {
52
+ if (! timing) resetTimer()
53
+
54
+ timing = false
67
55
}
56
+ }
68
57
69
- listener<InputEvent .KeyInputEvent > {
70
- val key = Keyboard .getEventKey()
58
+ fun pre (bb : AxisAlignedBB , player : EntityPlayerSP ): Boolean {
59
+ player.ridingEntity?.let {
60
+ it.stepHeight = if (strict) 1f else upStep.value
61
+ }
71
62
72
- if (bindUpStep.isDown(key)) {
73
- upStep.value = ! upStep.value
74
- MessageSendHelper .sendChatMessage(upStep.toggleMsg())
75
- }
63
+ playerY = bb.minY
76
64
77
- if (bindDownStep.isDown(key)) {
78
- downStep.value = ! downStep.value
79
- MessageSendHelper .sendChatMessage(downStep.toggleMsg())
80
- }
81
- }
65
+ return player.isInWater
66
+ || player.isInLava
67
+ || ! player.onGround
68
+ || player.isOnLadder
69
+ || player.movementInput.jump
70
+ || player.fallDistance >= 0.1
82
71
}
83
72
84
- private fun BooleanSetting.toggleMsg () = " $chatName Turned ${this .name} ${if (this .value) " &aon" else " &coff" } &f!"
73
+ fun post (bb : AxisAlignedBB , mc : Minecraft ) {
74
+ if (mode == Mode .VANILLA ) return
85
75
86
- init {
87
- safeListener<TickEvent .ClientTickEvent > {
88
- if (it.phase != TickEvent .Phase .START || ! shouldRunStep) return @safeListener
89
- setStepHeight()
90
- if (downStep.value && player.motionY <= 0.0 && player.ticksExisted - onGroundTick <= 3 ) downStep()
91
- if (player.collidedHorizontally) lastCollidedTick = player.ticksExisted
92
- if (player.onGround) onGroundTick = player.ticksExisted
93
- }
94
- }
76
+ val height = bb.minY - playerY
95
77
96
- private val SafeClientEvent .shouldRunStep: Boolean
97
- get() = ! mc.gameSettings.keyBindSneak.isKeyDown
98
- && ! player.isElytraFlying
99
- && ! player.capabilities.isFlying
100
- && ! player.isOnLadder
101
- && ! player.isInOrAboveLiquid
102
- && (! checkHole || ! inHoleCheck())
78
+ if (height < .6 )
79
+ return
103
80
104
- private fun SafeClientEvent.setStepHeight () {
105
- player.stepHeight = if (upStep.value && player.onGround && player.collidedHorizontally) height else defaultHeight
106
- player.ridingEntity?.let {
107
- it.stepHeight = if (entityStep && it.collidedHorizontally) height else 1.0f
108
- }
109
- }
81
+ val player = mc.player
82
+ val connection = mc.connection ? : return
110
83
111
- private fun SafeClientEvent.downStep () {
112
- // Down step doesn't work for edge lower than 1 blocks anyways
113
- val belowBB = player.entityBoundingBox.expand(0.0 , - 1.05 , 0.0 )
114
- if (world.collidesWithAnyBlock(belowBB)) player.motionY - = downSpeed
115
- }
84
+ val values = ArrayList <Double >()
116
85
117
- init {
118
- safeListener<PacketEvent .Send > { event ->
119
- if (! upStep.value || mode != Mode .PACKET || ! shouldRunStep) return @safeListener
120
- if (event.packet !is CPacketPlayer || event.packet !is CPacketPlayer .Position && event.packet !is CPacketPlayer .PositionRotation ) return @safeListener
121
- if (ignoredPackets.remove(event.packet)) return @safeListener
122
-
123
- val prevPos = PlayerPacketManager .prevServerSidePosition
124
- if (player.ticksExisted - lastCollidedTick <= 5 ) getStepArray(event.packet.playerY - prevPos.y)?.let {
125
- for (posY in it) {
126
- val packet = CPacketPlayer .Position (prevPos.x, prevPos.y + posY, prevPos.z, true )
127
- ignoredPackets.add(packet)
128
- connection.sendPacket(packet)
129
- }
130
- }
86
+ when {
87
+ height > 2.019 -> values.addAll(listOf (.425 , .821 , .699 , .599 , 1.022 , 1.372 , 1.652 , 1.869 , 2.019 , 1.919 ))
88
+ height > 1.5 -> values.addAll(listOf (.42 , .78 , .63 , .51 , .9 , 1.21 , 1.45 , 1.43 ))
89
+ height > 1.015 -> values.addAll(listOf (.42 , .7532 , 1.01 , 1.093 , 1.015 ))
90
+ height > .6 -> values.addAll(listOf (.42 * height, .7532 * height))
131
91
}
132
- }
133
-
134
- private fun getStepArray (diff : Double ) = when {
135
- height >= diff && diff in 0.6 .. 1.0 -> stepOne
136
- height >= diff && diff in 1.0 .. 1.5 -> stepOneHalf
137
- height >= diff && diff in 1.5 .. 2.0 -> stepTwo
138
- else -> null
139
- }
140
92
141
- private val stepOne = doubleArrayOf(0.41999 , 0.75320 )
142
- private val stepOneHalf = doubleArrayOf(0.41999 , 0.75320 , 1.00133 , 1.16611 , 1.24919 , 1.17079 )
143
- private val stepTwo = doubleArrayOf(0.42 , 0.78 , 0.63 , 0.51 , 0.90 , 1.21 , 1.45 , 1.43 )
93
+ if (strict && height > .6 ) values.add(height)
144
94
145
- init {
146
- upStep.valueListeners.add { _, it ->
147
- BaritoneUtils .settings?.assumeStep?.value = isEnabled && it
95
+ values.forEach {
96
+ connection.sendPacket(CPacketPlayer .Position (player.posX, player.posY + it, player.posZ, false ))
148
97
}
98
+
99
+ modifyTimer(50f * values.size)
100
+ timing = true
149
101
}
150
102
}
0 commit comments