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

How can i make my music play at the background, like the vanilla soundtrack? I want to not just replace the vanilla soundtrack with my own, as in a resourcepack, but add new tracks to it

You could register your own SoundEvents as detailed here, and then for example play those SoundEvents (your music) in a tick event at random.

  • Author
1 hour ago, vemerion said:

You could register your own SoundEvents as detailed here, and then for example play those SoundEvents (your music) in a tick event at random.

I have already registered all the sound events, but i have never worked with tick events. Could you explain me how it works or give an example code?

39 minutes ago, kemika1girl said:

example code

This would play your music once every 1000 ticks (every 50 seconds):

private static int musicTimer = 1000;
	
	@SubscribeEvent
	public static void onTick(ClientTickEvent event) {
		if (event.phase == Phase.END && event.side == LogicalSide.CLIENT) {
			if (musicTimer-- <= 0 && Minecraft.getInstance() != null && Minecraft.getInstance().player != null) {
				musicTimer = 1000;
				Minecraft.getInstance().player.playSound(YOUR MUSIC HERE, 2f, 1f);
				Minecraft.getInstance().getMusicTicker().stop();
			}
		}
	}

 

Although I think the vanilla Minecraft music could potentially start while your music is playing, so you would have to handle that also.

  • Author

ah, thanks!

36 minutes ago, vemerion said:

Although I think the vanilla Minecraft music could potentially start

yes, vanilla music can start playing, but i will try to make vanilla music stop playing if mine is already playing

  • Author

@vemerion strange, but seems like nothing happens after i added the code.. did i do something wrong?

@Mod.EventBusSubscriber(modid = Atmospheric.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
@Mod("atmospheric")
public class Atmospheric {
    public static final String MOD_ID = "atmospheric";

    Minecraft minecraft = Minecraft.getInstance();
    private static int musicTimer = 10;

    @SubscribeEvent
    public static void onTick(TickEvent.ClientTickEvent event) {
        if (event.phase == TickEvent.Phase.END && event.side == LogicalSide.CLIENT) {
            if (musicTimer-- <= 0 && Minecraft.getInstance() != null && Minecraft.getInstance().player != null) {
                musicTimer = 10;
                Minecraft.getInstance().player.playSound(AtmosphericSoundEvents.SOLACE_1, 2f, 1f);
                Minecraft.getInstance().getMusicTicker().stop();
            }
        }
    }
}


 

11 minutes ago, kemika1girl said:

strange, but seems like nothing happens after i added the code.. did i do something wrong?

ClientTickEvent is fired on the Forge bus, try changing 

bus = Mod.EventBusSubscriber.Bus.MOD

to

bus = Mod.EventBusSubscriber.Bus.FORGE

 

  • Author
4 minutes ago, vemerion said:

ClientTickEvent is fired on the Forge bus, try changing 


bus = Mod.EventBusSubscriber.Bus.MOD

to


bus = Mod.EventBusSubscriber.Bus.FORGE

 

really, now it works 
thanks you very much!

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.