1+ package com.lambda.module.modules.combat
2+
3+ import com.lambda.context.SafeContext
4+ import com.lambda.event.events.AttackEvent
5+ import com.lambda.event.listener.SafeListener.Companion.listener
6+ import com.lambda.interaction.rotation.Rotation
7+ import com.lambda.interaction.rotation.Rotation.Companion.rotationTo
8+ import com.lambda.module.Module
9+ import com.lambda.module.tag.ModuleTag
10+ import com.lambda.util.primitives.extension.component1
11+ import com.lambda.util.primitives.extension.component2
12+ import com.lambda.util.primitives.extension.component3
13+ import com.lambda.util.primitives.extension.rotation
14+ import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket
15+ import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket
16+ import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket
17+ import net.minecraft.util.Hand
18+ import net.minecraft.util.math.BlockPos
19+ import net.minecraft.util.math.Direction
20+
21+ object Criticals : Module(
22+ name = " Criticals" ,
23+ description = " Forces your hits to be critical" ,
24+ defaultTags = setOf(ModuleTag .COMBAT )
25+ ) {
26+ private val mode by setting(" Mode" , Mode .Grim )
27+
28+ enum class Mode {
29+ Grim
30+ }
31+
32+ init {
33+ listener<AttackEvent .Pre > {
34+ when (mode) {
35+ Mode .Grim -> {
36+ if (player.isOnGround) posPacket(0.00000001 , rotation = player.rotation)
37+ posPacket(- 0.000000001 , rotation = player.eyePos.rotationTo(it.entity.boundingBox.center))
38+
39+ connection.sendPacket(PlayerInteractItemC2SPacket (Hand .OFF_HAND , 0 ))
40+ connection.sendPacket(PlayerActionC2SPacket (PlayerActionC2SPacket .Action .RELEASE_USE_ITEM , BlockPos .ORIGIN , Direction .DOWN ))
41+ }
42+ }
43+ }
44+ }
45+
46+ private fun SafeContext.posPacket (yOffset : Double , ground : Boolean = false, rotation : Rotation ? ) {
47+ val (x, y, z) = player.pos
48+
49+ val packet = rotation?.let {
50+ PlayerMoveC2SPacket .Full (x, y + yOffset, z, it.yawF, it.pitchF, ground)
51+ } ? : PlayerMoveC2SPacket .PositionAndOnGround (x, y + yOffset, z, ground)
52+
53+ connection.sendPacket(packet)
54+ }
55+ }
0 commit comments