mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 08:58:02 -04:00
fix arm not correctly swinging whe having no target
This commit is contained in:
parent
5ed8ea53cf
commit
b84ccc436a
@ -64,7 +64,7 @@ class AttackHandler(
|
||||
return
|
||||
}
|
||||
|
||||
interactions.connection.sendPacket(EntityAttackC2SP(target.entity.id ?: return, player.isSneaking))
|
||||
interactions.connection.network.send(EntityAttackC2SP(target.entity.id ?: return, player.isSneaking))
|
||||
if (player.gamemode == Gamemodes.SPECTATOR) {
|
||||
return
|
||||
}
|
||||
|
@ -72,7 +72,10 @@ class InteractionManager(val camera: ConnectionCamera) : Tickable {
|
||||
}
|
||||
|
||||
fun swingHand(hand: Hands) {
|
||||
swingArmRateLimiter += { connection.sendPacket(SwingArmC2SP(hand)) }
|
||||
swingArmRateLimiter += {
|
||||
connection.network.send(SwingArmC2SP(hand))
|
||||
connection.player.swingHand(hand)
|
||||
}
|
||||
}
|
||||
|
||||
fun isCoolingDown(item: Item): Boolean {
|
||||
|
@ -55,7 +55,8 @@ class BreakHandler(
|
||||
interactions.swingHand(Hands.MAIN)
|
||||
return
|
||||
}
|
||||
tickBreaking()
|
||||
val swung = tickBreaking()
|
||||
if (!swung) interactions.swingHand(Hands.MAIN)
|
||||
}
|
||||
|
||||
override fun onRelease() {
|
||||
@ -70,16 +71,15 @@ class BreakHandler(
|
||||
tickBreaking()
|
||||
}
|
||||
|
||||
private fun tickBreaking() {
|
||||
private fun tickBreaking(): Boolean {
|
||||
val gamemode = connection.player.gamemode
|
||||
val target = validateTarget()
|
||||
|
||||
if (gamemode == Gamemodes.CREATIVE) {
|
||||
digging.tryCancel()
|
||||
creative.breakBlock(target)
|
||||
} else {
|
||||
this.digging.dig(target)
|
||||
return creative.breakBlock(target)
|
||||
}
|
||||
return this.digging.dig(target)
|
||||
}
|
||||
|
||||
fun addCooldown() {
|
||||
|
@ -23,13 +23,14 @@ class CreativeBreaker(
|
||||
) {
|
||||
private val connection = breaking.interactions.connection
|
||||
|
||||
fun breakBlock(target: BlockTarget?) {
|
||||
if (target == null) return
|
||||
fun breakBlock(target: BlockTarget?): Boolean {
|
||||
if (target == null) return false
|
||||
breaking.addCooldown()
|
||||
val sequence = breaking.executor.start(target.blockPosition, target.state)
|
||||
breaking.executor.finish()
|
||||
|
||||
connection.sendPacket(PlayerActionC2SP(PlayerActionC2SP.Actions.START_DIGGING, target.blockPosition, target.direction, sequence))
|
||||
connection.network.send(PlayerActionC2SP(PlayerActionC2SP.Actions.START_DIGGING, target.blockPosition, target.direction, sequence))
|
||||
breaking.interactions.swingHand(Hands.MAIN)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class SurvivalDigger(
|
||||
|
||||
private fun cancel(status: BlockDigStatus) {
|
||||
breaking.executor.cancel()
|
||||
connection.sendPacket(PlayerActionC2SP(PlayerActionC2SP.Actions.CANCELLED_DIGGING, status.position, sequence = 0))
|
||||
connection.network.send(PlayerActionC2SP(PlayerActionC2SP.Actions.CANCELLED_DIGGING, status.position, sequence = 0))
|
||||
this.status = null
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ class SurvivalDigger(
|
||||
val sequence = breaking.executor.finish()
|
||||
this.status = null
|
||||
if (!instant) {
|
||||
connection.sendPacket(PlayerActionC2SP(PlayerActionC2SP.Actions.FINISHED_DIGGING, status.position, status.direction, sequence))
|
||||
connection.network.send(PlayerActionC2SP(PlayerActionC2SP.Actions.FINISHED_DIGGING, status.position, status.direction, sequence))
|
||||
breaking.addCooldown()
|
||||
}
|
||||
breaking.interactions.swingHand(Hands.MAIN)
|
||||
@ -118,7 +118,7 @@ class SurvivalDigger(
|
||||
} else {
|
||||
nextStatus = BlockDigStatus(target.blockPosition, target.state, slot, productivity, target.direction)
|
||||
val sequence = breaking.executor.start(target.blockPosition, target.state)
|
||||
connection.sendPacket(PlayerActionC2SP(PlayerActionC2SP.Actions.START_DIGGING, target.blockPosition, target.direction, sequence))
|
||||
connection.network.send(PlayerActionC2SP(PlayerActionC2SP.Actions.START_DIGGING, target.blockPosition, target.direction, sequence))
|
||||
}
|
||||
|
||||
if (instant || nextStatus.progress >= 1.0f) {
|
||||
@ -128,11 +128,11 @@ class SurvivalDigger(
|
||||
this.status = nextStatus
|
||||
}
|
||||
|
||||
fun dig(target: BlockTarget?) {
|
||||
fun dig(target: BlockTarget?): Boolean {
|
||||
var status = this.status
|
||||
if (target == null) {
|
||||
status?.let { cancel(it) }
|
||||
return
|
||||
return false
|
||||
}
|
||||
val slot = connection.player.items.hotbar
|
||||
|
||||
@ -141,5 +141,6 @@ class SurvivalDigger(
|
||||
status = null
|
||||
}
|
||||
tick(status, target, slot)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -137,9 +137,9 @@ class UseHandler(
|
||||
|
||||
fun sendItemUse(hand: Hands, stack: ItemStack) {
|
||||
if (connection.version < V_15W31A) {
|
||||
connection.sendPacket(BlockInteractC2SP(null, null, null, stack, hand, false, 1))
|
||||
connection.network.send(BlockInteractC2SP(null, null, null, stack, hand, false, 1))
|
||||
}
|
||||
connection.sendPacket(UseItemC2SP(hand, interactions.connection.sequence.getAndIncrement()))
|
||||
connection.network.send(UseItemC2SP(hand, interactions.connection.sequence.getAndIncrement()))
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
Loading…
x
Reference in New Issue
Block a user