Jump to content

[SOLVED] [1.15.2] Help with playing SoundEvents


Novârch

Recommended Posts

I'm having problems with playing my custom SoundEvents, I've tried every version of the playSound method and tried using world.isRemote, but it still won't play. The sound is valid, the sounds.json is valid and the sound plays fine when using the playsound command ingame, what am I missing here?

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

Just now, diesieben07 said:

Show your code.

this.world.playSound(this.getMaster(), new BlockPos(this.getMaster().getPosX(), this.getMaster().getPosY(), this.getMaster().getPosZ()), this.getSpawnSound(), this.getSoundCategory(), 1.0f, 1.0f);

getMaster returns the player, it works fine so it's not the issue, getSpawnSound returns the custom SoundEvent.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

24 minutes ago, diesieben07 said:

The way you are using this method (with a non-null player) you must call it on both client and server, with the same player.

Whats the best way to do this? DistExecutor, OnlyIn or World#isRemote?

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

 

I have no idea where you are trying to play this sound from.

From a packet.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

On 4/25/2020 at 6:48 PM, diesieben07 said:

Server to client? Client to server? When is this packet sent?

 

Can you please just explain the details so we don't have to go around in circles for 20 posts? Thank you.

Here's the class on GitHub: https://github.com/Novarch129/JoJo-s-Blocky-Adventure/blob/9cd711da2a15ab17ffcb085798f211284f3fbf3f/src/main/java/com/novarch/jojomod/network/message/SyncStandSummonButton.java.

It's syncing a KeyBind to the server, so it's client to server.

Edited by Novârch

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

39 minutes ago, diesieben07 said:

Then you must pass null as the player for it to play it to all players in range.

Still not working, exact code is:

this.world.playSound(null, new BlockPos(this.getMaster().getPosX(), this.getMaster().getPosY(), this.getMaster().getPosZ()), this.getSpawnSound(), this.getSoundCategory(), 1.0f, 1.0f)

 

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

9 hours ago, diesieben07 said:

Is the method called?

It is, all the code in the message works.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

Still haven't fixed this, the code used to work perfectly back in 1.12, has something about the method changed?

 

*Edit: For some reason switching to deferred registers made it work.

Edited by Novârch

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

  • Novârch changed the title to [SOLVED] [1.15.2] Help with playing SoundEvents

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.



×
×
  • Create New...

Important Information

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