From b428a30466acbb1335dedb5343951e868d78683c Mon Sep 17 00:00:00 2001 From: Camii2407 Date: Tue, 6 Aug 2024 15:33:38 +0100 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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 05/10] 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 06/10] 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 07/10] 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() } From ff9b4470b20e9a265ab03ff034573fdb23abb1a0 Mon Sep 17 00:00:00 2001 From: Camii2407 Date: Thu, 19 Sep 2024 23:49:21 +0100 Subject: [PATCH 08/10] RocketBoost havent tested yet because im having intellij issues (fixing now), inb4 kamigen correction --- .../entity/FireworkRocketEntityMixin.java | 51 +++++++++++++++++++ .../render/LivingEntityRendererMixin.java | 2 +- .../module/modules/movement/ElytraFly.kt | 11 +++- .../main/resources/lambda.mixins.common.json | 7 ++- 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 common/src/main/java/com/lambda/mixin/entity/FireworkRocketEntityMixin.java diff --git a/common/src/main/java/com/lambda/mixin/entity/FireworkRocketEntityMixin.java b/common/src/main/java/com/lambda/mixin/entity/FireworkRocketEntityMixin.java new file mode 100644 index 000000000..5ddefeaae --- /dev/null +++ b/common/src/main/java/com/lambda/mixin/entity/FireworkRocketEntityMixin.java @@ -0,0 +1,51 @@ +package com.lambda.mixin.entity; + +import com.lambda.module.Module; +import com.lambda.module.modules.movement.ElytraFly; +import com.lambda.util.Nameable; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.projectile.FireworkRocketEntity; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import javax.annotation.Nullable; + +@Mixin(FireworkRocketEntity.class) +public class FireworkRocketEntityMixin { + + + @Shadow @Nullable public LivingEntity shooter; + + @Redirect( + method = "tick", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/LivingEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V" + ) + ) + private void redirectSetVelocity(LivingEntity instance, Vec3d vec3d) { + + if (ElytraFly.INSTANCE.isEnabled() && ElytraFly.INSTANCE.getMode().equals(ElytraFly.Mode.ROCKET_BOOST)) { + + double speedMultiplier = ElytraFly.INSTANCE.getRocketSpeed(); + + assert shooter != null; + Vec3d rotationVector = shooter.getRotationVector(); + Vec3d currentVelocity = shooter.getVelocity(); + + double d = 1.5 * speedMultiplier; + double e = 0.1 * speedMultiplier; + + Vec3d newVelocity = currentVelocity.add( + rotationVector.x * e + (rotationVector.x * d - currentVelocity.x) * 0.5, + rotationVector.y * e + (rotationVector.y * d - currentVelocity.y) * 0.5, + rotationVector.z * e + (rotationVector.z * d - currentVelocity.z) * 0.5 + ); + + this.shooter.setVelocity(newVelocity); + } + } +} diff --git a/common/src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java b/common/src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java index 5de183ea1..488f30745 100644 --- a/common/src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java @@ -34,7 +34,7 @@ private void injectRender(T livingEntity, float f, float g, MatrixStack matrixSt this.lambda$pitch = rotationPitch; } - @Redirect(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;lerp(FFF)F", ordinal = 0)) + @Redirect(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;lerp(FFF)F", ordinal = 0), require = 0) private float injectRotationPitch(float g, float f, float s) { return Objects.requireNonNullElseGet(lambda$pitch, () -> MathHelper.lerp(g, f, s)); } 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 d21dc8476..ed54305e5 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 @@ -14,11 +14,13 @@ object ElytraFly : Module( defaultTags = setOf(ModuleTag.MOVEMENT, ModuleTag.GRIM) ) { // private val page by setting("Page", Page.GENERAL) // Uncomment when needed - private val mode by setting("Mode", Mode.BOOST) + 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 mute by setting("Mute Elytra", false, "Mutes the elytra sound when gliding") + val rocketSpeed by setting("Rocket Speed", 2.0, 0.0 ..5.0, description = "Speed multiplier that the rocket gives you") { mode == Mode.ROCKET_BOOST } + init { listener { when (mode) { @@ -27,9 +29,15 @@ object ElytraFly : Module( addSpeed(speed) } } + + Mode.ROCKET_BOOST -> { + + + } } } + listener { event -> if (!mute) return@listener if (event.sound.id != SoundEvents.ITEM_ELYTRA_FLYING.id) return@listener @@ -44,6 +52,7 @@ object ElytraFly : Module( enum class Mode { BOOST, + ROCKET_BOOST, // Add more when needed } } diff --git a/common/src/main/resources/lambda.mixins.common.json b/common/src/main/resources/lambda.mixins.common.json index d9c7a6fb4..7ca37d5cb 100644 --- a/common/src/main/resources/lambda.mixins.common.json +++ b/common/src/main/resources/lambda.mixins.common.json @@ -36,9 +36,12 @@ "render.WorldRendererMixin", "world.BlockCollisionSpliteratorMixin", "world.ClientChunkManagerMixin", - "world.ClientWorldMixin" + "world.ClientWorldMixin", + "entity.FireworkRocketEntityMixin" ], "injectors": { "defaultRequire": 1 - } + }, + "mixins": [ + ] } From 0b9f4757a7735881b62747111d6238e7d2c56159 Mon Sep 17 00:00:00 2001 From: Constructor Date: Fri, 20 Sep 2024 02:27:48 +0200 Subject: [PATCH 09/10] Refactor --- .../entity/FireworkRocketEntityMixin.java | 33 ++---------- .../module/modules/movement/ElytraFly.kt | 51 +++++++++++-------- 2 files changed, 33 insertions(+), 51 deletions(-) diff --git a/common/src/main/java/com/lambda/mixin/entity/FireworkRocketEntityMixin.java b/common/src/main/java/com/lambda/mixin/entity/FireworkRocketEntityMixin.java index 5ddefeaae..9fbeb63c7 100644 --- a/common/src/main/java/com/lambda/mixin/entity/FireworkRocketEntityMixin.java +++ b/common/src/main/java/com/lambda/mixin/entity/FireworkRocketEntityMixin.java @@ -1,24 +1,15 @@ package com.lambda.mixin.entity; -import com.lambda.module.Module; import com.lambda.module.modules.movement.ElytraFly; -import com.lambda.util.Nameable; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.FireworkRocketEntity; import net.minecraft.util.math.Vec3d; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import javax.annotation.Nullable; - @Mixin(FireworkRocketEntity.class) public class FireworkRocketEntityMixin { - - - @Shadow @Nullable public LivingEntity shooter; - @Redirect( method = "tick", at = @At( @@ -26,26 +17,8 @@ public class FireworkRocketEntityMixin { target = "Lnet/minecraft/entity/LivingEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V" ) ) - private void redirectSetVelocity(LivingEntity instance, Vec3d vec3d) { - - if (ElytraFly.INSTANCE.isEnabled() && ElytraFly.INSTANCE.getMode().equals(ElytraFly.Mode.ROCKET_BOOST)) { - - double speedMultiplier = ElytraFly.INSTANCE.getRocketSpeed(); - - assert shooter != null; - Vec3d rotationVector = shooter.getRotationVector(); - Vec3d currentVelocity = shooter.getVelocity(); - - double d = 1.5 * speedMultiplier; - double e = 0.1 * speedMultiplier; - - Vec3d newVelocity = currentVelocity.add( - rotationVector.x * e + (rotationVector.x * d - currentVelocity.x) * 0.5, - rotationVector.y * e + (rotationVector.y * d - currentVelocity.y) * 0.5, - rotationVector.z * e + (rotationVector.z * d - currentVelocity.z) * 0.5 - ); - - this.shooter.setVelocity(newVelocity); - } + private void redirectSetVelocity(LivingEntity shooter, Vec3d vec3d) { + if (!ElytraFly.getDoBoost()) return; + ElytraFly.boostRocket(shooter); } } 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 ed54305e5..fef1b96ef 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 @@ -5,7 +5,9 @@ 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.threading.runSafe import com.lambda.util.player.MovementUtils.addSpeed +import net.minecraft.entity.LivingEntity import net.minecraft.sound.SoundEvents object ElytraFly : Module( @@ -14,30 +16,24 @@ object ElytraFly : Module( defaultTags = setOf(ModuleTag.MOVEMENT, ModuleTag.GRIM) ) { // private val page by setting("Page", Page.GENERAL) // Uncomment when needed - 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 playerBoost by setting("Player Boost", true, description = "Boosts the player when flying") + private val playerSpeed by setting("Player Speed", 0.02, 0.0..0.5, 0.005, description = "Speed to add when flying") { playerBoost } + private val rocketBoost by setting("Rocket Boost", false, description = "Boosts the player when using a firework") + private val rocketSpeed by setting("Rocket Speed", 2.0, 0.0 ..2.0, description = "Speed multiplier that the rocket gives you") { rocketBoost } + private val mute by setting("Mute Elytra", false, "Mutes the elytra sound when gliding") - val rocketSpeed by setting("Rocket Speed", 2.0, 0.0 ..5.0, description = "Speed multiplier that the rocket gives you") { mode == Mode.ROCKET_BOOST } + @JvmStatic + val doBoost: Boolean get() = isEnabled && playerBoost init { listener { - when (mode) { - Mode.BOOST -> { - if (player.isFallFlying && !player.isUsingItem) { - addSpeed(speed) - } - } - - Mode.ROCKET_BOOST -> { - - - } + if (playerBoost && player.isFallFlying && !player.isUsingItem) { + addSpeed(playerSpeed) } } - listener { event -> if (!mute) return@listener if (event.sound.id != SoundEvents.ITEM_ELYTRA_FLYING.id) return@listener @@ -45,14 +41,27 @@ object ElytraFly : Module( } } - private enum class Page { - GENERAL, - // Add more when needed + @JvmStatic + fun boostRocket(shooter: LivingEntity) { + runSafe { + if (shooter != player) return@runSafe + + val vec = player.rotationVector + val velocity = player.velocity + + val d = 1.5 * rocketSpeed + val e = 0.1 * rocketSpeed + + player.velocity = velocity.add( + vec.x * e + (vec.x * d - velocity.x) * 0.5, + vec.y * e + (vec.y * d - velocity.y) * 0.5, + vec.z * e + (vec.z * d - velocity.z) * 0.5 + ) + } } - enum class Mode { - BOOST, - ROCKET_BOOST, + private enum class Page { + GENERAL, // Add more when needed } } From 350d02cbbc05dabcc85cf3f3151eec8303fe7cc1 Mon Sep 17 00:00:00 2001 From: Camii2407 Date: Fri, 20 Sep 2024 02:17:43 +0100 Subject: [PATCH 10/10] Fixed mistake in mixins --- common/src/main/resources/lambda.mixins.common.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/common/src/main/resources/lambda.mixins.common.json b/common/src/main/resources/lambda.mixins.common.json index 6d1bf94d0..640f64e30 100644 --- a/common/src/main/resources/lambda.mixins.common.json +++ b/common/src/main/resources/lambda.mixins.common.json @@ -47,7 +47,5 @@ ], "injectors": { "defaultRequire": 1 - }, - "mixins": [ - ] + } }