aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-07-22 03:08:56 +0200
committernea <nea@nea.moe>2023-07-22 03:08:56 +0200
commitcdf3938b778188211ad316d16381e0d8c7beac75 (patch)
treeeb3508942f61bee290b0558c97c3e04946070b0a /src/main/java/moe/nea/firmament/mixins
parent538827af3bfccbc4cee1ff2e9cb76922108ace9e (diff)
downloadFirmament-cdf3938b778188211ad316d16381e0d8c7beac75.tar.gz
Firmament-cdf3938b778188211ad316d16381e0d8c7beac75.tar.bz2
Firmament-cdf3938b778188211ad316d16381e0d8c7beac75.zip
Add image preview
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinChatHud.java16
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinChatScreen.java8
2 files changed, 20 insertions, 4 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java b/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java
index f0db847..13921e5 100644
--- a/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java
+++ b/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java
@@ -8,14 +8,22 @@ 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 {
- @Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", cancellable = true)
- public void onAddMessage(Text message, MessageSignatureData signature, int ticks, MessageIndicator indicator, boolean refresh, CallbackInfo ci) {
- if (ClientChatLineReceivedEvent.Companion.publish(new ClientChatLineReceivedEvent(message)).getCancelled()) {
- ci.cancel();
+ @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
new file mode 100644
index 0000000..4d75c44
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/MixinChatScreen.java
@@ -0,0 +1,8 @@
+package moe.nea.firmament.mixins;
+
+import net.minecraft.client.gui.screen.ChatScreen;
+import org.spongepowered.asm.mixin.Mixin;
+
+@Mixin(ChatScreen.class)
+public class MixinChatScreen {
+}