diff options
author | Linnea Gräf <nea@nea.moe> | 2024-01-18 20:00:47 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-01-18 20:00:47 +0100 |
commit | 608fec9cd0bbe3cf389faaeb7e258b592e3adf14 (patch) | |
tree | ef7996342498f64529ac6eb5851b2a61a1973d1c /src/main/kotlin/moe/nea/firmament/events | |
parent | d7902e06cd7285c72cd4ea2be6f18ead56a8775e (diff) | |
download | Firmament-608fec9cd0bbe3cf389faaeb7e258b592e3adf14.tar.gz Firmament-608fec9cd0bbe3cf389faaeb7e258b592e3adf14.tar.bz2 Firmament-608fec9cd0bbe3cf389faaeb7e258b592e3adf14.zip |
Add Nearby Burrow Highlighter
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/events')
4 files changed, 63 insertions, 6 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/events/AttackBlockEvent.kt b/src/main/kotlin/moe/nea/firmament/events/AttackBlockEvent.kt new file mode 100644 index 0000000..3d8ccdd --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/events/AttackBlockEvent.kt @@ -0,0 +1,23 @@ +/* + * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.events + +import net.minecraft.entity.player.PlayerEntity +import net.minecraft.util.Hand +import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.Direction +import net.minecraft.world.World + +data class AttackBlockEvent( + val player: PlayerEntity, + val world: World, + val hand: Hand, + val blockPos: BlockPos, + val direction: Direction +) : FirmamentEvent.Cancellable() { + companion object : FirmamentEventBus<AttackBlockEvent>() +} diff --git a/src/main/kotlin/moe/nea/firmament/events/ParticleSpawnEvent.kt b/src/main/kotlin/moe/nea/firmament/events/ParticleSpawnEvent.kt index e1b9ad3..a97b6d0 100644 --- a/src/main/kotlin/moe/nea/firmament/events/ParticleSpawnEvent.kt +++ b/src/main/kotlin/moe/nea/firmament/events/ParticleSpawnEvent.kt @@ -6,15 +6,17 @@ package moe.nea.firmament.events +import org.joml.Vector3f import net.minecraft.particle.ParticleEffect import net.minecraft.util.math.Vec3d data class ParticleSpawnEvent( val particleEffect: ParticleEffect, val position: Vec3d, - val offset: Vec3d, + val offset: Vector3f, val longDistance: Boolean, val count: Int, + val speed: Float, ) : FirmamentEvent.Cancellable() { companion object : FirmamentEventBus<ParticleSpawnEvent>() } diff --git a/src/main/kotlin/moe/nea/firmament/events/UseBlockEvent.kt b/src/main/kotlin/moe/nea/firmament/events/UseBlockEvent.kt new file mode 100644 index 0000000..5db4104 --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/events/UseBlockEvent.kt @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.events + +import net.minecraft.entity.player.PlayerEntity +import net.minecraft.util.Hand +import net.minecraft.util.hit.BlockHitResult +import net.minecraft.world.World + +data class UseBlockEvent(val player: PlayerEntity, val world: World, val hand: Hand, val hitResult: BlockHitResult) : FirmamentEvent.Cancellable() { + companion object : FirmamentEventBus<UseBlockEvent>() +} 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 + }) } |