Jump to content

[1.9] Sounds now invoked from client side?


Purplicious_Cow

Recommended Posts

I've been messing around with sounds today, upgrading one of my mods from 1.8.9 mod to 1.9. I managed to finally get the sounds registered correctly, and there were no errors in the console, but the sounds were not playing.

 

Then, on a whim, I decided to switch the new PlaySound to run on the client also, instead of just the server (literally, I just removed !worldObj.isRemote from the conditional), and voila, the sound played. It has always been counterintuitive to play the sound on the server, but it has been this way since 1.6.4.

 

The problem is, my code does a bunch of things on the server side, which is also where I play the sound, and now I will need to rewrite a lot of code to get the sounds playing correctly (that, or use packets).

 

Before I rewrite everything, can someone confirm my discovery, that sounds will not play if invoked from the Server anymore?

 

PC

Link to comment
Share on other sites

I've been messing around with sounds today, upgrading one of my mods from 1.8.9 mod to 1.9. I managed to finally get the sounds registered correctly, and there were no errors in the console, but the sounds were not playing.

 

Then, on a whim, I decided to switch the new PlaySound to run on the client also, instead of just the server (literally, I just removed !worldObj.isRemote from the conditional), and voila, the sound played. It has always been counterintuitive to play the sound on the server, but it has been this way since 1.6.4.

 

The problem is, my code does a bunch of things on the server side, which is also where I play the sound, and now I will need to rewrite a lot of code to get the sounds playing correctly (that, or use packets).

 

Before I rewrite everything, can someone confirm my discovery, that sounds will not play if invoked from the Server anymore?

 

PC

Link to comment
Share on other sites

Sounds changed in 1.9, and did not work in earlest Forge builds. Search for previous discussion, and make sure you get a relatively recent Forge build that will let you customize sound (see change log).

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.

Link to comment
Share on other sites

Sounds changed in 1.9, and did not work in earlest Forge builds. Search for previous discussion, and make sure you get a relatively recent Forge build that will let you customize sound (see change log).

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.

Link to comment
Share on other sites

As mentioned, sounds worked, but only if invoked client side...

 

I'll try updating and see if that does anything, for the record, using 1.9-12.16.0.1865. It's an earlier version, from 15 April. Will report back.

 

Edit: Updated to 1.9-12.16.1.1934, but it didn't change the result. Still need to call from the non-server side to get sound to work.

Link to comment
Share on other sites

As mentioned, sounds worked, but only if invoked client side...

 

I'll try updating and see if that does anything, for the record, using 1.9-12.16.0.1865. It's an earlier version, from 15 April. Will report back.

 

Edit: Updated to 1.9-12.16.1.1934, but it didn't change the result. Still need to call from the non-server side to get sound to work.

Link to comment
Share on other sites

Old code, used in 1.8.9 (does not work in 1.9)

 

if(!worldObj.isRemote && (itemstack.getItemDamage() < 3 || entityplayer.capabilities.isCreativeMode)) {
        worldObj.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, ModSoundEvents.black_hole, SoundCategory.NEUTRAL, 1.0F, 1.0F);
}

 

 

New code, used in 1.9 (only way I can get the sound to play is to call it from client side as well)

if((itemstack.getItemDamage() < 3 || entityplayer.capabilities.isCreativeMode)) {
worldObj.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, ModSoundEvents.black_hole, SoundCategory.NEUTRAL, 1.0F, 1.0F);
}

 

 

The same applies to vanilla sounds if I try to use playSound.

Link to comment
Share on other sites

Old code, used in 1.8.9 (does not work in 1.9)

 

if(!worldObj.isRemote && (itemstack.getItemDamage() < 3 || entityplayer.capabilities.isCreativeMode)) {
        worldObj.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, ModSoundEvents.black_hole, SoundCategory.NEUTRAL, 1.0F, 1.0F);
}

 

 

New code, used in 1.9 (only way I can get the sound to play is to call it from client side as well)

if((itemstack.getItemDamage() < 3 || entityplayer.capabilities.isCreativeMode)) {
worldObj.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, ModSoundEvents.black_hole, SoundCategory.NEUTRAL, 1.0F, 1.0F);
}

 

 

The same applies to vanilla sounds if I try to use playSound.

Link to comment
Share on other sites

At least as far as 1.8.9, playSound was like a client-side renderer for sound (and I didn't know it would send packets when called server-side -- maybe that's new?).

 

PlaySoundEffect was the method to call server-side when you had made a decision that you wanted communicated to all world accesses within earshot.

 

I need to pick a 1.9.x Forge build and upgrade my mods so I can see what's been done to what I thought I knew  :o

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.

Link to comment
Share on other sites

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.