Say for whatever reason I want to play a cat sound effect just to the client, how would I do that? I've seen
PositionedSoundRecord var13 = new PositionedSoundRecord(new ResourceLocation("name"), 1, 1, x, y, z);
in other projects, but I don't know what the name is for a cat sound and I'd also like it to not be based off of position.
I got the idea for it when I had Minecraft minimized and people wanted me, but I didn't know because I couldn't see it. After that I decided to make a simple mod for myself that sends a notification whenever someone says something in chat. The reason I called it chat notifier was because it did exactly that, notify me of chat. Your mod seems a little different to mine though because mine will send notifications (using system commands) when there is any message at all (which I plan on changing)
I made a mod (for personal use) that is supposed to create a notification when someone says something in a chat.
This is my code:
ChatNotifier.java:
package com.notifier.chatnotifier;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@Mod(modid = ChatNotifier.MODID, version = ChatNotifier.VERSION)
public class ChatNotifier
{
public static final String MODID = "Chat Notifier";
public static final String VERSION = "1.0";
ChatEventHandler handler = new ChatEventHandler();
@EventHandler
public void preinit(FMLPreInitializationEvent event)
{
FMLCommonHandler.instance().bus().register(handler);
MinecraftForge.EVENT_BUS.register(handler);
}
}
ChatEventHandler.java:
package com.notifier.chatnotifier;
import java.io.IOException;
import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class ChatEventHandler
{
@SubscribeEvent
public void checkNormalChat(ServerChatEvent event)
{
try
{
Runtime.getRuntime().exec("notify-send " + event.username + " \"" + event.message + "\""); //Creates a notification (Linux only)
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
The mod works perfectly in singleplayer, but obviously the point of the mod is to create notifications in multiplayer. I've tested it on a completely vanilla server, and also in a craftbukkit server, and neither work.