From d45f8d2a57e4d20e0f45844b0ea35c198ee8a96a Mon Sep 17 00:00:00 2001 From: xtex Date: Fri, 18 Aug 2023 09:28:00 +0800 Subject: [PATCH] fix: signed 32-bits integer overflowed Use in the wild: Mojang --- .../main/kotlin/quaedam/projector/ProjectorBlockEntity.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt b/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt index 49a024d..2220fee 100644 --- a/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt +++ b/common/src/main/kotlin/quaedam/projector/ProjectorBlockEntity.kt @@ -75,8 +75,11 @@ class ProjectorBlockEntity(pos: BlockPos, state: BlockState) : val chunk = ChunkPos(SectionPos.blockToSectionCoord(blockPos.x), SectionPos.blockToSectionCoord(blockPos.z)) val minChunk = ChunkPos(chunk.x - radius, chunk.z - radius) val maxChunk = ChunkPos(chunk.x + radius, chunk.z + radius) - val minBlock = BlockPos(minChunk.minBlockX, Int.MIN_VALUE, minChunk.minBlockZ) - val maxBlock = BlockPos(maxChunk.maxBlockX, Int.MAX_VALUE, maxChunk.maxBlockZ) + // Y is not the limit value of Int because at + // Lnet/minecraft/world/level/entity/EntitySectionStorage;forEachAccessibleNonEmptySection(Lnet/minecraft/world/phys/AABB;Lnet/minecraft/util/AbortableIterationConsumer;)V + // it may get overflow + val minBlock = BlockPos(minChunk.minBlockX, Short.MIN_VALUE.toInt(), minChunk.minBlockZ) + val maxBlock = BlockPos(maxChunk.maxBlockX, Short.MAX_VALUE.toInt(), maxChunk.maxBlockZ) effectArea = BoundingBox.fromCorners(minBlock, maxBlock) effectAreaAABB = AABB(minBlock, maxBlock) }