Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.