Jump to content

rexlz

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by rexlz

  1. 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.
  2. 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.
  3. 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?
×
×
  • Create New...

Important Information

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