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

Hey everyone.

 

I'm trying to grasp minecraft/forge modding and it's been going fine so far. I'm creating a nuclear warning siren for my ic2 nuclear power plant I'm building. I've created a textured siren block so far and when it gets powered by redstone it emits light (I wanted it to be a red warning light, but apparently that's not natively supported by minecraft.. any tips there are welcome) and it plays a siren sound. 

I'm playing the sound with

 

world.playSoundEffect((double)x, (double)y, (double)z, Sirens.MODID + ":siren.nuclear", 5f, 0.5f);

 

And it works beautifully, but the problem is that the siren sound is ~2 minutes long. I want the block to behave exactly like a Jukebox block does when it's broken. That is, when I remove the redstone power from the siren block, I want it to stop (preferably to ease into a "powering down" sound). I've been looking at the Jukebox block and how it handles the right click from a player, but it seems to me that it's using some code specifically created for records.

 

So what I am hoping someone knows how to do is, stop a sound as soon as it's playing (and I don't want to stop all of them, so I can't just somehow tell the sound manager to stop all sounds called "siren.nuclearwarning", incase other sirens are still running).

 

The next phase I would like to go to after getting that to work would then be to have "Siren starting", "Siren on" and "Siren stopping" sounds, so that "Siren starting" is the first sound played, then "Siren on" on repeat until the block it stopped with the "Siren stopping" sound playing at the end. But I'd say that's a 'nice to have' feature if I get the other thing working.

 

The whole source code is available on Github right here. The exact line where I'm playing the sound is here

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.