Add Nearby Burrow Highlighter
This commit is contained in:
23
src/main/kotlin/moe/nea/firmament/events/AttackBlockEvent.kt
Normal file
23
src/main/kotlin/moe/nea/firmament/events/AttackBlockEvent.kt
Normal file
@@ -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>()
|
||||
}
|
||||
@@ -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>()
|
||||
}
|
||||
|
||||
16
src/main/kotlin/moe/nea/firmament/events/UseBlockEvent.kt
Normal file
16
src/main/kotlin/moe/nea/firmament/events/UseBlockEvent.kt
Normal file
@@ -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>()
|
||||
}
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user