Jump to content

Recommended Posts

Posted

I use SoundEvent registry sound and set category are music, stream true in .json but why can't play it.

Ummm if possible i don't need remove original backgound music but i want to add for random with original.

Posted (edited)

Now i can play it thank you for reply this post.

How i play it.
 

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void addSound(PlaySoundEvent event)
{
	if(event.getName().equals("music.game") || event.getName().equals("music.creative")) {
			
		Random rand = new Random();
		int n = rand.nextInt(2) + 1;
			
		if(n == 2) {
	    		int m = rand.nextInt(6) + 1;
	    		if(m == 1) {
	    			event.setResultSound(PositionedSoundRecord.getMusicRecord(Register.mo_ce01));
	    		}else if(m == 2) {
	    			event.setResultSound(PositionedSoundRecord.getMusicRecord(Register.mo_ce02));
	    		}else if(m == 3) {
	    			event.setResultSound(PositionedSoundRecord.getMusicRecord(Register.mo_ce03));
	    		}else if(m == 4) {
	    			event.setResultSound(PositionedSoundRecord.getMusicRecord(Register.mo_ce04));
	    		}else if(m == 5) {
	    			event.setResultSound(PositionedSoundRecord.getMusicRecord(Register.mo_ce05));
	    		}else if(m == 6) {
	    			event.setResultSound(PositionedSoundRecord.getMusicRecord(Register.mo_ce06));
	    		}
		}
	}
}

 

Edited by zlappedx3

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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