-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented ClientSoundPlayer for client-side sound playback at any p…
…osition
- Loading branch information
1 parent
ed5ae50
commit c94d2c8
Showing
12 changed files
with
100 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/floralquafloral/util/ClientSoundPlayer.java
This file contains 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,47 @@ | ||
package com.floralquafloral.util; | ||
|
||
import com.floralquafloral.mariodata.MarioData; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.sound.PositionedSoundInstance; | ||
import net.minecraft.client.sound.SoundManager; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvent; | ||
import net.minecraft.util.math.random.Random; | ||
|
||
@SuppressWarnings("UnusedReturnValue") | ||
public abstract class ClientSoundPlayer { | ||
public static final SoundManager SOUND_MANAGER = MinecraftClient.getInstance().getSoundManager(); | ||
|
||
public static PositionedSoundInstance playSound(SoundEvent event, SoundCategory category, double x, double y, double z, float volume, float pitch, long seed) { | ||
PositionedSoundInstance sound = new PositionedSoundInstance( | ||
event, | ||
category, | ||
volume, | ||
pitch, | ||
Random.create(seed), | ||
x, | ||
y, | ||
z | ||
); | ||
SOUND_MANAGER.play(sound); | ||
return sound; | ||
} | ||
|
||
public static PositionedSoundInstance playSound(SoundEvent event, SoundCategory category, Entity entity, float volume, float pitch, long seed) { | ||
return playSound(event, category, entity.getX(), entity.getY(), entity.getZ(), volume, pitch, seed); | ||
} | ||
|
||
public static PositionedSoundInstance playSound(SoundEvent event, MarioData data, float volume, float pitch, long seed) { | ||
return playSound(event, SoundCategory.PLAYERS, data.getMario(), volume, pitch, seed); | ||
} | ||
|
||
public static PositionedSoundInstance playSound(SoundEvent event, MarioData data, long seed) { | ||
return playSound(event, data, 1.0F, 1.0F, seed); | ||
} | ||
|
||
public static void kill(PositionedSoundInstance sound) { | ||
SOUND_MANAGER.stop(sound); | ||
} | ||
} |
This file contains 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
Binary file modified
BIN
-76 Bytes
(99%)
src/main/resources/assets/qua_mario/sounds/sfx/action/unduck.ogg
Binary file not shown.