@@ -34,8 +34,6 @@ import kotlin.time.toDuration
3434
3535// ToDo:
3636// - Use a custom binary format to store the data (Protobuf / DB?)
37- // - Actually store the data in a file
38- // - Implement a way to save and load the data (Commands?)
3937// - Record other types of inputs: (Interactions, etc.)
4038object Replay : Module(
4139 name = " Replay" ,
@@ -107,6 +105,7 @@ object Replay : Module(
107105 }
108106 State .PLAYING , State .PLAYING_CHECKPOINTS -> {
109107 replay?.let {
108+ it.input.removeFirstOrNull()?.update(event.input)
110109 it.position.removeFirstOrNull()?.let a@{ pos ->
111110 val diff = pos.subtract(player.pos).length()
112111 if (diff < 0.001 ) return @a
@@ -118,7 +117,6 @@ object Replay : Module(
118117 return @listener
119118 }
120119 }
121- it.input.removeFirstOrNull()?.update(event.input)
122120 }
123121 }
124122 else -> {}
@@ -131,10 +129,8 @@ object Replay : Module(
131129 recording?.rotation?.add(player.rotation)
132130 }
133131 State .PLAYING , State .PLAYING_CHECKPOINTS -> {
134- replay?.let {
135- it.rotation.removeFirstOrNull()?.let { rot ->
136- event.context = RotationContext (rot, rotationConfig)
137- }
132+ replay?.rotation?.removeFirstOrNull()?.let { rot ->
133+ event.context = RotationContext (rot, rotationConfig)
138134 }
139135 }
140136 else -> {}
@@ -147,11 +143,9 @@ object Replay : Module(
147143 recording?.sprint?.add(player.isSprinting)
148144 }
149145 State .PLAYING , State .PLAYING_CHECKPOINTS -> {
150- replay?.let {
151- it.sprint.removeFirstOrNull()?.let { sprint ->
152- event.sprint = sprint
153- player.isSprinting = sprint // ToDo: Find out why
154- }
146+ replay?.sprint?.removeFirstOrNull()?.let { sprint ->
147+ event.sprint = sprint
148+ player.isSprinting = sprint
155149 }
156150 }
157151 else -> {}
@@ -255,8 +249,8 @@ object Replay : Module(
255249
256250 checkpoint = recording?.duplicate()
257251 lambdaScope.launch(Dispatchers .IO ) {
258- FolderRegister .replays .mkdirs()
259- FolderRegister .replays .resolve(" checkpoint-${
252+ FolderRegister .replay .mkdirs()
253+ FolderRegister .replay .resolve(" checkpoint-${
260254 mc.currentServerEntry?.address?.replace(" :" , " _" )
261255 } -${
262256 world.dimensionKey?.value?.path?.replace(" /" , " _" )
@@ -361,21 +355,13 @@ object Replay : Module(
361355 }
362356
363357 data class InputAction (
364- @SerializedName(" s" )
365358 val movementSideways : Float ,
366- @SerializedName(" f" )
367359 val movementForward : Float ,
368- @SerializedName(" pf" )
369360 val pressingForward : Boolean ,
370- @SerializedName(" pb" )
371361 val pressingBack : Boolean ,
372- @SerializedName(" pl" )
373362 val pressingLeft : Boolean ,
374- @SerializedName(" pr" )
375363 val pressingRight : Boolean ,
376- @SerializedName(" j" )
377364 val jumping : Boolean ,
378- @SerializedName(" sn" )
379365 val sneaking : Boolean
380366 ) {
381367 fun update (input : Input ) {
0 commit comments