Buckets:
| package com.example.examplemod; | |
| import net.minecraft.registry.Registries; | |
| import net.minecraft.registry.Registry; | |
| import net.minecraft.sound.SoundCategory; | |
| import net.minecraft.sound.SoundEvent; | |
| import net.minecraft.util.Identifier; | |
| import net.minecraft.world.World; | |
| import net.minecraft.util.math.BlockPos; | |
| /** | |
| * Custom sound event registration + playback helpers. | |
| * Requires a matching entry in: | |
| * assets/examplemod/sounds.json | |
| * and an .ogg file at: | |
| * assets/examplemod/sounds/gem_chime.ogg | |
| * | |
| * SoundEvent API unchanged across 1.21.7 - 1.21.11. | |
| */ | |
| public final class ExampleSounds { | |
| private ExampleSounds() {} | |
| public static final SoundEvent GEM_CHIME = registerSound("gem_chime"); | |
| private static SoundEvent registerSound(String path) { | |
| Identifier id = Identifier.of(ExampleMod.MOD_ID, path); | |
| return Registry.register(Registries.SOUND_EVENT, id, SoundEvent.of(id)); | |
| } | |
| /** Play the sound at a block position, audible to all nearby players. */ | |
| public static void playGemChime(World world, BlockPos pos) { | |
| world.playSound( | |
| null, // no specific source player (server broadcasts to all) | |
| pos, | |
| GEM_CHIME, | |
| SoundCategory.BLOCKS, | |
| 1.0f, // volume | |
| 1.0f // pitch | |
| ); | |
| } | |
| } | |
| /* | |
| * assets/examplemod/sounds.json | |
| * { | |
| * "gem_chime": { | |
| * "subtitle": "subtitle.examplemod.gem_chime", | |
| * "sounds": ["examplemod:gem_chime"] | |
| * } | |
| * } | |
| */ | |
Xet Storage Details
- Size:
- 1.56 kB
- Xet hash:
- 23c3f08a13bd88696338101ea763cb6a3c164f5a716bcaff728db15f0f0fabfd
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.