Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • ServerChatEvent doesn't work on my server
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
rexlz

ServerChatEvent doesn't work on my server

By rexlz, February 23, 2020 in Modder Support

  • Start new topic

Recommended Posts

rexlz    0

rexlz

rexlz    0

  • Tree Puncher
  • rexlz
  • Members
  • 0
  • 3 posts
Posted February 23, 2020 (edited)

I've started modding with forge recently, and I want to create a mod to play a custom sound upon player chatting on my server.

 

I used ServerChatEvent as the event to trigger the sound, however that event doesn't really fire when I chat on my server as a client(no sound heard, no debug info). Other events like ItemCraftedEvent fires normally on my server.

I also tried my mod in singleplayer, ServerChatEvent works properly there(when I chat I could hear the sound correctly).

 

So, what could be the problem?

Edited February 24, 2020 by rexlz

Share this post


Link to post
Share on other sites

IAmAFrenchFry    2

IAmAFrenchFry

IAmAFrenchFry    2

  • Tree Puncher
  • IAmAFrenchFry
  • Members
  • 2
  • 27 posts
Posted February 24, 2020 (edited)

I’m not 100% sure if this is better or what you want, but I think it would be a better route to do this with a plugin, and players can run a command if they want to hear the sound when chatting. If you do this, I would suggest checking out SpigotMC.org.

 

Hope this helps!

Edited February 24, 2020 by IAmAFrenchFry

Share this post


Link to post
Share on other sites

rexlz    0

rexlz

rexlz    0

  • Tree Puncher
  • rexlz
  • Members
  • 0
  • 3 posts
Posted February 24, 2020
3 hours ago, IAmAFrenchFry said:

I’m not 100% sure if this is better or what you want, but I think it would be a better route to do this with a plugin, and players can run a command if they want to hear the sound when chatting. If you do this, I would suggest checking out SpigotMC.org.

 

Hope this helps!

Thanks man, I'll consider that. But I'd still like to figure out a way to do it in a forge mod, as I'm also learning to mod. In fact it's not only the sound won't play, but the event itself not fires when I connect to my server as a client, where I'd try adding some other functions later on. The event does fire and function normally when I play singleplayer.

Share this post


Link to post
Share on other sites

diesieben07    7597

diesieben07

diesieben07    7597

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7597
  • 55122 posts
Posted February 24, 2020

ServerChatEvent is a server-side event. Did you install the mod on the server?

Show your code.

Share this post


Link to post
Share on other sites

rexlz    0

rexlz

rexlz    0

  • Tree Puncher
  • rexlz
  • Members
  • 0
  • 3 posts
Posted February 25, 2020 (edited)
On 2/24/2020 at 4:18 PM, diesieben07 said:

ServerChatEvent is a server-side event. Did you install the mod on the server?

Show your code.

Yeah...I'm trying to understand the concept of two sides in Minecraft. As I see it, ServerChatEvent should fire when a player chat on server.

The code below is event loader.

public class EventLoader {    
    public EventLoader()
    {
        MinecraftForge.EVENT_BUS.register(this);
    }
	
    ResourceLocation location = new ResourceLocation("mytestmod", "mytestmod.test");
    SoundEvent se = new SoundEvent(location);

    @SubscribeEvent
    public void onPlayerChat(ServerChatEvent event)
    {
        event.getPlayer().sendMessage(new TextComponentString("fired!"));
        System.out.println("fired!");
        event.getPlayer().world.playSound(null, event.getPlayer().getPosition(),se, SoundCategory.PLAYERS, 1.0F, 1.0F);
    }
}

 

And I initiate it in the main class.

public void preInit(FMLPreInitializationEvent event)
{
    new EventLoader();
}

 

The result when I test it on my remote server was nothing happen.

Edited February 25, 2020 by rexlz

Share this post


Link to post
Share on other sites

diesieben07    7597

diesieben07

diesieben07    7597

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7597
  • 55122 posts
Posted February 25, 2020

1.12 is no longer supported on this forum.

Please update to a modern version of Minecraft to receive support.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Woodside
      [1.15.2]ServerWorld.spawnParticle excluding specific player

      By Woodside · Posted 1 hour ago

      I have an item which I want to spawn a specific particle for the user, and then a separate particle for other players. Spawning one exclusively for the player using is easy enough, but spawning a particle server side has no way to exclude a specific player. Is there a way to do this without reflection?
    • DaemonUmbra
      I just started modding minecraft and I thought i had finished modding it but Titanium mod isn't loading properly. Can someone help me fix this?

      By DaemonUmbra · Posted 1 hour ago

      Please read the error...
    • DaemonUmbra
      HELP! WORLD WONT WORK

      By DaemonUmbra · Posted 2 hours ago

      I told you to delete a file in the save, not the save itself Go into the save and delete forge-server.toml from serverconfig
    • Gubipe
      Minecraft.getMinecraft().thePlayer.swingItem(); wont attack

      By Gubipe · Posted 3 hours ago

      I am making the two mods with the same functionality. One is 1.16.4 and the other is 1.8.9. The current one is 1.8.9 and then I shall try to port it over to 1.16.4
    • poopoodice
      Minecraft.getMinecraft().thePlayer.swingItem(); wont attack

      By poopoodice · Posted 3 hours ago

      It's for animation only. Btw what version are you using?
  • Topics

    • Woodside
      0
      [1.15.2]ServerWorld.spawnParticle excluding specific player

      By Woodside
      Started 1 hour ago

    • TheDonkey_King
      5
      I just started modding minecraft and I thought i had finished modding it but Titanium mod isn't loading properly. Can someone help me fix this?

      By TheDonkey_King
      Started 9 hours ago

    • BIGDog8808
      11
      HELP! WORLD WONT WORK

      By BIGDog8808
      Started 10 hours ago

    • Gubipe
      2
      Minecraft.getMinecraft().thePlayer.swingItem(); wont attack

      By Gubipe
      Started 5 hours ago

    • mightymoy
      8
      Cant craft items in modded server

      By mightymoy
      Started Yesterday at 03:00 AM

  • Who's Online (See full list)

    • LK1905
    • BliX5
    • Choonster
    • LexManos
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • ServerChatEvent doesn't work on my server
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community