From b428a30466acbb1335dedb5343951e868d78683c Mon Sep 17 00:00:00 2001 From: Camii2407 Date: Tue, 6 Aug 2024 15:33:38 +0100 Subject: [PATCH 1/7] ElytraFly --- .../kotlin/com/lambda/module/modules/movement/ElytraFly.kt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt diff --git a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt new file mode 100644 index 000000000..569cf77a6 --- /dev/null +++ b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -0,0 +1,4 @@ +package com.lambda.module.modules.movement + +class ElytraFly { +} \ No newline at end of file From 82f41533492aaaf8e17f23f26f9b10b5d3db0004 Mon Sep 17 00:00:00 2001 From: Camii2407 Date: Tue, 6 Aug 2024 18:25:33 +0100 Subject: [PATCH 2/7] lol elytrafly mode boost since i messed last one up somehow --- .../module/modules/movement/ElytraFly.kt | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 569cf77a6..e743bfecd 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -1,4 +1,24 @@ -package com.lambda.module.modules.movement +package com.lambda.module.modules.movement; +import com.lambda.event.events.MovementEvent +import com.lambda.module.Module +import com.lambda.module.tag.ModuleTag +import com.lambda.event.listener.SafeListener.Companion.listener +import com.lambda.util.player.MovementUtils.addSpeed + +object ElytraFly : Module( + name = "ElytraFly", + description = "Elytra Go Brrr", + defaultTags = setOf(ModuleTag.MOVEMENT, ModuleTag.GRIM) +) { + private val speed by setting("Speed", 0.0, 0.0..0.5, 0.005) + init { + listener { + if (player.isFallFlying && !player.isUsingItem) { + addSpeed(speed) + } + } + } +} + + -class ElytraFly { -} \ No newline at end of file From 0aed9ba6145a4aa3a3d8edc69b8a9a6ac551f692 Mon Sep 17 00:00:00 2001 From: Edouard127 <46357922+Edouard127@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:34:33 -0400 Subject: [PATCH 3/7] refactor: module style --- .../module/modules/movement/ElytraFly.kt | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index e743bfecd..6c4697a18 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -1,24 +1,40 @@ -package com.lambda.module.modules.movement; +package com.lambda.module.modules.movement + import com.lambda.event.events.MovementEvent +import com.lambda.event.listener.SafeListener.Companion.listener import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.event.listener.SafeListener.Companion.listener import com.lambda.util.player.MovementUtils.addSpeed object ElytraFly : Module( name = "ElytraFly", - description = "Elytra Go Brrr", + description = "Allows you to fly with an elytra", defaultTags = setOf(ModuleTag.MOVEMENT, ModuleTag.GRIM) ) { - private val speed by setting("Speed", 0.0, 0.0..0.5, 0.005) + // private val page by setting("Page", Page.GENERAL) // Uncomment when needed + private val mode by setting("Mode", Mode.BOOST) + + private val speed by setting("Speed", 0.0, 0.0..0.5, 0.005, description = "Speed to add when flying") { mode == Mode.BOOST } + init { listener { - if (player.isFallFlying && !player.isUsingItem) { - addSpeed(speed) + when (mode) { + Mode.BOOST -> { + if (player.isFallFlying && !player.isUsingItem) { + addSpeed(speed) + } + } } } } -} - + private enum class Page { + GENERAL, + // Add more when needed + } + enum class Mode { + BOOST, + // Add more when needed + } +} From 5a7bf4a29450aa0b9111be50ba7e5f16397d4039 Mon Sep 17 00:00:00 2001 From: Camii2407 Date: Wed, 7 Aug 2024 22:42:27 +0100 Subject: [PATCH 4/7] added Mute Elytra option to ElytraFly module --- .../mixin/client/sound/SoundSystemMixin.java | 20 +++++++++++++++++++ .../com/lambda/event/events/ClientEvent.kt | 6 +++++- .../module/modules/movement/ElytraFly.kt | 10 ++++++++++ .../main/resources/lambda.mixins.common.json | 1 + 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/com/lambda/mixin/client/sound/SoundSystemMixin.java diff --git a/common/src/main/java/com/lambda/mixin/client/sound/SoundSystemMixin.java b/common/src/main/java/com/lambda/mixin/client/sound/SoundSystemMixin.java new file mode 100644 index 000000000..406d48ecc --- /dev/null +++ b/common/src/main/java/com/lambda/mixin/client/sound/SoundSystemMixin.java @@ -0,0 +1,20 @@ +package com.lambda.mixin.client.sound; + +import com.lambda.event.EventFlow; +import com.lambda.event.events.ClientEvent; +import net.minecraft.client.sound.SoundInstance; +import net.minecraft.client.sound.SoundSystem; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(SoundSystem.class) +public class SoundSystemMixin { + @Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At(value = "HEAD"), cancellable = true) + public void onPlay(SoundInstance sound, CallbackInfo ci) { + if (EventFlow.post(new ClientEvent.Sound(sound)).isCanceled()) { + ci.cancel(); + } + } +} diff --git a/common/src/main/kotlin/com/lambda/event/events/ClientEvent.kt b/common/src/main/kotlin/com/lambda/event/events/ClientEvent.kt index 0e692d8a6..42d8f50b6 100644 --- a/common/src/main/kotlin/com/lambda/event/events/ClientEvent.kt +++ b/common/src/main/kotlin/com/lambda/event/events/ClientEvent.kt @@ -1,10 +1,14 @@ package com.lambda.event.events import com.lambda.event.Event +import com.lambda.event.callback.Cancellable +import com.lambda.event.callback.ICancellable +import net.minecraft.client.sound.SoundInstance abstract class ClientEvent : Event { class Shutdown : ClientEvent() class Startup : ClientEvent() - class Timer(var speed: Double) : Event + class Timer(var speed: Double) : ClientEvent() + class Sound(val sound: SoundInstance) : ClientEvent(), ICancellable by Cancellable() } \ No newline at end of file diff --git a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 6c4697a18..301fe1b22 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -1,10 +1,13 @@ package com.lambda.module.modules.movement +import com.lambda.event.events.ClientEvent import com.lambda.event.events.MovementEvent +import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listener import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.player.MovementUtils.addSpeed +import net.minecraft.sound.SoundEvents object ElytraFly : Module( name = "ElytraFly", @@ -15,6 +18,7 @@ object ElytraFly : Module( private val mode by setting("Mode", Mode.BOOST) private val speed by setting("Speed", 0.0, 0.0..0.5, 0.005, description = "Speed to add when flying") { mode == Mode.BOOST } + private val elytraMute by setting("Mute Elytra", false, "Mutes elytra sound") init { listener { @@ -26,6 +30,12 @@ object ElytraFly : Module( } } } + + listener { event -> + if (!elytraMute) return@listener + if (event.sound.id != SoundEvents.ITEM_ELYTRA_FLYING.id) return@listener + event.cancel() + } } private enum class Page { diff --git a/common/src/main/resources/lambda.mixins.common.json b/common/src/main/resources/lambda.mixins.common.json index ff8a0378b..d9c7a6fb4 100644 --- a/common/src/main/resources/lambda.mixins.common.json +++ b/common/src/main/resources/lambda.mixins.common.json @@ -8,6 +8,7 @@ "MinecraftClientMixin", "baritone.MixinBaritonePlayerContext", "baritone.MixinLookBehavior", + "client.sound.SoundSystemMixin", "entity.ClientPlayerEntityMixin", "entity.ClientPlayInteractionManagerMixin", "entity.EntityMixin", From 9cca97509d41e10767501da33b2b5789aaf063c9 Mon Sep 17 00:00:00 2001 From: Blade-gl Date: Thu, 8 Aug 2024 16:02:37 +0300 Subject: [PATCH 5/7] Elytra extensions --- .../kotlin/com/lambda/util/primitives/extension/Entity.kt | 5 +++++ common/src/main/resources/lambda.accesswidener | 1 + 2 files changed, 6 insertions(+) diff --git a/common/src/main/kotlin/com/lambda/util/primitives/extension/Entity.kt b/common/src/main/kotlin/com/lambda/util/primitives/extension/Entity.kt index 86ed6f794..06ac94ea9 100644 --- a/common/src/main/kotlin/com/lambda/util/primitives/extension/Entity.kt +++ b/common/src/main/kotlin/com/lambda/util/primitives/extension/Entity.kt @@ -3,6 +3,7 @@ package com.lambda.util.primitives.extension import com.lambda.interaction.rotation.Rotation import com.lambda.util.math.MathUtils.lerp import net.minecraft.entity.Entity +import net.minecraft.entity.LivingEntity import net.minecraft.util.math.Vec3d val Entity.prevPos @@ -11,4 +12,8 @@ val Entity.prevPos val Entity.rotation get() = Rotation(yaw, pitch) +var LivingEntity.isElytraFlying + get() = isFallFlying + set(value) { setFlag(7, value) } + fun Vec3d.interpolate(other: Vec3d, t: Double) = lerp(this, other, t) \ No newline at end of file diff --git a/common/src/main/resources/lambda.accesswidener b/common/src/main/resources/lambda.accesswidener index bd4ab6ec7..63a995c34 100644 --- a/common/src/main/resources/lambda.accesswidener +++ b/common/src/main/resources/lambda.accesswidener @@ -19,6 +19,7 @@ accessible method net/minecraft/entity/Entity movementInputToVelocity (Lnet/mine accessible method net/minecraft/entity/passive/AbstractHorseEntity setHorseFlag (IZ)V accessible method net/minecraft/entity/passive/AbstractHorseEntity updateSaddle ()V accessible field net/minecraft/entity/LivingEntity lastAttackedTicks I +accessible method net/minecraft/entity/Entity setFlag (IZ)V # Camera accessible method net/minecraft/client/render/Camera setPos (DDD)V From 0ac125b60bbfda5a6f745cd63a64b97e55bac0e3 Mon Sep 17 00:00:00 2001 From: Camii2407 Date: Sat, 10 Aug 2024 09:03:26 +0100 Subject: [PATCH 6/7] changed default value of boost speed to 0.02 --- .../main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 301fe1b22..ec600973e 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -17,7 +17,7 @@ object ElytraFly : Module( // private val page by setting("Page", Page.GENERAL) // Uncomment when needed private val mode by setting("Mode", Mode.BOOST) - private val speed by setting("Speed", 0.0, 0.0..0.5, 0.005, description = "Speed to add when flying") { mode == Mode.BOOST } + private val speed by setting("Speed", 0.02, 0.0..0.5, 0.005, description = "Speed to add when flying") { mode == Mode.BOOST } private val elytraMute by setting("Mute Elytra", false, "Mutes elytra sound") init { From 50b4954cdb41b104847e1959fff785cd52c0c9a3 Mon Sep 17 00:00:00 2001 From: Constructor Date: Sat, 17 Aug 2024 04:18:51 +0200 Subject: [PATCH 7/7] Rename setting --- .../kotlin/com/lambda/module/modules/movement/ElytraFly.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index ec600973e..d21dc8476 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -2,7 +2,6 @@ package com.lambda.module.modules.movement import com.lambda.event.events.ClientEvent import com.lambda.event.events.MovementEvent -import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listener import com.lambda.module.Module import com.lambda.module.tag.ModuleTag @@ -18,7 +17,7 @@ object ElytraFly : Module( private val mode by setting("Mode", Mode.BOOST) private val speed by setting("Speed", 0.02, 0.0..0.5, 0.005, description = "Speed to add when flying") { mode == Mode.BOOST } - private val elytraMute by setting("Mute Elytra", false, "Mutes elytra sound") + private val mute by setting("Mute Elytra", false, "Mutes the elytra sound when gliding") init { listener { @@ -32,7 +31,7 @@ object ElytraFly : Module( } listener { event -> - if (!elytraMute) return@listener + if (!mute) return@listener if (event.sound.id != SoundEvents.ITEM_ELYTRA_FLYING.id) return@listener event.cancel() }