Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}
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()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.lambda.module.modules.movement

import com.lambda.event.events.ClientEvent
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.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 mute by setting("Mute Elytra", false, "Mutes the elytra sound when gliding")

init {
listener<MovementEvent.Pre> {
when (mode) {
Mode.BOOST -> {
if (player.isFallFlying && !player.isUsingItem) {
addSpeed(speed)
}
}
}
}

listener<ClientEvent.Sound> { event ->
if (!mute) 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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
1 change: 1 addition & 0 deletions common/src/main/resources/lambda.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/lambda.mixins.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"MinecraftClientMixin",
"baritone.MixinBaritonePlayerContext",
"baritone.MixinLookBehavior",
"client.sound.SoundSystemMixin",
"entity.ClientPlayerEntityMixin",
"entity.ClientPlayInteractionManagerMixin",
"entity.EntityMixin",
Expand Down