aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinChatHud.java25
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinChatScreen.java14
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinMessageHandler.java40
3 files changed, 3 insertions, 76 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java b/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java
index bc7c036..aa1bf54 100644
--- a/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java
+++ b/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java
@@ -7,41 +7,22 @@
package moe.nea.firmament.mixins;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
-import moe.nea.firmament.events.ClientChatLineReceivedEvent;
import moe.nea.firmament.features.fixes.Fixes;
import net.minecraft.client.gui.hud.ChatHud;
-import net.minecraft.client.gui.hud.MessageIndicator;
-import net.minecraft.network.message.MessageSignatureData;
-import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.ModifyArg;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ChatHud.class)
public class MixinChatHud {
- @ModifyExpressionValue(method = "render",at = @At(value = "INVOKE",target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"))
+ @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"))
public boolean onGetChatHud(boolean old) {
return old || Fixes.INSTANCE.shouldPeekChat();
}
- @ModifyExpressionValue(method = "getHeight",at = @At(value = "INVOKE",target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"))
+
+ @ModifyExpressionValue(method = "getHeight", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"))
public boolean onGetChatHudHeight(boolean old) {
return old || Fixes.INSTANCE.shouldPeekChat();
}
- @ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V")
- public Text onAddMessage(Text message) {
- var event = new ClientChatLineReceivedEvent(message);
- if (ClientChatLineReceivedEvent.Companion.publish(event).getCancelled()) {
- return null;
- }
- return event.getReplaceWith();
- }
-
- @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", at = @At("HEAD"), cancellable = true)
- public void onAddMessage2(Text message, MessageSignatureData signature, int ticks, MessageIndicator indicator, boolean refresh, CallbackInfo ci) {
- if (message == null) ci.cancel();
- }
}
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinChatScreen.java b/src/main/java/moe/nea/firmament/mixins/MixinChatScreen.java
deleted file mode 100644
index 0759163..0000000
--- a/src/main/java/moe/nea/firmament/mixins/MixinChatScreen.java
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- */
-
-package moe.nea.firmament.mixins;
-
-import net.minecraft.client.gui.screen.ChatScreen;
-import org.spongepowered.asm.mixin.Mixin;
-
-@Mixin(ChatScreen.class)
-public class MixinChatScreen {
-}
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinMessageHandler.java b/src/main/java/moe/nea/firmament/mixins/MixinMessageHandler.java
deleted file mode 100644
index 867c8ea..0000000
--- a/src/main/java/moe/nea/firmament/mixins/MixinMessageHandler.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- */
-
-package moe.nea.firmament.mixins;
-
-import com.mojang.authlib.GameProfile;
-import moe.nea.firmament.events.ServerChatLineReceivedEvent;
-import net.minecraft.client.network.message.MessageHandler;
-import net.minecraft.network.message.MessageType;
-import net.minecraft.network.message.SignedMessage;
-import net.minecraft.text.Text;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
-@Mixin(MessageHandler.class)
-public class MixinMessageHandler {
- @Inject(method = "onChatMessage", cancellable = true, at = @At("HEAD"))
- public void onOnChatMessage(SignedMessage message, GameProfile sender, MessageType.Parameters params, CallbackInfo ci) {
- var decoratedText = params.applyChatDecoration(message.unsignedContent() != null ? message.unsignedContent() : message.getContent());
- var event = new ServerChatLineReceivedEvent(decoratedText);
- if (ServerChatLineReceivedEvent.Companion.publish(event).getCancelled()) {
- ci.cancel();
- }
- }
-
- @Inject(method = "onGameMessage", at = @At("HEAD"), cancellable = true)
- public void onOnGameMessage(Text message, boolean overlay, CallbackInfo ci) {
- if (!overlay) {
- var event = new ServerChatLineReceivedEvent(message);
- if (ServerChatLineReceivedEvent.Companion.publish(event).getCancelled()) {
- ci.cancel();
- }
- }
- }
-}