interaction handler: stop item using when changing hotbar slot

This commit is contained in:
Bixilon 2022-05-03 22:20:48 +02:00
parent 3fed73e640
commit bd268034bf
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 3 additions and 1 deletions

View File

@ -32,6 +32,7 @@ import de.bixilon.minosoft.util.KUtil.toResourceLocation
class HotbarInteractionHandler(
val renderWindow: RenderWindow,
val interactionManager: InteractionManager,
) {
private val connection = renderWindow.connection
val slotLimiter = RateLimiter()
@ -48,6 +49,7 @@ class HotbarInteractionHandler(
return
}
connection.player.selectedHotbarSlot = slot
interactionManager.use.stopUsingItem()
slotLimiter += { connection.sendPacket(HotbarSlotC2SP(slot)) }
connection.fireEvent(SelectHotbarSlotEvent(connection, EventInitiators.CLIENT, slot))
}

View File

@ -23,7 +23,7 @@ class InteractionManager(
val renderWindow: RenderWindow,
) {
private val connection = renderWindow.connection
val hotbar = HotbarInteractionHandler(renderWindow)
val hotbar = HotbarInteractionHandler(renderWindow, this)
val pick = ItemPickInteractionHandler(renderWindow, this)
val attack = AttackInteractionHandler(renderWindow, this)
val `break` = BreakInteractionHandler(renderWindow)