In a tile entity, I need it to play a sound when the player stands on top of the block. I do this by checking for the first player (if any) that is standing on top of the block from within the method. It detects perfectly, and does all the actions that are supposed to occur as a result of standing there, except for playing a sound once the detection occurs, using worldObj.playSound(). I suspect it has to do with the fact that the entire contents of the update method are within an if block that only runs server-side (!worldObj.isRemote). How do I get the world to play the sound from within this code?
Try using World#playSoundEffect, this sends a packet to all clients near the position telling them to play the sound. This doesn't allow for delayed sounds, but sounds are only delayed if the player is >= 100 blocks away from the sound's position anyway.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Try using World#playSoundEffect, this sends a packet to all clients near the position telling them to play the sound. This doesn't allow for delayed sounds, but sounds are only delayed if the player is >= 100 blocks away from the sound's position anyway.
In a tile entity, I need it to play a sound when the player stands on top of the block. I do this by checking for the first player (if any) that is standing on top of the block from within the method. It detects perfectly, and does all the actions that are supposed to occur as a result of standing there, except for playing a sound once the detection occurs, using worldObj.playSound(). I suspect it has to do with the fact that the entire contents of the update method are within an if block that only runs server-side (!worldObj.isRemote). How do I get the world to play the sound from within this code?
Link to TileEntity update code in question
Try using World#playSoundEffect, this sends a packet to all clients near the position telling them to play the sound. This doesn't allow for delayed sounds, but sounds are only delayed if the player is >= 100 blocks away from the sound's position anyway.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Thanks! That worked perfectly.