From 7ab3fc89819eaa432ae1291ed174e80a21a53e63 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Thu, 27 Apr 2023 14:48:53 -0700 Subject: [PATCH] ElytraFastClose module --- .../lambda/mixin/accessor/AccessorEntity.java | 3 ++ .../modules/movement/ElytraFastClose.kt | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFastClose.kt diff --git a/src/main/java/com/lambda/mixin/accessor/AccessorEntity.java b/src/main/java/com/lambda/mixin/accessor/AccessorEntity.java index c4d8c93bf..74a20dd33 100644 --- a/src/main/java/com/lambda/mixin/accessor/AccessorEntity.java +++ b/src/main/java/com/lambda/mixin/accessor/AccessorEntity.java @@ -3,6 +3,7 @@ import net.minecraft.entity.Entity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(Entity.class) public interface AccessorEntity { @@ -10,4 +11,6 @@ public interface AccessorEntity { @Accessor("isInWeb") boolean getIsInWeb(); + @Invoker("setFlag") + void invokeSetFlag(int flag, boolean set); } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFastClose.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFastClose.kt new file mode 100644 index 000000000..8d906f9bc --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFastClose.kt @@ -0,0 +1,33 @@ +package com.lambda.client.module.modules.movement + +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.client.util.threads.safeListener +import com.lambda.mixin.accessor.AccessorEntity +import net.minecraft.network.play.client.CPacketPlayer +import net.minecraftforge.fml.common.gameevent.TickEvent + +object ElytraFastClose : Module( + name = "ElytraFastClose", + description = "Closes elytra on ground without waiting for the server", + category = Category.MOVEMENT +) { + private val stopMotion by setting("Stop Motion", true) + private val yThreshold by setting ("Y Distance", 0.05, 0.0..1.0, 0.01) + + init { + safeListener { + if (it.phase != TickEvent.Phase.START || !player.isElytraFlying) return@safeListener + if (world.collidesWithAnyBlock(player.entityBoundingBox.offset(0.0, -yThreshold, 0.0))) { + if (stopMotion) { + player.motionX = 0.0 + player.motionY = 0.0 + player.motionZ = 0.0 + } + (player as AccessorEntity).invokeSetFlag(7, false) + connection.sendPacket(CPacketPlayer(true)) + } + } + } + +} \ No newline at end of file