net.minecraft.network.play.client.C01PacketChatMessage Java Examples

The following examples show how to use net.minecraft.network.play.client.C01PacketChatMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ForceUnicodeChat.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@EventTarget
public void onPacket(final PacketEvent event) {
    if(event.getPacket() instanceof C01PacketChatMessage) {
        final C01PacketChatMessage chatMessage = (C01PacketChatMessage) event.getPacket();

        final String message = chatMessage.getMessage();
        final StringBuilder stringBuilder = new StringBuilder();

        for(char c : message.toCharArray())
            if(c >= 33 && c <= 128)
                stringBuilder.append(Character.toChars(c + 65248));
            else
                stringBuilder.append(c);

        chatMessage.message = stringBuilder.toString();
    }
}
 
Example #2
Source File: AtAllProvider.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@EventTarget
public void onPacket(final PacketEvent event) {
    if(event.getPacket() instanceof C01PacketChatMessage) {
        final C01PacketChatMessage packetChatMessage = (C01PacketChatMessage) event.getPacket();
        final String message = packetChatMessage.getMessage();

        if(message.contains("@a")) {
            synchronized(sendQueue) {
                for(final NetworkPlayerInfo playerInfo : mc.getNetHandler().getPlayerInfoMap()) {
                    final String playerName = playerInfo.getGameProfile().getName();

                    if(playerName.equals(mc.thePlayer.getName()))
                        continue;

                    sendQueue.add(message.replace("@a", playerName));
                }

                if(retryValue.get()) {
                    synchronized(retryQueue) {
                        retryQueue.clear();
                        retryQueue.addAll(Arrays.asList(sendQueue.toArray(new String[0])));
                    }
                }
            }

            event.cancelEvent();
        }
    }
}
 
Example #3
Source File: ChatUtil.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Send a message using the C01PacketChatMessage
 *
 * @param msg a string that the user inputs
 */
public static void sendMessage(String msg) {
    final C01PacketChatMessage packet = new C01PacketChatMessage(msg);
    ((MixinC01PacketChatMessage) packet).setMessage(msg);
    Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(packet);
}
 
Example #4
Source File: FakeNetServerHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void processChatMessage(C01PacketChatMessage p_147354_1_) {
}