Skip to content

Commit bbdad3b

Browse files
committed
Fixing Physics Ticks Event Handler
1 parent ae437ba commit bbdad3b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

common/src/main/kotlin/io/github/techtastic/cc_vs/CCVSMod.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import dan200.computercraft.shared.computer.core.ServerContext
55
import dev.architectury.event.events.common.LifecycleEvent
66
import io.github.techtastic.cc_vs.apis.ShipAPI
77
import io.github.techtastic.cc_vs.ship.PhysTickEventHandler
8+
import io.github.techtastic.cc_vs.ship.PhysicsTicksEventHandler
89
import org.valkyrienskies.core.impl.hooks.VSEvents
910

1011
object CCVSMod {
@@ -18,6 +19,10 @@ object CCVSMod {
1819
ComputerCraftAPI.registerAPIFactory(::ShipAPI)
1920

2021
VSEvents.shipLoadEvent.on { huh -> huh.ship.setAttachment(PhysTickEventHandler::class.java, null) }
22+
23+
VSEvents.tickEndEvent.on { huh -> huh.world.loadedShips.forEach { ship ->
24+
PhysicsTicksEventHandler.getOrCreateControl(ship).resetData()
25+
} }
2126
}
2227

2328
@JvmStatic

common/src/main/kotlin/io/github/techtastic/cc_vs/ship/PhysicsTicksEventHandler.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ class PhysicsTicksEventHandler: ShipForcesInducer {
1919
}
2020

2121
@JsonIgnore
22-
fun getData(): Array<LuaPhysShip> {
23-
val data = this.queuedData.toTypedArray()
24-
this.queuedData.clear()
25-
return data
26-
}
22+
fun getData() = this.queuedData.toTypedArray()
23+
24+
fun resetData() = this.queuedData.clear()
2725

2826
companion object {
2927
fun getOrCreateControl(ship: ServerShip): PhysicsTicksEventHandler {

0 commit comments

Comments
 (0)