Posted April 23, 20178 yr 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 April 23, 20178 yr by creepersgalore Wrong Code
April 23, 20178 yr Author 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 April 23, 20178 yr 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.