mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
breaking: fix reverting action (1.19)
This commit is contained in:
parent
660aae38d4
commit
10ffbb7f29
@ -43,7 +43,9 @@ class SequencedExecutorTest {
|
|||||||
|
|
||||||
executor.start(Vec3i(1, 1, 1), state)
|
executor.start(Vec3i(1, 1, 1), state)
|
||||||
|
|
||||||
connection.world[Vec3i(1, 1, 1)] = state // <- set the same block -> revert
|
|
||||||
|
executor.abort(Vec3i(1, 1, 1), state) // TODO: simulate packet
|
||||||
|
// connection.world[Vec3i(1, 1, 1)] = state // <- set the same block -> revert/cancel
|
||||||
|
|
||||||
executor.finish()
|
executor.finish()
|
||||||
assertEquals(connection.world[Vec3i(1, 1, 1)], state)
|
assertEquals(connection.world[Vec3i(1, 1, 1)], state)
|
||||||
@ -57,6 +59,7 @@ class SequencedExecutorTest {
|
|||||||
executor.start(Vec3i(1, 1, 1), state)
|
executor.start(Vec3i(1, 1, 1), state)
|
||||||
|
|
||||||
executor.finish()
|
executor.finish()
|
||||||
|
Thread.sleep(10) // async, wait for thread to complete
|
||||||
assertNull(connection.world[Vec3i(1, 1, 1)])
|
assertNull(connection.world[Vec3i(1, 1, 1)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ abstract class BreakingExecutor(protected val breaking: BreakHandler) {
|
|||||||
open fun finish(): Int {
|
open fun finish(): Int {
|
||||||
val state = this.state ?: Broken()
|
val state = this.state ?: Broken()
|
||||||
val position = this.position ?: Broken()
|
val position = this.position ?: Broken()
|
||||||
|
val abort = this.abort
|
||||||
reset()
|
reset()
|
||||||
if (!abort) {
|
if (!abort) {
|
||||||
execute(position, state)
|
execute(position, state)
|
||||||
|
@ -13,7 +13,9 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.s2c.play.block
|
package de.bixilon.minosoft.protocol.packets.s2c.play.block
|
||||||
|
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||||
|
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||||
|
import de.bixilon.minosoft.input.interaction.breaking.executor.SequencedExecutor
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
@ -40,6 +42,9 @@ class BlockS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
connection.world[position] = state
|
connection.world[position] = state
|
||||||
|
if (state != null) {
|
||||||
|
connection.camera.interactions.breaking.executor.nullCast<SequencedExecutor>()?.abort(position, state)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user