mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Avoid int overflow when using fillr in negative coords (#1711)
Fix int overflow when using fill and fillr in negative y-coordinates
This commit is contained in:
parent
198c6b7800
commit
32231b48fe
@ -1459,10 +1459,17 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
checkArgument(radius >= 0, "radius >= 0");
|
checkArgument(radius >= 0, "radius >= 0");
|
||||||
checkArgument(depth >= 1, "depth >= 1");
|
checkArgument(depth >= 1, "depth >= 1");
|
||||||
|
|
||||||
|
// Avoid int overflow (negative coordinate space allows for overflow back round to positive if the depth is large enough).
|
||||||
|
// Depth is always 1 or greater, thus the lower bound should always be <= origin y.
|
||||||
|
int lowerBound = origin.getBlockY() - depth + 1;
|
||||||
|
if (lowerBound > origin.getBlockY()) {
|
||||||
|
lowerBound = Integer.MIN_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
Mask mask = new MaskIntersection(
|
Mask mask = new MaskIntersection(
|
||||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||||
new BoundedHeightMask(
|
new BoundedHeightMask(
|
||||||
Math.max(origin.getBlockY() - depth + 1, minY),
|
Math.max(lowerBound, minY),
|
||||||
Math.min(maxY, origin.getBlockY())
|
Math.min(maxY, origin.getBlockY())
|
||||||
),
|
),
|
||||||
Masks.negate(new ExistingBlockMask(this))
|
Masks.negate(new ExistingBlockMask(this))
|
||||||
|
Loading…
Reference in New Issue
Block a user