-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up sound effect registration code
- Loading branch information
Showing
8 changed files
with
59 additions
and
18 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
47 changes: 47 additions & 0 deletions
47
src/client/java/org/ladysnake/effective/core/index/EffectiveSounds.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 org.ladysnake.effective.core.index; | ||
|
||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.sound.BlockSoundGroup; | ||
import net.minecraft.sound.SoundEvent; | ||
import org.ladysnake.effective.core.Effective; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
public interface EffectiveSounds { | ||
|
||
List<SoundEvent> SOUND_EVENTS = new LinkedList<>(); | ||
|
||
SoundEvent AMBIENCE_WATERFALL = create("ambience.waterfall"); | ||
SoundEvent PARRY = create("entity.parry"); | ||
|
||
static SoundEvent create(String name) { | ||
SoundEvent soundEvent = SoundEvent.of(Effective.id(name)); | ||
SOUND_EVENTS.add(soundEvent); | ||
return soundEvent; | ||
} | ||
|
||
static BlockSoundGroup createBlockSoundGroup(String name, float volume, float pitch) { | ||
return new BlockSoundGroup(volume, pitch, | ||
create("block." + name + ".break"), | ||
create("block." + name + ".step"), | ||
create("block." + name + ".place"), | ||
create("block." + name + ".hit"), | ||
create("block." + name + ".fall")); | ||
} | ||
|
||
static BlockSoundGroup copyBlockSoundGroup(BlockSoundGroup blockSoundGroup, float volume, float pitch) { | ||
return new BlockSoundGroup(volume, pitch, | ||
blockSoundGroup.getBreakSound(), | ||
blockSoundGroup.getStepSound(), | ||
blockSoundGroup.getPlaceSound(), | ||
blockSoundGroup.getHitSound(), | ||
blockSoundGroup.getFallSound()); | ||
} | ||
|
||
static void initialize() { | ||
SOUND_EVENTS.forEach(soundEvent -> Registry.register(Registries.SOUND_EVENT, soundEvent.getId(), soundEvent)); | ||
} | ||
|
||
} |
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