Java Code Examples for net.minecraft.client.audio.SoundHandler#playSound()

The following examples show how to use net.minecraft.client.audio.SoundHandler#playSound() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HypixelDetector.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@InvokeEvent
public void join(JoinHypixelEvent event) {
    if (Settings.HYPIXEL_ZOO) {
        Hyperium.INSTANCE.getNotification().display("Welcome to the Hypixel Zoo.", "Click to visit https://hypixel.net/", 5f,
            null, () -> {
                try {
                    Desktop.getDesktop().browse(new URI("https://hypixel.net/"));
                } catch (IOException | URISyntaxException e) {
                    e.printStackTrace();
                }
            }, new Color(200, 150, 50));

        SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
        if (soundHandler == null || Minecraft.getMinecraft().theWorld == null) return;
        soundHandler.playSound(PositionedSoundRecord.create(new ResourceLocation("zoo"),
            (float) Minecraft.getMinecraft().thePlayer.posX, (float) Minecraft.getMinecraft().thePlayer.posY, (float) Minecraft.getMinecraft().thePlayer.posZ));
    }
}
 
Example 2
Source File: DMChatHandler.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean chatReceived(IChatComponent component, String text) {
    if (!Settings.PING_ON_DM)
        return false;

    Matcher matcher = regexPatterns.get(ChatRegexType.PRIVATE_MESSAGE_FROM).matcher(text);
    if (matcher.matches()) {
        SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
        if (soundHandler != null && Minecraft.getMinecraft().theWorld != null) {
            soundHandler.playSound(PositionedSoundRecord.create(new ResourceLocation("note.pling"),
                (float) Minecraft.getMinecraft().thePlayer.posX, (float) Minecraft.getMinecraft().thePlayer.posY, (float) Minecraft.getMinecraft().thePlayer.posZ));
        }
    }

    return false;
}
 
Example 3
Source File: ClientProxy.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void playSound(int soundId, float pitch, float volume, boolean repeat, boolean stop, float x, float y, float z)
{
    SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
    SoundEvent sound = SoundEvent.REGISTRY.getObjectById(soundId);

    if (sound != null)
    {
        if (stop)
        {
            soundHandler.stop(sound.getRegistryName().toString(), null);
        }
        else
        {
            PositionedSoundRecord positionedSound = new PositionedSoundRecord(sound.getSoundName(),
                    SoundCategory.RECORDS, volume, pitch, repeat, 0, AttenuationType.LINEAR, x, y, z);
            soundHandler.playSound(positionedSound);
        }
    }
}
 
Example 4
Source File: GuiKnappingButton.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void playPressSound(SoundHandler paramSoundHandler)
{
	PlayerInfo pi = PlayerManagerTFC.getInstance().getClientPlayer();
	if(pi.specialCraftingType.getItem() == TFCItems.LooseRock)
		paramSoundHandler.playSound(net.minecraft.client.audio.PositionedSoundRecord.getMasterRecord(TFC_Sounds.KNAPPING, 1.0F));
}
 
Example 5
Source File: GuiCustomButton.java    From Custom-Main-Menu with MIT License 5 votes vote down vote up
@Override
public void playPressSound(SoundHandler soundHandlerIn)
{
	if (b.pressSound != null)
	{
		soundHandlerIn.playSound(new PositionedSoundRecord(new ResourceLocation(b.pressSound), SoundCategory.MASTER, 1F, 1F, false, 0, AttenuationType.NONE, 0, 0, 0));
	}
	else
	{
		super.playPressSound(soundHandlerIn);
	}
}