Plants without occupied spaces no longer crash server

This commit is contained in:
DBotThePony 2024-04-22 22:16:48 +07:00
parent c2cb8dd208
commit 934e8f8479
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -148,6 +148,7 @@ class PlantPieceEntity() : DynamicEntity() {
piecesInternal.add(Piece(piece))
}
if (allSpaces.isNotEmpty()) {
calculatedMetaBoundingBox = AABB.ofPoints(allSpaces)
if (pieces.any { it.isStructuralSegment } && stemSpaces.isNotEmpty()) {
@ -162,8 +163,11 @@ class PlantPieceEntity() : DynamicEntity() {
calculatedCollisionBox = calculatedMetaBoundingBox
calculatedCollisionHull = Poly(calculatedMetaBoundingBox)
}
//calculatedCollisionHull = calculatedCollisionHull * 0.5 + calculatedCollisionHull.aabb.centre * 0.5
} else {
calculatedMetaBoundingBox = AABB.rectangle(Vector2d.ZERO, 0.1, 0.1)
calculatedCollisionBox = calculatedMetaBoundingBox
calculatedCollisionHull = Poly(calculatedMetaBoundingBox)
}
}
constructor(stream: DataInputStream, isLegacy: Boolean) : this() {