From 7d44850bb06eb1c1a806ce53c1f3b0659b178bc5 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 5 Jun 2016 19:46:52 +1000 Subject: [PATCH] Mask getBlock --- .../java/com/plotsquared/listener/ProcessedWEExtent.java | 8 ++++++++ Core/src/main/java/com/plotsquared/listener/WEExtent.java | 8 ++++++++ .../src/main/java/com/plotsquared/listener/WEManager.java | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/listener/ProcessedWEExtent.java b/Core/src/main/java/com/plotsquared/listener/ProcessedWEExtent.java index 6bd48ce9f..72c6432d0 100644 --- a/Core/src/main/java/com/plotsquared/listener/ProcessedWEExtent.java +++ b/Core/src/main/java/com/plotsquared/listener/ProcessedWEExtent.java @@ -41,6 +41,14 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { this.parent = parent; } + @Override + public BaseBlock getBlock(Vector location) { + if (WEManager.maskContains(this.mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) { + return super.getBlock(location); + } + return WEManager.AIR; + } + @Override public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { int id = block.getType(); diff --git a/Core/src/main/java/com/plotsquared/listener/WEExtent.java b/Core/src/main/java/com/plotsquared/listener/WEExtent.java index 2b5170156..bd5d8b527 100644 --- a/Core/src/main/java/com/plotsquared/listener/WEExtent.java +++ b/Core/src/main/java/com/plotsquared/listener/WEExtent.java @@ -40,4 +40,12 @@ public class WEExtent extends AbstractDelegateExtent { public boolean setBiome(Vector2D position, BaseBiome biome) { return WEManager.maskContains(this.mask, position.getBlockX(), position.getBlockZ()) && super.setBiome(position, biome); } + + @Override + public BaseBlock getBlock(Vector location) { + if (WEManager.maskContains(this.mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) { + return super.getBlock(location); + } + return WEManager.AIR; + } } diff --git a/Core/src/main/java/com/plotsquared/listener/WEManager.java b/Core/src/main/java/com/plotsquared/listener/WEManager.java index 61ab3c93d..e6f7dbe6f 100644 --- a/Core/src/main/java/com/plotsquared/listener/WEManager.java +++ b/Core/src/main/java/com/plotsquared/listener/WEManager.java @@ -8,12 +8,14 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; - +import com.sk89q.worldedit.blocks.BaseBlock; import java.util.HashSet; import java.util.UUID; public class WEManager { + public static BaseBlock AIR = new BaseBlock(0, 0); + public static boolean maskContains(HashSet mask, int x, int y, int z) { for (RegionWrapper region : mask) { if (region.isIn(x, y, z)) {