From e9d6a8aa983ac8e3eca7984a774af592b59cc33d Mon Sep 17 00:00:00 2001 From: hackthetime Date: Mon, 16 Oct 2023 10:37:12 +0200 Subject: added meme actionbar normal chat switcher. --- .../java/de/hype/bbsentials/forge/ForgeChat.java | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'forge') diff --git a/forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java b/forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java index f84d760..7764d7b 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java @@ -2,9 +2,11 @@ package de.hype.bbsentials.forge; import de.hype.bbsentials.common.chat.Chat; import de.hype.bbsentials.common.chat.Message; +import de.hype.bbsentials.common.client.BBsentials; import de.hype.bbsentials.common.mclibraries.MCChat; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.util.ChatStyle; import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.common.MinecraftForge; @@ -26,10 +28,11 @@ public class ForgeChat implements MCChat { if (!(event.type == 2)) { //2 means action bar // Chat.sendPrivateMessageToSelfDebug(String.valueOf(((int) event.type))); - Message newMessage = chat.onEvent(new Message(IChatComponent.Serializer.componentToJson(event.message), event.message.getUnformattedText())); - if (!newMessage.equals(event.message)) { + Message message = new Message(IChatComponent.Serializer.componentToJson(event.message), event.message.getUnformattedText()); + Message newMessage = chat.onEvent(message); + if (!newMessage.equals(message)) { event.setCanceled(true); - Chat.sendPrivateMessageToSelfText(newMessage); + sendClientSideMessage(newMessage); } } } @@ -43,7 +46,31 @@ public class ForgeChat implements MCChat { } } + + public void sendClientSideMessage(Message message, boolean actionbar) { + if (BBsentials.config.swapActionBarChat && !BBsentials.config.swapOnlyNormal) { + actionbar = !actionbar; + } + if (actionbar) { + showActionBar(message); + } + else { + sendClientSideMessage(message); + } + } + public void sendChatMessage(String message) { Minecraft.getMinecraft().thePlayer.sendChatMessage(message); } + + public void showActionBar(Message message) { + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + if (player != null) { + String json = message.getJson(); + IChatComponent text = IChatComponent.Serializer.jsonToComponent(json); + // Display the text in the action bar + Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(text); + } + } + } -- cgit