Jump to content

how to play a sound that's heard everywhere, even in other dimensions?


Recommended Posts

i'm trying to make a mod that announces a chosen player's joining to all other players with a sound. i managed to get a custom sound to play upon a player joining, but for some reason the sound can be only heard within maximum 8 blocks of the joining player's joining spot. i tried playing the sound to every single player's client, but for whatever reason the effect hasn't changed. the forge doc for sounds is barely helpful in this regard, so figuring out this issue by myself seems nigh impossible.

two versions of my code, one that plays a sound from the joining player:

    @SubscribeEvent
    public void pickupItem(PlayerLoggedInEvent event) {

        String UUID = configmaker.names.get().toString().replace("[", "").replace("]", "").replace(" ", "");
        String[] toStringArray = UUID.split(",");//get the list and split it in to different uuids

        System.out.println("Player's UUID: " + event.getEntity().getStringUUID().toString());//logs the player's uuid

        for (int i = 0; i < toStringArray.length; i++) {
            if (event.getEntity().getStringUUID().equals(toStringArray[i])) {//"893fe864-7b87-4155-b1de-82a517d0e294" is kuba26038
                    event.getEntity().playSound(ModSounds.THE_SOUND_ITSELF.get(), 1.0F, 1.0F);
        }

    }

and another one that plays a sound for all clients that are currently in-game:

    @SubscribeEvent
    public void pickupItem(PlayerLoggedInEvent event) {

        String UUID = configmaker.names.get().toString().replace("[", "").replace("]", "").replace(" ", "");
        String[] toStringArray = UUID.split(",");//get the list and split it in to different uuids
        MinecraftServer server = ServerLifecycleHooks.getCurrentServer();

        System.out.println("Player's UUID: " + event.getEntity().getStringUUID().toString());//logs the player's uuid

        for (int i = 0; i < toStringArray.length; i++) {
            if (event.getEntity().getStringUUID().equals(toStringArray[i])) {//"893fe864-7b87-4155-b1de-82a517d0e294" is kuba26038
                List<ServerPlayer> players = server.getPlayerList().getPlayers();
                for (ServerPlayer player : players)
                    player.playSound(ModSounds.THE_SOUND_ITSELF.get(), 1.0F, 1.0F);
        }

    }

please tell me what i'm missing, i'm slowly going insane over this. thanks.

Link to comment
Share on other sites

Quote

the forge doc for sounds is barely helpful in this regard

You should be grateful that people document Mojang's code at all.

The main purpose of the forge documentation is to explain what it provides in addition to Mojang's code.

The feature you are using is very much Mojang's code and quite idiosyncratic in its behaviour.

 

Quote

so figuring out this issue by myself seems nigh impossible.

You didn't consider looking at Mojang's code to see how it actually works?

Or using a debugger to see which "if statement" stops the sound from playing?

 

https://forge.gemwire.uk/wiki/Sounds#Player

It won't send the sound from the server to the player making the sound. It assumes the client already played the sound.

You pass a null player directly to Level.playSound() to send it to the player and nearby players.

 

So your first attempt plays the sound to everybody near the joining player, but not to the joining player

The second attempt will be heard by everybody that is near another player.

But people by themselves won't hear it because there is no other player making the sound for them.

 

The example I can think of similar to what you want to do is the use of ClientBoundCustomSoundPacket in the PlaySoundCommand?

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've had this problem for a long while now, and am just now remembering that Forge has a forum site. I feel dumb that I could've had this problem solved sooner. Though it is a problem I've only experienced as of 1.20(to my memory). Everything prior to that version worked fine up until I installed Forge 1.20. Anyway, I've tried some things including trying previous versions and (at the recommendation of others)taking my resource pack off. Paste.ee link lol Running Minecraft version 1.12 is the version of Forge that works without issues. I've deduced that this is because the overlay that loads the game and mods in future versions of Forge is not present, but this still doesn't solve my problem of how to fix the crashing of said future versions, or why it crashes in the first place. Yes, this happens even without mods. I'm not very good at messing with files, so here I am. Hopefully I did this right after looking at the FAQ.
    • it seems i can put back my mods in my mods folder one by one with their dependencies to get the config file, but when i put 2 or more it doesn't create it
    • Call+27732318372 $100‱-Authentic-Love Spells New York-London-Tokyo-Sydney-Toronto Visit website: https://www.strongspellcaster.us.com. For Rebinding Love Spells New York, Best love spells New York, Genuine love spells New York, Attraction love spells New York, Marriage spells New York, Divorce spells New York, Stop Cheating spells New York, Return Ex-Lover New York, Real Love spells New York, Bring back Ex Lover and Psychic Reader in USA. +27732318372 Are you currently seeing someone? Are you feeling that your lover’s love for is slowly diminishing? Are you looking for something that will instantly strengthen your relationship? Have you tried seeking help from various spell casters but failed because they only gave false hope? Are you hoping to win your lost lover back? Is your current relationship giving you so much misery? Do you want the man/girl of your dreams to find you alluring? Then you are at the right place because here you will find exactly what you have been searching for and that is the Return of Your Lost Love My name is Aadila. During the last 30 years, I have helped many people solve their relationship problems and financial difficulties with powerful Egyptian magic spells. All my clients had different problems, wishes, and goals. All situations involved various people, different spirits, and different souls and as the name goes I am truly a Lovespell Expert. Therefore it is very important that I get to know you, and your problem and gain profound insight into your situation. All my spell work is tailored to your specific needs because this is the only way you will receive your results, and your problems will be solved in a timely manner. You contacted me because you have a problem in your life, which you would like to solve through authentic spiritual means. I am here to assist you. While browsing my site, you will get to know me better, and this site will prepare you to make the right decision. website: https://www.strongspellcaster.us.com. Vodoo is an oral tradition practised by extended families that inherit familial spirits, along with the necessary devotional practices, from their elders. In the cities, local hierarchies of priestesses or priests (manbo and oungan), “children of the spirits” (ounsi), and ritual drummers (ountògi) comprise more formal “societies” or “congregations” (sosyete). In these congregations, knowledge is passed on through a ritual of initiation (kanzo) in which the body becomes the site of spiritual transformation. There is some regional difference in ritual practice across Haiti, and branches of the religion include Rada, Daome, Ibo, Nago, Dereal, Manding, Petwo, and Kongo. There is no centralized hierarchy, no single leader, and no official spokesperson, but various groups sometimes attempt to create such official structures. There are also secret societies, called Bizango or Sanpwèl, that perform a religio-juridical function. I have been having lots of questions from clients about our prices, As a voodoo Priest, it’s 100% forbidden to tax anyone for our services (It's a Taboo). We will only accept FREE WILL DONATIONS AFTER YOU HAVE SEEN RESULTS and not forgetting that every ritual has a list of items to use so all customers PROVIDE JUST THEIR ITEMS NEEDED FOR THEIR WORK Depending on their request!
    • Call +27732318372 $100‱ -Lottery Spells USA: Most Powerful Lottery Spells to Win the Mega Millions in New York. Visit website: https://www.strongspellcaster.us.com I'm William Jones  from the United States. I started playing lottery games 4 years ago and I have never won big. I went online to seek help on how I can win big in my lottery games and I saw some nice reviews about Prof Mama Khulusum who has made different people huge winners in their lottery games with her prayers. I gave it a try and I contacted Prof Mama Khulusum who told me how and what to do before I can become a big lotto winner and I accepted. 
    • $100‱+27732318372 NEW YORK-## LOTTERY SPELLS #STAR# LOTTERY SPELLS THAT NEVER MISS IN USA. visit also my website: https://www.strongspellcaster.us.com HOW TO WIN LOTTERY JACKPOT ASK DR MAMA KHULUSUM IN Fiji Island, Malta, Greek Island cruise, Amelia Island properties, Robin Island, Channel Island By a real lottery spell cater prof mama KHULUSUM +27732318372. Who doesn’t want to win the lottery? Chances are that most of us could do with a little
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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