From a7b49ff79373d1671f0be988e3ad8ecc6b17e6b2 Mon Sep 17 00:00:00 2001 From: aumgn Date: Mon, 16 Apr 2012 07:41:14 +0200 Subject: [PATCH] Add minimum/maximumY to FlatRegion and fix a typo in Polygonal2DRegion --- .../com/sk89q/worldedit/regions/CuboidRegion.java | 8 ++++++++ .../com/sk89q/worldedit/regions/FlatRegion.java | 14 ++++++++++++++ .../sk89q/worldedit/regions/Polygonal2DRegion.java | 5 +++++ .../regions/Polygonal2DRegionSelector.java | 6 +++--- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 16e4028c9..2b5d2b4a6 100644 --- a/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -87,6 +87,14 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { Math.max(pos1.getZ(), pos2.getZ())); } + public int getMinimumY() { + return Math.min(pos1.getBlockX(), pos2.getBlockY()); + } + + public int getMaximumY() { + return Math.max(pos1.getBlockX(), pos2.getBlockY()); + } + /** * Get the number of blocks in the region. * diff --git a/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java b/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java index 4e131f908..1974912aa 100644 --- a/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java @@ -23,5 +23,19 @@ import com.sk89q.worldedit.Vector2D; public interface FlatRegion extends Region { + /** + * Gets the minimum Y value + * + * @return + */ + public int getMinimumY(); + + /** + * Gets the maximum Y value + * + * @return + */ + public int getMaximumY(); + public Iterable asFlatRegion(); } diff --git a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java index d5d140e5e..4bec4cd97 100644 --- a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java @@ -167,6 +167,11 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { * * @return min y */ + public int getMinimumY() { + return minY; + } + + @Deprecated public int getMininumY() { return minY; } diff --git a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java index 3f5beee25..04aeb6bf6 100644 --- a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java @@ -124,14 +124,14 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID())); session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getArea())); - session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMininumY(), region.getMaximumY())); + session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY())); } public void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector pos) { player.print("Added point #" + region.size() + " at " + pos + "."); session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea())); - session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMininumY(), region.getMaximumY())); + session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY())); } public void explainRegionAdjust(LocalPlayer player, LocalSession session) { @@ -195,7 +195,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { session.dispatchCUIEvent(player, new SelectionPoint2DEvent(id, points.get(id), getArea())); } - session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMininumY(), region.getMaximumY())); + session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY())); } public void describeLegacyCUI(LocalSession session, LocalPlayer player) {