XeliteXirish Posted September 15, 2015 Posted September 15, 2015 I know this is a silly question to ask but is there a way to get the chat right after the players name? I need to check if the players name is in chat and it keeps firing when that user sends a message. Its a client ONLY mod so I cant use any server methods. Also, is there a way to play a sound that overrides the minecraft sound settings and plays even if sound is turned off? Thanks, ~Shaun O'Neill Quote View my website at -> http://www.xelitexirish.com/ You can nearly always contact me on my twitter (XeliteXirish)
XeliteXirish Posted September 15, 2015 Author Posted September 15, 2015 Scratch the top one off the list, sorry I managed to figure out how to do it. Just need a way to play a sound overriding the sound settings? Quote View my website at -> http://www.xelitexirish.com/ You can nearly always contact me on my twitter (XeliteXirish)
Failender Posted September 15, 2015 Posted September 15, 2015 how about u tell us which version u are in? in 1.7 there is PlaySoundEvent Quote
XeliteXirish Posted September 15, 2015 Author Posted September 15, 2015 how about u tell us which version u are in? in 1.7 there is PlaySoundEvent Sorry forgot to mention that haha, its Minecraft 1.8 with newest forge version. Quote View my website at -> http://www.xelitexirish.com/ You can nearly always contact me on my twitter (XeliteXirish)
TrashCaster Posted September 16, 2015 Posted September 16, 2015 I know you may already have the first one solved, but in case others don't know, and would like to know, you can subscribe to the ClientChatReceivedEvent and use regex to separate the player name from the chat. try { if (event.type == 0) { UUID player = null; Pattern p = Pattern.compile("\\<(.*?)\\>"); Matcher m = p.matcher(event.message.getUnformattedText()); while (m.find()) { String s = m.group(1); for (EntityPlayer ep:(List<EntityPlayer>)Minecraft.getMinecraft().theWorld.playerEntities) { if (ep.getName().equals(s)) { player = ep.getUniqueID(); break; } } } if (player != null && event.message.getFormattedText() != null) { String chat = event.message.getFormattedText().replaceFirst("\\<(.*?)\\> ", ""); } } } catch (Exception e) { e.printStackTrace(); } Quote
XeliteXirish Posted September 16, 2015 Author Posted September 16, 2015 I know you may already have the first one solved, but in case others don't know, and would like to know, you can subscribe to the ClientChatReceivedEvent and use regex to separate the player name from the chat. try { if (event.type == 0) { UUID player = null; Pattern p = Pattern.compile("\\<(.*?)\\>"); Matcher m = p.matcher(event.message.getUnformattedText()); while (m.find()) { String s = m.group(1); for (EntityPlayer ep:(List<EntityPlayer>)Minecraft.getMinecraft().theWorld.playerEntities) { if (ep.getName().equals(s)) { player = ep.getUniqueID(); break; } } } if (player != null && event.message.getFormattedText() != null) { String chat = event.message.getFormattedText().replaceFirst("\\<(.*?)\\> ", ""); } } } catch (Exception e) { e.printStackTrace(); } Just out of curiosity, can you not just split the chat by every space and just check everything after the first word which is always the player name? Thats what I did and it seems to be okay. Quote View my website at -> http://www.xelitexirish.com/ You can nearly always contact me on my twitter (XeliteXirish)
Recommended Posts
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.