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

Hello, i created radio for my mod and i want to have music playing all the time. I created class extended from MovingSound(As well as MovingSoundMinecart):

public class RepeatSound extends MovingSound
{
    public RepeatSound(TileRadio radio)
    {
        super(new ResourceLocation("modid", "radio_sound_1"));
        this.repeat = true;
        this.volume = 1.0F;
        this.xPosF = radio.xCoord;
        this.yPosF = radio.yCoord;
        this.zPosF = radio.zCoord;
    }

    @Override
    public void update() {}
}

In sounds:

{
	"radio_sound_1": {
		"category": "music",
		"sounds": [
			{
				"name": "modid:radio_sound_1",
				"stream": true
			}
		]
	}
}

In TileRadio

@Override
    public void updateEntity()
    {
        if (play)
        {
            play = false;
            Minecraft.getMinecraft().getSoundHandler().playSound(new RepeatSound(this));
        }
    }

And it's not working, there is a small period of 1 second, and sometimes does not work. How to fix it? The fact that I used the same code on 1.7.10 and 1.11.2, and still all the same.

Minecraft sound handling can be confusing because  decision code for the server and "rendering" code for the client are partly mixed together with  similarly named methods. Take some time to trace both the execution and data flows with an eye toward logical client-server separation.

 

Then look for a client-side vanilla classes with "continuous" in their names (I hope they haven't changed too much since I used them in 1.10). Finally, look up other threads about changes to Minecraft sounds in 1.12. I think there's some info on sound in 1.12 in the Forge docs area too.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

  • Author
4 minutes ago, jeffryfisher said:

Minecraft sound handling can be confusing because  decision code for the server and "rendering" code for the client are partly mixed together with  similarly named methods. Take some time to trace both the execution and data flows with an eye toward logical client-server separation.

 

Then look for a client-side vanilla classes with "continuous" in their names (I hope they haven't changed too much since I used them in 1.10). Finally, look up other threads about changes to Minecraft sounds in 1.12. I think there's some info on sound in 1.12 in the Forge docs area too.

Currently working with 1.11.2 :) I found a mod Siren Mod, it does what I need, and most interestingly, the code is identical to mine, it's very strange:\

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.