aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/events/registration
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-01-18 20:00:47 +0100
committerLinnea Gräf <nea@nea.moe>2024-01-18 20:00:47 +0100
commit608fec9cd0bbe3cf389faaeb7e258b592e3adf14 (patch)
treeef7996342498f64529ac6eb5851b2a61a1973d1c /src/main/kotlin/moe/nea/firmament/events/registration
parentd7902e06cd7285c72cd4ea2be6f18ead56a8775e (diff)
downloadfirmament-608fec9cd0bbe3cf389faaeb7e258b592e3adf14.tar.gz
firmament-608fec9cd0bbe3cf389faaeb7e258b592e3adf14.tar.bz2
firmament-608fec9cd0bbe3cf389faaeb7e258b592e3adf14.zip
Add Nearby Burrow Highlighter
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/events/registration')
-rw-r--r--src/main/kotlin/moe/nea/firmament/events/registration/ChatEvents.kt26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/events/registration/ChatEvents.kt b/src/main/kotlin/moe/nea/firmament/events/registration/ChatEvents.kt
index 90a665a..4db0f60 100644
--- a/src/main/kotlin/moe/nea/firmament/events/registration/ChatEvents.kt
+++ b/src/main/kotlin/moe/nea/firmament/events/registration/ChatEvents.kt
@@ -6,24 +6,29 @@
package moe.nea.firmament.events.registration
+import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents
+import net.fabricmc.fabric.api.event.player.AttackBlockCallback
+import net.fabricmc.fabric.api.event.player.UseBlockCallback
+import net.minecraft.text.Text
+import net.minecraft.util.ActionResult
import moe.nea.firmament.events.AllowChatEvent
+import moe.nea.firmament.events.AttackBlockEvent
import moe.nea.firmament.events.ModifyChatEvent
import moe.nea.firmament.events.ProcessChatEvent
-import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents
-import net.minecraft.text.Text
+import moe.nea.firmament.events.UseBlockEvent
private var lastReceivedMessage: Text? = null
-fun registerFirmamentChatEvents() {
+fun registerFirmamentEvents() {
ClientReceiveMessageEvents.ALLOW_CHAT.register(ClientReceiveMessageEvents.AllowChat { message, signedMessage, sender, params, receptionTimestamp ->
lastReceivedMessage = message
!ProcessChatEvent.publish(ProcessChatEvent(message, false)).cancelled
- && !AllowChatEvent.publish(AllowChatEvent(message)).cancelled
+ && !AllowChatEvent.publish(AllowChatEvent(message)).cancelled
})
ClientReceiveMessageEvents.ALLOW_GAME.register(ClientReceiveMessageEvents.AllowGame { message, overlay ->
lastReceivedMessage = message
overlay || (!ProcessChatEvent.publish(ProcessChatEvent(message, false)).cancelled &&
- !AllowChatEvent.publish(AllowChatEvent(message)).cancelled)
+ !AllowChatEvent.publish(AllowChatEvent(message)).cancelled)
})
ClientReceiveMessageEvents.MODIFY_GAME.register(ClientReceiveMessageEvents.ModifyGame { message, overlay ->
if (overlay) message
@@ -39,4 +44,15 @@ fun registerFirmamentChatEvents() {
ProcessChatEvent.publish(ProcessChatEvent(message, true))
}
})
+
+ AttackBlockCallback.EVENT.register(AttackBlockCallback { player, world, hand, pos, direction ->
+ if (AttackBlockEvent.publish(AttackBlockEvent(player, world, hand, pos, direction)).cancelled)
+ ActionResult.CONSUME
+ else ActionResult.PASS
+ })
+ UseBlockCallback.EVENT.register(UseBlockCallback { player, world, hand, hitResult ->
+ if (UseBlockEvent.publish(UseBlockEvent(player, world, hand, hitResult)).cancelled)
+ ActionResult.CONSUME
+ else ActionResult.PASS
+ })
}