Log a dev-only warning when an entity still has world == null two ticks after its creation
This commit is contained in:
parent
b5b9b2c876
commit
c959478978
2 changed files with 9 additions and 1 deletions
|
@ -107,7 +107,7 @@ class TestPlugin : Plugin("Test", "1.0.0") {
|
|||
// Not showing up yet because no metadata is sent
|
||||
val entity = Uranos.create<MinecartEntity>()
|
||||
entity.position = Position(0.0, 4.0, 0.0)
|
||||
entity.setWorld(world)
|
||||
// entity.setWorld(world)
|
||||
|
||||
var x = 0f
|
||||
var y = -90f
|
||||
|
|
|
@ -65,6 +65,8 @@ sealed class UranosEntity(server: UranosServer) : Entity {
|
|||
}
|
||||
}
|
||||
|
||||
override fun toString(): String = "Entity($uuid)"
|
||||
|
||||
abstract suspend fun tick()
|
||||
abstract val chunkKey: Chunk.Key
|
||||
|
||||
|
@ -79,6 +81,12 @@ sealed class UranosEntity(server: UranosServer) : Entity {
|
|||
addedViewers.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 {
|
||||
|
|
Reference in a new issue