Skip to content

Commit

Permalink
Updated the thing
Browse files Browse the repository at this point in the history
StewStrong committed Nov 25, 2023
1 parent 30f689d commit b25fa98
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@
import org.valkyrienskies.core.api.ships.ClientShip;
import org.valkyrienskies.mod.client.audio.VelocityTickableSoundInstance;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import org.valkyrienskies.mod.common.util.EntityDraggingInformation;
import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider;
import org.valkyrienskies.mod.mixinducks.com.mojang.blaze3d.audio.HasOpenALVelocity;

@Mixin(SoundEngine.class)
@@ -31,6 +33,7 @@ public abstract class MixinSoundEngine {
protected abstract float calculatePitch(SoundInstance sound);

// Applies the velocity provided by a VelocityTickableSoundInstance
@SuppressWarnings("unused")
@WrapOperation(
at = @At(
value = "INVOKE",
@@ -39,7 +42,7 @@ public abstract class MixinSoundEngine {
),
method = "tickNonPaused"
)
private Object redirectGet(final Map instance, final Object obj, final Operation<Object> get) {
private Object redirectGet(final Map<?, ?> instance, final Object obj, final Operation<Object> get) {
if (obj instanceof final VelocityTickableSoundInstance soundInstance) {
final ChannelAccess.ChannelHandle handle = (ChannelAccess.ChannelHandle) instance.get(soundInstance);
final float f = calculateVolume(soundInstance);
@@ -59,6 +62,7 @@ private Object redirectGet(final Map instance, final Object obj, final Operation
return get.call(instance, obj);
}

@SuppressWarnings("unused")
@WrapOperation(
at = @At(
value = "INVOKE",
@@ -76,6 +80,12 @@ private void injectListenerVelocity(final Listener listener, final Vec3 position
final ClientShip mounted = VSGameUtilsKt.getShipObjectEntityMountedTo(level, player);
if (mounted != null) {
((HasOpenALVelocity) listener).setVelocity(mounted.getVelocity());
} else {
final EntityDraggingInformation dragInfo = ((IEntityDraggingInformationProvider) player).getDraggingInformation();
if (dragInfo.isEntityBeingDraggedByAShip()) {
final Vector3dc playerVel = dragInfo.getAddedMovementLastTick();
((HasOpenALVelocity) listener).setVelocity(playerVel);
}
}
}

0 comments on commit b25fa98

Please sign in to comment.