From 3a21bbfa2f97808a6cb4306756f0397db5103a7d Mon Sep 17 00:00:00 2001 From: Bixilon Date: Fri, 16 Sep 2022 14:37:28 +0200 Subject: [PATCH] add VoxelShape::equals * This should fix some lighting bugs, because light properties are not determinant as expected --- .../minosoft/data/registries/VoxelShape.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/de/bixilon/minosoft/data/registries/VoxelShape.kt b/src/main/java/de/bixilon/minosoft/data/registries/VoxelShape.kt index 4616c2c3e..57d62b73f 100644 --- a/src/main/java/de/bixilon/minosoft/data/registries/VoxelShape.kt +++ b/src/main/java/de/bixilon/minosoft/data/registries/VoxelShape.kt @@ -140,6 +140,21 @@ class VoxelShape(private val aabbs: MutableList = mutableListOf()) : Itera return shouldDrawLine(start.toVec3d, end.toVec3d) } + override fun toString(): String { + return aabbs.toString() + } + + override fun hashCode(): Int { + return aabbs.hashCode() + } + + override fun equals(other: Any?): Boolean { + if (other === this) return true + if (other !is VoxelShape) return false + if (other.hashCode() != hashCode()) return false + return aabbs == other.aabbs + } + companion object { val EMPTY = VoxelShape() val FULL = VoxelShape(mutableListOf(AABB.BLOCK))