Skip to content

Include polygon regions whose max edge lies on a chunk's first row - #2340

Open
intersecato wants to merge 1 commit into
EngineHub:version/7.0.xfrom
intersecato:version/7.0.x
Open

intersecato wants to merge 1 commit into
EngineHub:version/7.0.xfrom
intersecato:version/7.0.x

Conversation

@intersecato

Copy link
Copy Markdown
Contributor

Problem

Polygonal regions are missing from getApplicableRegions on their max X/Z edge when that edge falls exactly on the first block row of a chunk (coordinate divisible by 16), even though ProtectedRegion#contains returns true for those blocks. Flag queries on that row only see the parent/global regions.

Example: a poly region with points spanning z -861..-848. Block (-445, 92, -848):

  • region.contains(...) → true
  • regionManager.getApplicableRegions(...) → region missing
  • block (-445, 92, -849) → region present

Cause

ChunkHashTable.EnumerateRegions collects a chunk's regions via applyIntersecting with a cuboid covering the chunk, which ends up comparing AWT Area. ProtectedCuboidRegion#toArea adds +1 to width/height so the area covers whole blocks, but ProtectedPolygonalRegion#toArea uses the raw vertices, so the polygon's area ends on its max edge line. When that line equals the chunk's min coordinate the two areas only touch, the intersection is empty, and the region is never cached for that chunk.

Fix

Extend the chunk lookup cuboid by one block on the min side. This only widens the candidate list for the chunk cache, applyContaining still filters every candidate with region.contains(position), so results stay exact. Cuboid regions are unaffected.

Testing

Built worldguard-bukkit. Verified the reported behavior on a live server: before the fix, the edge block on the chunk boundary was missing from the applicable regions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant