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.