|
| 1 | +package com.lambda.module.modules.movement |
| 2 | + |
| 3 | +import baritone.api.utils.Helper |
| 4 | +import com.lambda.event.events.TickEvent |
| 5 | +import com.lambda.event.listener.SafeListener.Companion.listener |
| 6 | +import com.lambda.module.Module |
| 7 | +import com.lambda.module.tag.ModuleTag |
| 8 | +import net.minecraft.entity.MovementType |
| 9 | +import net.minecraft.item.TridentItem |
| 10 | +import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket |
| 11 | +import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket |
| 12 | +import net.minecraft.util.math.BlockPos |
| 13 | +import net.minecraft.util.math.Direction |
| 14 | +import net.minecraft.util.math.Vec3d |
| 15 | +import kotlin.math.cos |
| 16 | +import kotlin.math.sin |
| 17 | +import kotlin.math.sqrt |
| 18 | + |
| 19 | + |
| 20 | +object TridentFlight : Module( |
| 21 | + name = "TridentFlight", |
| 22 | + description = "Allows you to fly with tridents", |
| 23 | + defaultTags = setOf(ModuleTag.MOVEMENT, ModuleTag.BYPASS, ModuleTag.GRIM), |
| 24 | +) { |
| 25 | + private val delay by setting("Delay", 0, 0..20, 1, description = "Delay in ticks before releasing the trident") |
| 26 | + private val grimBypass by setting("Grim Bypass", true, description = "Bypass Grim's trident flight check") |
| 27 | + val rain by setting("Rain", true, description = "Set rain client-side to allow flight") |
| 28 | + |
| 29 | + private var ticks = 0 |
| 30 | + |
| 31 | + init { |
| 32 | + listener<TickEvent.Pre> { |
| 33 | + if (ticks >= delay && |
| 34 | + player.activeItem.item is TridentItem) |
| 35 | + { |
| 36 | + val tridentSlot = player.inventory.selectedSlot |
| 37 | + val spoofSlot = player.inventory.swappableHotbarSlot |
| 38 | + |
| 39 | + connection.sendPacket(UpdateSelectedSlotC2SPacket(tridentSlot)) |
| 40 | + connection.sendPacket(PlayerActionC2SPacket(PlayerActionC2SPacket.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.DOWN)) |
| 41 | + |
| 42 | + if (grimBypass) { |
| 43 | + val yaw = player.yaw * (Math.PI / 180) |
| 44 | + val pitch = player.pitch * (Math.PI / 180) |
| 45 | + |
| 46 | + val x = -sin(yaw) * cos(pitch) |
| 47 | + val y = -sin(pitch) |
| 48 | + val z = cos(yaw) * cos(pitch) |
| 49 | + |
| 50 | + val dot = sqrt(x * x + y * y + z * z) |
| 51 | + val multiplier = 3 / dot |
| 52 | + |
| 53 | + player.addVelocity(x * multiplier, y * multiplier, z * multiplier) |
| 54 | + |
| 55 | + if (player.isOnGround) |
| 56 | + player.move(MovementType.SELF, Vec3d(0.0, 1.2, 0.0)) |
| 57 | + } |
| 58 | + |
| 59 | + connection.sendPacket(UpdateSelectedSlotC2SPacket(spoofSlot)) |
| 60 | + |
| 61 | + ticks = 0 |
| 62 | + } |
| 63 | + |
| 64 | + ticks++ |
| 65 | + } |
| 66 | + } |
| 67 | +} |
0 commit comments