mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 01:16:46 -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
|
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) {
|
if (player.gamemode == Gamemodes.SPECTATOR) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,10 @@ class InteractionManager(val camera: ConnectionCamera) : Tickable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun swingHand(hand: Hands) {
|
fun swingHand(hand: Hands) {
|
||||||
swingArmRateLimiter += { connection.sendPacket(SwingArmC2SP(hand)) }
|
swingArmRateLimiter += {
|
||||||
|
connection.network.send(SwingArmC2SP(hand))
|
||||||
|
connection.player.swingHand(hand)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isCoolingDown(item: Item): Boolean {
|
fun isCoolingDown(item: Item): Boolean {
|
||||||
|
@ -55,7 +55,8 @@ class BreakHandler(
|
|||||||
interactions.swingHand(Hands.MAIN)
|
interactions.swingHand(Hands.MAIN)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tickBreaking()
|
val swung = tickBreaking()
|
||||||
|
if (!swung) interactions.swingHand(Hands.MAIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRelease() {
|
override fun onRelease() {
|
||||||
@ -70,16 +71,15 @@ class BreakHandler(
|
|||||||
tickBreaking()
|
tickBreaking()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tickBreaking() {
|
private fun tickBreaking(): Boolean {
|
||||||
val gamemode = connection.player.gamemode
|
val gamemode = connection.player.gamemode
|
||||||
val target = validateTarget()
|
val target = validateTarget()
|
||||||
|
|
||||||
if (gamemode == Gamemodes.CREATIVE) {
|
if (gamemode == Gamemodes.CREATIVE) {
|
||||||
digging.tryCancel()
|
digging.tryCancel()
|
||||||
creative.breakBlock(target)
|
return creative.breakBlock(target)
|
||||||
} else {
|
|
||||||
this.digging.dig(target)
|
|
||||||
}
|
}
|
||||||
|
return this.digging.dig(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addCooldown() {
|
fun addCooldown() {
|
||||||
|
@ -23,13 +23,14 @@ class CreativeBreaker(
|
|||||||
) {
|
) {
|
||||||
private val connection = breaking.interactions.connection
|
private val connection = breaking.interactions.connection
|
||||||
|
|
||||||
fun breakBlock(target: BlockTarget?) {
|
fun breakBlock(target: BlockTarget?): Boolean {
|
||||||
if (target == null) return
|
if (target == null) return false
|
||||||
breaking.addCooldown()
|
breaking.addCooldown()
|
||||||
val sequence = breaking.executor.start(target.blockPosition, target.state)
|
val sequence = breaking.executor.start(target.blockPosition, target.state)
|
||||||
breaking.executor.finish()
|
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)
|
breaking.interactions.swingHand(Hands.MAIN)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class SurvivalDigger(
|
|||||||
|
|
||||||
private fun cancel(status: BlockDigStatus) {
|
private fun cancel(status: BlockDigStatus) {
|
||||||
breaking.executor.cancel()
|
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
|
this.status = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class SurvivalDigger(
|
|||||||
val sequence = breaking.executor.finish()
|
val sequence = breaking.executor.finish()
|
||||||
this.status = null
|
this.status = null
|
||||||
if (!instant) {
|
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.addCooldown()
|
||||||
}
|
}
|
||||||
breaking.interactions.swingHand(Hands.MAIN)
|
breaking.interactions.swingHand(Hands.MAIN)
|
||||||
@ -118,7 +118,7 @@ class SurvivalDigger(
|
|||||||
} else {
|
} else {
|
||||||
nextStatus = BlockDigStatus(target.blockPosition, target.state, slot, productivity, target.direction)
|
nextStatus = BlockDigStatus(target.blockPosition, target.state, slot, productivity, target.direction)
|
||||||
val sequence = breaking.executor.start(target.blockPosition, target.state)
|
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) {
|
if (instant || nextStatus.progress >= 1.0f) {
|
||||||
@ -128,11 +128,11 @@ class SurvivalDigger(
|
|||||||
this.status = nextStatus
|
this.status = nextStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dig(target: BlockTarget?) {
|
fun dig(target: BlockTarget?): Boolean {
|
||||||
var status = this.status
|
var status = this.status
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
status?.let { cancel(it) }
|
status?.let { cancel(it) }
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
val slot = connection.player.items.hotbar
|
val slot = connection.player.items.hotbar
|
||||||
|
|
||||||
@ -141,5 +141,6 @@ class SurvivalDigger(
|
|||||||
status = null
|
status = null
|
||||||
}
|
}
|
||||||
tick(status, target, slot)
|
tick(status, target, slot)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,9 +137,9 @@ class UseHandler(
|
|||||||
|
|
||||||
fun sendItemUse(hand: Hands, stack: ItemStack) {
|
fun sendItemUse(hand: Hands, stack: ItemStack) {
|
||||||
if (connection.version < V_15W31A) {
|
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 {
|
private companion object {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user