|
5 | 5 |
|
6 | 6 | package meteordevelopment.meteorclient.mixin; |
7 | 7 |
|
| 8 | +import com.llamalad7.mixinextras.sugar.Local; |
| 9 | +import com.llamalad7.mixinextras.sugar.ref.LocalRef; |
8 | 10 | import com.mojang.brigadier.exceptions.CommandSyntaxException; |
9 | 11 | import meteordevelopment.meteorclient.MeteorClient; |
10 | 12 | import meteordevelopment.meteorclient.commands.Commands; |
@@ -47,12 +49,6 @@ public abstract class ClientPlayNetworkHandlerMixin extends ClientCommonNetworkH |
47 | 49 | @Shadow |
48 | 50 | private ClientWorld world; |
49 | 51 |
|
50 | | - @Shadow |
51 | | - public abstract void sendChatMessage(String content); |
52 | | - |
53 | | - @Unique |
54 | | - private boolean ignoreChatMessage; |
55 | | - |
56 | 52 | @Unique |
57 | 53 | private boolean worldNotNull; |
58 | 54 |
|
@@ -139,18 +135,16 @@ private void onItemPickupAnimation(ItemPickupAnimationS2CPacket packet, Callback |
139 | 135 | } |
140 | 136 |
|
141 | 137 | @Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true) |
142 | | - private void onSendChatMessage(String message, CallbackInfo ci) { |
143 | | - if (ignoreChatMessage) return; |
144 | | - |
| 138 | + private void onSendChatMessage(String message, CallbackInfo ci, @Local(argsOnly = true) LocalRef<String> messageRef) { |
145 | 139 | if (!message.startsWith(Config.get().prefix.get()) && !(BaritoneUtils.IS_AVAILABLE && message.startsWith(BaritoneUtils.getPrefix()))) { |
146 | 140 | SendMessageEvent event = MeteorClient.EVENT_BUS.post(SendMessageEvent.get(message)); |
147 | 141 |
|
148 | 142 | if (!event.isCancelled()) { |
149 | | - ignoreChatMessage = true; |
150 | | - sendChatMessage(event.message); |
151 | | - ignoreChatMessage = false; |
| 143 | + messageRef.set(event.message); |
| 144 | + } else { |
| 145 | + ci.cancel(); |
152 | 146 | } |
153 | | - ci.cancel(); |
| 147 | + |
154 | 148 | return; |
155 | 149 | } |
156 | 150 |
|
|
0 commit comments