Jump to content

Recommended Posts

Posted

Hi guys!

I have a problem... i have created a Entity wich is my "Camera" for a small nimation flight... but now my problem is, that the sound is not centered to the view, it is centered to the the player! I mean... I here not the 3D sound sin the animation enviroment, i hear the sounds around the player!

How can i fix this? Must i execute something every tick or handle an event?

Posted
24 minutes ago, jabelar said:

What method are you calling to play the sound? You should be calling the playSound() method from the entity itself. That should make the sound come from the entity. 

He's not playing sounds, he's talking about every sound affect being picked up by the player not the remote camera perspective.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
1 minute ago, Draco18s said:

He's not playing sounds, he's talking about every sound affect being picked up by the player not the remote camera perspective.

Ahh, I see. There are many sounds that are localized and those should still work properly I think -- but he's saying that music and other unlocalized sounds are acting localized around the player? That doesn't seem right -- looking at how music and such is played in the code I don't see where it would matter where your view camera was (although I admit I didn't spend a lot of time looking). At least there are certainly sounds that are meant to be played with no attenuation factor...

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
1 hour ago, jabelar said:

Ahh, I see. There are many sounds that are localized and those should still work properly I think -- but he's saying that music and other unlocalized sounds are acting localized around the player? That doesn't seem right -- looking at how music and such is played in the code I don't see where it would matter where your view camera was (although I admit I didn't spend a lot of time looking). At least there are certainly sounds that are meant to be played with no attenuation factor...

Other way around. The sounds that are localized are being played at the volume that is local to the player not local to the camera.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

Okay, I get what you mean. He's hearing things as if he's the player even though he should not because the camera view is some distance away.

 

That might be really tough to fix directly. You'd have to replicate the attenuation code I guess based on the camera location instead of the player. It seems like you'd have to find a way to fake it out.

 

It might be fairly easy to make the sounds that are sent to the client attenuate properly. I would probably use reflection to change the Minecraft@mcSoundHandler field to my own custom SoundHandler instance and I would adjust all sound attenuation by the distance of the camera from the player.

 

HOWEVER, client side adjustments would only affect sounds the server chooses to send which I think are those which the player is supposed to hear. In other words, the server would not know to send sounds that the camera is close to. That is because the ServerWorldEventHandler#playSoundToAllNearExcept() method calls PlayerList#sentToAllNearExcept which sends sound play packets only to those in a radius set by the expression volume > 1.0F ? (double)(16.0F * volume) : 16.0D

 

So I think for sounds to really work properly, the camera has to be considered a player (EnittyPlayerMP) that is in the PlayerList. I was digging around it the MinecraftServer#setPlayerList() method is already public scope so you could set it to a custom extended version of DedicatedPlayerList or IntegratedPlayerList (need to check which mode is executing). In your custom class you could override the sentToAllNearExcept() method to also consider sending a packet to a client that has this camera enabled. Of course you'd need to have the client send info back to the server to let it know the camera position (and this also means it cannot just be a client-side mod).

 

There is also the FakePlayer class that maybe could be used for such a purpose, although I've never used that class and can't find a lot of good information on it. But it is an extension of EntityPlayerMP but I don't know if it is associated with clients and would send packets.

 

Anyway, I think it is possible and probably are several different approaches but may require a bit of clever coding to find the best way to intercept the determination of which sounds should be sent to the client. @Draco18sI think you know something about using the FakePlayer so you could better comment on whether it could be used for this purpose.

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
7 hours ago, jabelar said:

 @Draco18sI think you know something about using the FakePlayer so you could better comment on whether it could be used for this purpose.

Nope, just in understanding the problem.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.