Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ProfessorFichte/Bards/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The BardsSounds class provides a registry system for sound events in the Bards RPG mod. It handles sound event registration, variant management, and provides utility methods for playing sounds in the world.
Entry structure
Sound entries are managed through the nested Entry class:
public static final class Entry {
private final Identifier id;
private final SoundEvent soundEvent;
private RegistryEntry<SoundEvent> entry;
private int variants = 1;
}
Unique identifier for the sound in the format bards_rpg:sound_name
Minecraft sound event instance
entry
RegistryEntry<SoundEvent>
Registry entry set after registration
Number of sound variants available for randomization
Constructors
Basic constructor
public Entry(Identifier id, SoundEvent soundEvent)
Creates an entry with a specific identifier and sound event.
Pre-configured sound event instance
Name-based constructor
public Entry(String name)
Creates an entry from a name string, automatically prefixing with the mod ID.
Sound name (e.g., “lute_strum”) - will become bards_rpg:lute_strum
Identifier-based constructor
public Entry(Identifier id)
Creates an entry with default sound event settings.
Complete sound identifier
Builder methods
travelDistance
public Entry travelDistance(float distance)
Sets the maximum distance the sound can travel before attenuating.
Travel distance in blocks
New Entry instance with updated travel distance
Example:
public static final Entry distant_horn = add(
new Entry("horn_blast").travelDistance(64.0f)
);
variants
public Entry variants(int variants)
Specifies the number of sound variants for randomization.
Number of variants (corresponds to sound files with _1, _2, etc. suffixes)
This Entry instance for method chaining
Example:
public static final Entry lute_note = add(
new Entry("lute_note").variants(3)
);
// Expects: lute_note_1.ogg, lute_note_2.ogg, lute_note_3.ogg
Accessor methods
id()
Returns the sound identifier.
soundEvent()
public SoundEvent soundEvent()
Returns the sound event instance.
entry()
public RegistryEntry<SoundEvent> entry()
Returns the registry entry (available after registration).
variants()
Returns the number of sound variants.
Registration
register()
public static void register()
Registers all sound entries with the Minecraft sound registry. This method should be called during mod initialization.
// During mod initialization
BardsSounds.register();
Playback utilities
playSoundEvent (basic)
public static void playSoundEvent(World world, Entity entity, SoundEvent soundEvent)
Plays a sound at an entity’s location with default volume and pitch.
The world to play the sound in
Entity at whose position the sound should play
playSoundEvent (advanced)
public static void playSoundEvent(World world, Entity entity, SoundEvent soundEvent, float volume, float pitch)
Plays a sound with custom volume and pitch.
The world to play the sound in
Entity at whose position the sound should play
Volume level (1.0 = normal, higher = louder)
Pitch level (1.0 = normal, higher = higher pitch)
Usage example
import com.bards.content.BardsSounds;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
public class SoundExample {
// Define a new sound
public static final BardsSounds.Entry LUTE_STRUM = BardsSounds.add(
new BardsSounds.Entry("lute_strum")
.travelDistance(32.0f)
.variants(3)
);
// Play the sound
public void playLuteSound(World world, PlayerEntity player) {
BardsSounds.playSoundEvent(
world,
player,
LUTE_STRUM.soundEvent(),
1.0f, // normal volume
1.0f // normal pitch
);
}
// Play with variation
public void playHighPitchedLute(World world, PlayerEntity player) {
BardsSounds.playSoundEvent(
world,
player,
LUTE_STRUM.soundEvent(),
0.8f, // slightly quieter
1.5f // higher pitch
);
}
}
Sound file structure
When defining sound entries, ensure corresponding sound files exist in your resource pack:
resources/
assets/
bards_rpg/
sounds/
lute_strum_1.ogg
lute_strum_2.ogg
lute_strum_3.ogg
sounds.json
And register them in sounds.json:
{
"lute_strum": {
"sounds": [
"bards_rpg:lute_strum_1",
"bards_rpg:lute_strum_2",
"bards_rpg:lute_strum_3"
],
"subtitle": "Lute strums"
}
}
Notes
- The class currently has no registered sounds (the
test entry is commented out)
- All sounds are played in the
PLAYERS sound category
- Sound playback uses
world.playSound() which is server-side and syncs to clients automatically
- The
playSoundEvent methods pass null as the player parameter to ensure all nearby players hear the sound