From 348abd9142f75d9fb723237fdd3cfa3174bbbc21 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Fri, 13 Jan 2023 11:06:54 -0500 Subject: fix chat head crash --- .../cc/woverflow/chatting/mixin/ChatLineMixin.java | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java') diff --git a/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java b/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java index b739284..ab052ae 100644 --- a/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java +++ b/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java @@ -34,26 +34,30 @@ public class ChatLineMixin implements ChatLineHook { private void onInit(int i, IChatComponent iChatComponent, int j, CallbackInfo ci) { chatLines.add(new WeakReference<>((ChatLine) (Object) this)); NetHandlerPlayClient netHandler = Minecraft.getMinecraft().getNetHandler(); + if (netHandler == null) return; Map nicknameCache = new HashMap<>(); - for (String word : iChatComponent.getFormattedText().split("(§.)|\\W")) { - if (word.isEmpty()) continue; - playerInfo = netHandler.getPlayerInfo(word); - if (playerInfo == null) { - playerInfo = getPlayerFromNickname(word, netHandler, nicknameCache); - } - if (playerInfo != null) { - detectedPlayerInfo = playerInfo; - detected = true; - if (playerInfo == lastPlayerInfo) { - first = false; - if (ChattingConfig.INSTANCE.getHideChatHeadOnConsecutiveMessages()) { - playerInfo = null; + try { + for (String word : iChatComponent.getFormattedText().split("(§.)|\\W")) { + if (word.isEmpty()) continue; + playerInfo = netHandler.getPlayerInfo(word); + if (playerInfo == null) { + playerInfo = getPlayerFromNickname(word, netHandler, nicknameCache); + } + if (playerInfo != null) { + detectedPlayerInfo = playerInfo; + detected = true; + if (playerInfo == lastPlayerInfo) { + first = false; + if (ChattingConfig.INSTANCE.getHideChatHeadOnConsecutiveMessages()) { + playerInfo = null; + } + } else { + lastPlayerInfo = playerInfo; } - } else { - lastPlayerInfo = playerInfo; + break; } - break; } + } catch (Exception ignored) { } } -- cgit