Skip to content

Commit 2ae37a1

Browse files
committed
Feature: Trident boost
1 parent 04e4c9e commit 2ae37a1

File tree

4 files changed

+59
-16
lines changed

4 files changed

+59
-16
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.lambda.mixin.items;
2+
3+
import com.lambda.module.modules.movement.TridentBoost;
4+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
5+
import net.minecraft.item.TridentItem;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.ModifyArg;
9+
10+
@Mixin(TridentItem.class)
11+
public class TridentMixin {
12+
// Forge doesn't support the @ModityArgs annotation, so we have to chain multiple @ModifyArg
13+
@ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V"), index = 0)
14+
private double modifyVelocity0(double velocity) { return TridentBoost.INSTANCE.isEnabled() ? velocity * TridentBoost.INSTANCE.getTridentSpeed() : velocity; }
15+
16+
@ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V"), index = 1)
17+
private double modifyVelocity1(double velocity) { return TridentBoost.INSTANCE.isEnabled() ? velocity * TridentBoost.INSTANCE.getTridentSpeed() : velocity; }
18+
19+
@ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V"), index = 2)
20+
private double modifyVelocity2(double velocity) { return TridentBoost.INSTANCE.isEnabled() ? velocity * TridentBoost.INSTANCE.getTridentSpeed() : velocity; }
21+
22+
@ModifyExpressionValue(method = {"onStoppedUsing", "use"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isTouchingWaterOrRain()Z"))
23+
private boolean modifyIsTouchingWaterOrRain(boolean original) { return TridentBoost.INSTANCE.isEnabled() ? TridentBoost.INSTANCE.getForceUse() : original; }
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.lambda.module.modules.movement
2+
3+
import com.lambda.module.Module
4+
import com.lambda.module.tag.ModuleTag
5+
6+
object TridentBoost : Module(
7+
name = "TridentBoost",
8+
description = "Boosts you with tridents",
9+
defaultTags = setOf(ModuleTag.MOVEMENT)
10+
) {
11+
val tridentSpeed by setting("Speed Factor", 2.0, 0.1..3.0, 0.1, description = "Speed factor of the trident boost")
12+
val forceUse by setting("Force Use", true, description = "Try to use the trident outside of water or rain")
13+
}

common/src/main/kotlin/com/lambda/module/modules/movement/TridentFlight.kt

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.lambda.module.modules.movement
22

3-
import baritone.api.utils.Helper
43
import com.lambda.event.events.TickEvent
54
import com.lambda.event.listener.SafeListener.Companion.listener
65
import com.lambda.module.Module
76
import com.lambda.module.tag.ModuleTag
7+
import net.minecraft.enchantment.EnchantmentHelper
88
import net.minecraft.entity.MovementType
99
import net.minecraft.item.TridentItem
1010
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket
@@ -22,8 +22,10 @@ object TridentFlight : Module(
2222
description = "Allows you to fly with tridents",
2323
defaultTags = setOf(ModuleTag.MOVEMENT, ModuleTag.BYPASS, ModuleTag.GRIM),
2424
) {
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")
25+
private val bounce by setting("Bounce", true, description = "Automatically use the trident")
26+
private val delay by setting("Delay", 0, 0..20, 1, description = "Delay in ticks before releasing the trident", visibility = { bounce })
27+
private val tridentSpeed by setting("Speed Factor", 1.0, 0.1..5.0, 0.1, description = "Speed factor of the trident flight")
28+
2729
val rain by setting("Rain", true, description = "Set rain client-side to allow flight")
2830

2931
private var ticks = 0
@@ -39,22 +41,25 @@ object TridentFlight : Module(
3941
connection.sendPacket(UpdateSelectedSlotC2SPacket(tridentSlot))
4042
connection.sendPacket(PlayerActionC2SPacket(PlayerActionC2SPacket.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.DOWN))
4143

42-
if (grimBypass) {
43-
val yaw = player.yaw * (Math.PI / 180)
44-
val pitch = player.pitch * (Math.PI / 180)
44+
val level = EnchantmentHelper.getRiptide(player.activeItem)
45+
val yaw = player.yaw * (Math.PI / 180)
46+
val pitch = player.pitch * (Math.PI / 180)
4547

46-
val x = -sin(yaw) * cos(pitch)
47-
val y = -sin(pitch)
48-
val z = cos(yaw) * cos(pitch)
48+
val x = -sin(yaw) * cos(pitch)
49+
val y = -sin(pitch)
50+
val z = cos(yaw) * cos(pitch)
4951

50-
val dot = sqrt(x * x + y * y + z * z)
51-
val multiplier = 3 / dot
52+
val dot = sqrt(x * x + y * y + z * z)
53+
val multiplier = (3 * ((1.0 + level) / 4.0)) / dot
5254

53-
player.addVelocity(x * multiplier, y * multiplier, z * multiplier)
55+
player.addVelocity(
56+
x * multiplier * tridentSpeed,
57+
y * multiplier * tridentSpeed,
58+
z * multiplier * tridentSpeed
59+
)
5460

55-
if (player.isOnGround)
56-
player.move(MovementType.SELF, Vec3d(0.0, 1.2, 0.0))
57-
}
61+
if (player.isOnGround)
62+
player.move(MovementType.SELF, Vec3d(0.0, 1.19999, 0.0))
5863

5964
connection.sendPacket(UpdateSelectedSlotC2SPacket(spoofSlot))
6065

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"render.RenderTickCounterMixin",
2828
"render.VertexBufferMixin",
2929
"render.WorldRendererMixin",
30-
"world.WorldMixin"
30+
"world.WorldMixin",
31+
"items.TridentMixin"
3132
],
3233
"injectors": {
3334
"defaultRequire": 1

0 commit comments

Comments
 (0)