From 5de4cfced2b24e223a833035454b38d72039a3c0 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 13 Sep 2016 09:26:23 +0200 Subject: [PATCH 1/2] Fix region contain method The region contain method was broken. A lot of subsquent issues are caused by this bug. E.g. in a selection the entities in the last blocks at the positive-axis border are not selected. Max block gives the impression of an exclusive point; however it is inclusive! A position that is anywhere between of a 1x1x1 region, would return false in the old implementation. By simply adding a one this should solve the problem. Greetings --- .../main/java/com/sk89q/worldedit/regions/CuboidRegion.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 258be2c6f..cf0a93503 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -336,9 +336,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { Vector min = getMinimumPoint(); Vector max = getMaximumPoint(); - return x >= min.getBlockX() && x <= max.getBlockX() - && y >= min.getBlockY() && y <= max.getBlockY() - && z >= min.getBlockZ() && z <= max.getBlockZ(); + return x >= min.getBlockX() && x < max.getBlockX() + 1 + && y >= min.getBlockY() && y < max.getBlockY() + 1 + && z >= min.getBlockZ() && z < max.getBlockZ() + 1; } @Override From 6c65a8a98997fb5dc464914646e8fafc58dd0f15 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 13 Sep 2016 23:13:47 +0200 Subject: [PATCH 2/2] CuboidRegion contains use block position Int casting would be better here than adding one to the max block --- .../com/sk89q/worldedit/regions/CuboidRegion.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index cf0a93503..b61651aba 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -329,16 +329,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public boolean contains(Vector position) { - double x = position.getX(); - double y = position.getY(); - double z = position.getZ(); + int x = position.getBlockX(); + int y = position.getBlockY(); + int z = position.getBlockZ(); Vector min = getMinimumPoint(); Vector max = getMaximumPoint(); - return x >= min.getBlockX() && x < max.getBlockX() + 1 - && y >= min.getBlockY() && y < max.getBlockY() + 1 - && z >= min.getBlockZ() && z < max.getBlockZ() + 1; + return x >= min.getBlockX() && x <= max.getBlockX() + && y >= min.getBlockY() && y <= max.getBlockY() + && z >= min.getBlockZ() && z <= max.getBlockZ(); } @Override