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.java21
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java9
2 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java b/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java
new file mode 100644
index 0000000..f0db847
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java
@@ -0,0 +1,21 @@
+package moe.nea.firmament.mixins;
+
+import moe.nea.firmament.events.ClientChatLineReceivedEvent;
+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.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();
+ }
+ }
+}
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java b/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java
index 46ab08a..9d8463e 100644
--- a/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java
+++ b/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java
@@ -18,8 +18,10 @@
package moe.nea.firmament.mixins;
+import moe.nea.firmament.events.OutgoingPacketEvent;
import moe.nea.firmament.events.ParticleSpawnEvent;
import net.minecraft.client.network.ClientPlayNetworkHandler;
+import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
@@ -38,4 +40,11 @@ public class MixinClientPacketHandler {
packet.isLongDistance()
));
}
+
+ @Inject(method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true)
+ public void onSendPacket(Packet<?> packet, CallbackInfo ci) {
+ if (OutgoingPacketEvent.Companion.publish(new OutgoingPacketEvent(packet)).getCancelled()) {
+ ci.cancel();
+ }
+ }
}