Skip to content

Commit 04e4c9e

Browse files
committed
Test: Trident flight
1 parent 5096c49 commit 04e4c9e

File tree

3 files changed

+87
-2
lines changed

3 files changed

+87
-2
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.lambda.mixin.world;
2+
3+
import com.lambda.module.modules.movement.TridentFlight;
4+
import net.minecraft.util.math.BlockPos;
5+
import net.minecraft.world.World;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.Inject;
9+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
10+
11+
@Mixin(World.class)
12+
public class WorldMixin {
13+
@Inject(method = "hasRain", at = @At("HEAD"), cancellable = true)
14+
private void hasRain(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
15+
if (TridentFlight.INSTANCE.isEnabled()) cir.setReturnValue(TridentFlight.INSTANCE.getRain());
16+
}
17+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
}

common/src/main/resources/lambda.mixins.common.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
"render.GameRendererMixin",
2323
"render.GlStateManagerMixin",
2424
"render.InGameHudMixin",
25-
"render.VertexBufferMixin",
2625
"render.LightmapTextureManagerMixin",
2726
"render.LivingEntityRendererMixin",
2827
"render.RenderTickCounterMixin",
29-
"render.WorldRendererMixin"
28+
"render.VertexBufferMixin",
29+
"render.WorldRendererMixin",
30+
"world.WorldMixin"
3031
],
3132
"injectors": {
3233
"defaultRequire": 1

0 commit comments

Comments
 (0)