-
Notifications
You must be signed in to change notification settings - Fork 41
[1.20.x] [All] Feat: Added elytra flight mode boost #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b428a30
ElytraFly
Camii2407 82f4153
lol elytrafly mode boost since i messed last one up somehow
Camii2407 0aed9ba
refactor: module style
emyfops 5a7bf4a
added Mute Elytra option to ElytraFly module
Camii2407 9cca975
Elytra extensions
bladekt 86c9949
Merge remote-tracking branch 'origin/feature/movement/elytraFly' into…
bladekt 0ac125b
changed default value of boost speed to 0.02
Camii2407 50b4954
Rename setting
Avanatiker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
common/src/main/java/com/lambda/mixin/client/sound/SoundSystemMixin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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() | ||
| } |
50 changes: 50 additions & 0 deletions
50
common/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| 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", | ||
| description = "Allows you to fly with an elytra", | ||
| 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) | ||
|
|
||
| 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 { | ||
| listener<MovementEvent.Pre> { | ||
| when (mode) { | ||
| Mode.BOOST -> { | ||
| if (player.isFallFlying && !player.isUsingItem) { | ||
| addSpeed(speed) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| listener<ClientEvent.Sound> { event -> | ||
| if (!elytraMute) return@listener | ||
| if (event.sound.id != SoundEvents.ITEM_ELYTRA_FLYING.id) return@listener | ||
| event.cancel() | ||
| } | ||
| } | ||
|
|
||
| private enum class Page { | ||
| GENERAL, | ||
| // Add more when needed | ||
| } | ||
|
|
||
| enum class Mode { | ||
| BOOST, | ||
| // Add more when needed | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.