Skip to content

Commit 3a332fd

Browse files
authored
Fix off-by-one in area calculation.
Even the volume calculation had it correct. Also fix code style in contains.
1 parent 0f72811 commit 3a332fd

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

worldguard-legacy/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedCuboidRegion.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ public boolean contains(Vector pt) {
125125
final double x = pt.getX();
126126
final double y = pt.getY();
127127
final double z = pt.getZ();
128-
return x >= min.getBlockX() && x < max.getBlockX()+1
129-
&& y >= min.getBlockY() && y < max.getBlockY()+1
130-
&& z >= min.getBlockZ() && z < max.getBlockZ()+1;
128+
return x >= min.getBlockX() && x < max.getBlockX() + 1
129+
&& y >= min.getBlockY() && y < max.getBlockY() + 1
130+
&& z >= min.getBlockZ() && z < max.getBlockZ() + 1;
131131
}
132132

133133
@Override
@@ -139,8 +139,8 @@ public RegionType getType() {
139139
Area toArea() {
140140
int x = getMinimumPoint().getBlockX();
141141
int z = getMinimumPoint().getBlockZ();
142-
int width = getMaximumPoint().getBlockX() - x;
143-
int height = getMaximumPoint().getBlockZ() - z;
142+
int width = getMaximumPoint().getBlockX() - x + 1;
143+
int height = getMaximumPoint().getBlockZ() - z + 1;
144144
return new Area(new Rectangle(x, z, width, height));
145145
}
146146

@@ -172,4 +172,4 @@ public int volume() {
172172
}
173173
}
174174

175-
}
175+
}

0 commit comments

Comments
 (0)