Archived
1
0
Fork 0

Log a dev-only warning when an entity still has world == null two ticks after its creation

This commit is contained in:
Moritz Ruth 2021-02-28 14:06:19 +01:00
parent b5b9b2c876
commit c959478978
No known key found for this signature in database
GPG key ID: AFD57E23E753841B
2 changed files with 9 additions and 1 deletions

View file

@ -107,7 +107,7 @@ class TestPlugin : Plugin("Test", "1.0.0") {
// Not showing up yet because no metadata is sent // Not showing up yet because no metadata is sent
val entity = Uranos.create<MinecartEntity>() val entity = Uranos.create<MinecartEntity>()
entity.position = Position(0.0, 4.0, 0.0) entity.position = Position(0.0, 4.0, 0.0)
entity.setWorld(world) // entity.setWorld(world)
var x = 0f var x = 0f
var y = -90f var y = -90f

View file

@ -65,6 +65,8 @@ sealed class UranosEntity(server: UranosServer) : Entity {
} }
} }
override fun toString(): String = "Entity($uuid)"
abstract suspend fun tick() abstract suspend fun tick()
abstract val chunkKey: Chunk.Key abstract val chunkKey: Chunk.Key
@ -79,6 +81,12 @@ sealed class UranosEntity(server: UranosServer) : Entity {
addedViewers.clear() addedViewers.clear()
removedViewers.clear() removedViewers.clear()
} }
init {
if (server.config.developmentMode) server.scheduler.executeAfter(2) {
if (world == null) server.logger.warn("$this was created 2 ticks ago and its world is still null.")
}
}
} }
sealed class UranosLivingEntity(server: UranosServer) : UranosEntity(server), LivingEntity { sealed class UranosLivingEntity(server: UranosServer) : UranosEntity(server), LivingEntity {