Posted November 15, 20205 yr Hi Guys ! I'm trying to do some stuff but it seem it doesn't work. I just want to check if a sound is played to prevent the game to play it twice. So... i was telling me there is two ways to do it : 1. put a timer and when it is below zero, the block can play it again when the player go trough it. 2. second option maybe safer, only play it again when the previous sound is over and the player go trough the block. I tried to check the second option that in a method but... it seem that Soundhandler.isPlaying(Isound) doesn't work.... Or maybe i'm missing something very obvious. Be gentle with me, i'm auto learning Java haha ;) private void playSound(IBlockReader world, BlockPos pos, Entity entity) { if(timer <=0) { SoundEvent sound = InitSound.PASSAGE_TOUR.get(); System.out.println("before doing it ? " +Minecraft.getInstance().getSoundHandler().isPlaying( SimpleSound.music(sound))); //((World) world).playSound((PlayerEntity)entity, pos,sound, SoundCategory.BLOCKS, 1F, 1F); entity.playSound(sound, 1.0F, 1.0F); System.out.println("the sound is played ? " +Minecraft.getInstance().getSoundHandler().isPlaying( SimpleSound.music(sound))); timer=30; } } the two output say in the consol that they are false... both. Thank you for reading this and Thank you even more if you help me with this ;)
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.