Search in sources :

Example 26 with SoundEvent

use of net.minecraft.sound.SoundEvent in project meteor-client by MeteorDevelopment.

the class SoundEventListSetting method parseImpl.

@Override
protected List<SoundEvent> parseImpl(String str) {
    String[] values = str.split(",");
    List<SoundEvent> sounds = new ArrayList<>(values.length);
    try {
        for (String value : values) {
            SoundEvent sound = parseId(Registry.SOUND_EVENT, value);
            if (sound != null)
                sounds.add(sound);
        }
    } catch (Exception ignored) {
    }
    return sounds;
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) ArrayList(java.util.ArrayList) NbtString(net.minecraft.nbt.NbtString)

Example 27 with SoundEvent

use of net.minecraft.sound.SoundEvent in project MiniMap by pl3xgaming.

the class Sound method initialize.

public static void initialize() {
    REGISTERED_SOUNDS.forEach(sound -> {
        sound.soundEvent = new SoundEvent(sound.identifier);
        MiniMap.LOG.info("Loaded sound " + sound.identifier);
    });
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent)

Example 28 with SoundEvent

use of net.minecraft.sound.SoundEvent in project MCDoom by AzureDoom.

the class ModSoundEvents method of.

static SoundEvent of(String id) {
    SoundEvent sound = new SoundEvent(new Identifier(DoomMod.MODID, id));
    Registry.register(Registry.SOUND_EVENT, new Identifier(DoomMod.MODID, id), sound);
    return sound;
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) Identifier(net.minecraft.util.Identifier)

Example 29 with SoundEvent

use of net.minecraft.sound.SoundEvent in project WK by witches-kitchen.

the class ParticlePacketHandler method handle.

@Environment(EnvType.CLIENT)
@Override
public void handle(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf buf, PacketSender responseSender) {
    final BlockPos pos = buf.readBlockPos();
    final Identifier particleId = buf.readIdentifier();
    final Identifier soundId = buf.readIdentifier();
    final byte range = buf.readByte();
    client.execute(() -> {
        final ClientWorld world = client.world;
        final ParticleType<?> particle = Registry.PARTICLE_TYPE.get(particleId);
        if (world != null) {
            for (int i = 0; i < range; i++) {
                world.addParticle((ParticleEffect) particle, pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D, 0.5D, 0.5D, 0.5D);
            }
            if (!soundId.toString().isEmpty()) {
                final SoundEvent soundEvent = Registry.SOUND_EVENT.get(soundId);
                world.playSound(pos, soundEvent, SoundCategory.NEUTRAL, 1.0F, 1.0F, false);
            }
        }
    });
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) Identifier(net.minecraft.util.Identifier) BlockPos(net.minecraft.util.math.BlockPos) ClientWorld(net.minecraft.client.world.ClientWorld) Environment(net.fabricmc.api.Environment)

Example 30 with SoundEvent

use of net.minecraft.sound.SoundEvent in project DawnAPI by DawnTeamMC.

the class SoundCreator method register.

@Override
public void register(ModData modData) {
    Identifier id = modData.id(this.name);
    this.sound = Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(id));
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) Identifier(net.minecraft.util.Identifier)

Aggregations

SoundEvent (net.minecraft.sound.SoundEvent)41 Identifier (net.minecraft.util.Identifier)13 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 BlockPos (net.minecraft.util.math.BlockPos)5 ItemStack (net.minecraft.item.ItemStack)4 SoundCategory (net.minecraft.sound.SoundCategory)4 List (java.util.List)3 Random (java.util.Random)3 DamageSource (net.minecraft.entity.damage.DamageSource)3 StatusEffect (net.minecraft.entity.effect.StatusEffect)3 NbtList (net.minecraft.nbt.NbtList)3 ServerWorld (net.minecraft.server.world.ServerWorld)3 World (net.minecraft.world.World)3 Origins (io.github.apace100.origins.Origins)2 ConditionFactory (io.github.apace100.origins.power.factory.condition.ConditionFactory)2 ModRegistries (io.github.apace100.origins.registry.ModRegistries)2 io.github.apace100.origins.util (io.github.apace100.origins.util)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2