Jump to content

Recommended Posts

Posted (edited)

I need help with an event handler. Before you ask, my problem is not having an unregistered event handler. Here is the code:

 

Spoiler

@SubscribeEvent
    public static void onTick(TickEvent event) {
        
        if (Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.world.provider instanceof GVIWorldProvider && (Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(PositionedSoundRecord.getMusicRecord(SoundEvents.MUSIC_CREATIVE)) || Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(PositionedSoundRecord.getMusicRecord(SoundEvents.MUSIC_GAME)))) {
            
            Minecraft.getMinecraft().getSoundHandler().stopSound(PositionedSoundRecord.getMusicRecord(SoundEvents.MUSIC_CREATIVE));
            Minecraft.getMinecraft().getSoundHandler().stopSound(PositionedSoundRecord.getMusicRecord(SoundEvents.MUSIC_GAME));
            
            EntityPlayerSP player = Minecraft.getMinecraft().player;
            
            player.world.playSound(player.posX, player.posY, player.posZ, GVISoundManager.gvi_music, SoundCategory.MUSIC, 100000.0F, 1.0F, false);
            
        }
        
    }

 

My aim is to play my custom music when Minecraft says "Play ambient music", then stop that music from playing and replace it with my own music.

Edited by creepersgalore
Wrong Code
Posted (edited)

I tried that.

 

Spoiler

@SubscribeEvent
    public static void onPlaySound(PlaySoundEvent event) {
        
        if (Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.world.provider instanceof GVIWorldProvider && (event.getSound() == PositionedSoundRecord.getMusicRecord(SoundEvents.MUSIC_CREATIVE) || event.getSound == PositionedSoundRecord.getMusicRecord(SoundEvents.MUSIC_GAME))) {
            
            event.setCanceled(true);
            
            EntityPlayerSP player = Minecraft.getMinecraft().player;
            
            player.world.playSound(player.posX, player.posY, player.posZ, GVISoundManager.gvi_music, SoundCategory.MUSIC, 100000.0F, 1.0F, false);
            
        }
        
    }

 

Didn't work.

Edited by creepersgalore
Wrong Spelling

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.