Skip to content

Commit 1db9c22

Browse files
authored
Fixed Wanderwand Deselect. (#293)
* Fixed bounding box comperison This caused unitended errors resulting in no-zero intersections when they should be empty. * Optimised Wanderwand Added selection merge to selection deletion, preventing NBT crashes from boundingboxes splitting repeateadly, without ever being merged.
1 parent 637a3a1 commit 1db9c22

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

common/src/main/kotlin/org/valkyrienskies/clockwork/content/curiosities/tools/wanderwand/WanderwandItem.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ class WanderwandItem(properties: Properties) : CWItem(properties) {
105105
val existingSelectionDeser = readAABBSetFromNBT(existingSelection)
106106
val out = existingSelectionDeser.subtractWithAABB(selection)
107107
wand.tag?.remove("selectedBlocks")
108-
wand.tag?.put("selectedBlocks", writeAABBSetToNBT(out))
108+
val optimizedOut = mergeAdjacentFast(out)
109+
wand.tag?.put("selectedBlocks", writeAABBSetToNBT(optimizedOut))
109110
}
110111
}
111112
sendTo(WanderwandRenderUpdatePacket(firstPos, if (deselect) ToolType.DESELECT else ToolType.SELECT, blocks = wand.tag?.get("selectedBlocks") as? CompoundTag?), sPlayer)

common/src/main/kotlin/org/valkyrienskies/clockwork/util/AABBHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.joml.primitives.AABBic
66
object AABBHelper {
77

88
private fun isEmpty(b: AABBi): Boolean =
9-
b.minX == b.maxX || b.minY == b.maxY || b.minZ == b.maxZ
9+
b.minX >= b.maxX || b.minY >= b.maxY || b.minZ >= b.maxZ
1010

1111
private fun intersectionHalfOpen(a: AABBi, c: AABBi): AABBi? {
1212
val ix0 = maxOf(a.minX, c.minX)

0 commit comments

Comments
 (0)