Search in sources :

Example 16 with SoundEvent

use of net.minecraft.util.SoundEvent in project Railcraft by Railcraft.

the class SoundHelper method playBlockSound.

//TODO: test
public static void playBlockSound(World world, BlockPos pos, SoundEvent sound, SoundCategory category, float volume, float pitch, IBlockState state) {
    if (world != null && sound != null) {
        ResourceLocation soundPath = ReflectionHelper.getPrivateValue(SoundEvent.class, sound, 1);
        if (matchesSoundResource(soundPath, "override")) {
            SoundType blockSound = SoundRegistry.getBlockSound(state, world, pos);
            if (blockSound != null) {
                SoundEvent newSound = matchSoundEvent(soundPath, blockSound);
                playSound(world, null, pos, newSound, category, volume, pitch * blockSound.getPitch());
            }
        }
        playSound(world, null, pos, sound, category, volume, pitch);
    }
}
Also used : SoundType(net.minecraft.block.SoundType) SoundEvent(net.minecraft.util.SoundEvent) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 17 with SoundEvent

use of net.minecraft.util.SoundEvent in project VanillaTeleporter by dyeo.

the class ModSounds method registerSound.

private static SoundEvent registerSound(String name) {
    ResourceLocation location = new ResourceLocation(TeleporterMod.MODID, name);
    SoundEvent event = new SoundEvent(location);
    SoundEvent.REGISTRY.register(size, location, event);
    size++;
    return event;
}
Also used : SoundEvent(net.minecraft.util.SoundEvent) ResourceLocation(net.minecraft.util.ResourceLocation)

Aggregations

SoundEvent (net.minecraft.util.SoundEvent)17 ResourceLocation (net.minecraft.util.ResourceLocation)7 Nonnull (javax.annotation.Nonnull)3 ItemStack (net.minecraft.item.ItemStack)3 SoundType (net.minecraft.block.SoundType)2 IBlockState (net.minecraft.block.state.IBlockState)2 IFluidHandlerItem (net.minecraftforge.fluids.capability.IFluidHandlerItem)2 Block (net.minecraft.block.Block)1 BlockLiquid (net.minecraft.block.BlockLiquid)1 Material (net.minecraft.block.material.Material)1 ISound (net.minecraft.client.audio.ISound)1 PositionedSound (net.minecraft.client.audio.PositionedSound)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 PlaySoundEvent (net.minecraftforge.client.event.sound.PlaySoundEvent)1 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)1 VoidFluidHandler (net.minecraftforge.fluids.capability.templates.VoidFluidHandler)1 BlockLiquidWrapper (net.minecraftforge.fluids.capability.wrappers.BlockLiquidWrapper)1 BlockWrapper (net.minecraftforge.fluids.capability.wrappers.BlockWrapper)1 FluidBlockWrapper (net.minecraftforge.fluids.capability.wrappers.FluidBlockWrapper)1