Skip to content

Commit

Permalink
Fixed (#97) block place/break sounds not playing on Valkyrien ships
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrenix committed Jan 8, 2025
1 parent 6dbe886 commit 17751b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ private PositionSoundHandler(ClientLevel level, double x, double y, double z, So

/* Methods */

/**
* @return Whether this handler modified the sound in some way.
*/
public boolean isHandled()
{
return this.handled;
}

/**
* @return The {@link SoundEvent} managed by this handler.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import mod.adrenix.nostalgic.helper.sound.PositionSoundHandler;
import mod.adrenix.nostalgic.helper.sound.SoundHelper;
import mod.adrenix.nostalgic.tweak.config.ModTweak;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.sounds.SoundEvent;
Expand All @@ -26,9 +27,12 @@ public abstract class ClientLevelMixin
)
private SimpleSoundInstance nt_position_sound$modifyPlaySound(SimpleSoundInstance original, double x, double y, double z, SoundEvent sound, SoundSource source, float volume, float pitch, boolean distanceDelay, long seed)
{
if (!ModTweak.ENABLED.get())
return original;

PositionSoundHandler handler = SoundHelper.getHandlerAt((ClientLevel) (Object) this, x, y, z, sound, source, volume, pitch);

if (handler == null)
if (handler == null || !handler.isHandled())
return original;

return new SimpleSoundInstance(handler.getSound(), handler.getSource(), handler.getVolume(), handler.getPitch(), RandomSource.create(seed), x, y, z);
Expand Down

0 comments on commit 17751b5

Please sign in to comment.