mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Added /editexpand and /editcontract.
This commit is contained in:
@ -120,6 +120,140 @@ public class CuboidRegion implements Region {
|
||||
return (int)(max.getZ() - min.getZ() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands the cuboid in a direction.
|
||||
*
|
||||
* @param change
|
||||
*/
|
||||
public void expand(Vector change) {
|
||||
if (change.getX() > 0) {
|
||||
if (Math.max(pos1.getX(), pos2.getX()) == pos1.getX()) {
|
||||
pos1 = pos1.add(new Vector(change.getX(), 0, 0));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(change.getX(), 0, 0));
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getX(), pos2.getX()) == pos1.getX()) {
|
||||
pos1 = pos1.add(new Vector(change.getX(), 0, 0));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(change.getX(), 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (change.getY() > 0) {
|
||||
if (Math.max(pos1.getY(), pos2.getY()) == pos1.getY()) {
|
||||
pos1 = pos1.add(new Vector(0, change.getY(), 0));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, change.getY(), 0));
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getY(), pos2.getY()) == pos1.getY()) {
|
||||
pos1 = pos1.add(new Vector(0, change.getY(), 0));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, change.getY(), 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (change.getZ() > 0) {
|
||||
if (Math.max(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
|
||||
pos1 = pos1.add(new Vector(0, 0, change.getZ()));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, 0, change.getZ()));
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
|
||||
pos1 = pos1.add(new Vector(0, 0, change.getZ()));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, 0, change.getZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Contracts the cuboid in a direction.
|
||||
*
|
||||
* @param change
|
||||
*/
|
||||
public void contract(Vector change) {
|
||||
if (change.getX() < 0) {
|
||||
if (Math.max(pos1.getX(), pos2.getX()) == pos1.getX()) {
|
||||
pos1 = pos1.add(new Vector(change.getX(), 0, 0));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(change.getX(), 0, 0));
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getX(), pos2.getX()) == pos1.getX()) {
|
||||
pos1 = pos1.add(new Vector(change.getX(), 0, 0));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(change.getX(), 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (change.getY() < 0) {
|
||||
if (Math.max(pos1.getY(), pos2.getY()) == pos1.getY()) {
|
||||
pos1 = pos1.add(new Vector(0, change.getY(), 0));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, change.getY(), 0));
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getY(), pos2.getY()) == pos1.getY()) {
|
||||
pos1 = pos1.add(new Vector(0, change.getY(), 0));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, change.getY(), 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (change.getZ() < 0) {
|
||||
if (Math.max(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
|
||||
pos1 = pos1.add(new Vector(0, 0, change.getZ()));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, 0, change.getZ()));
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
|
||||
pos1 = pos1.add(new Vector(0, 0, change.getZ()));
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, 0, change.getZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get position 1.
|
||||
*
|
||||
* @return position 1
|
||||
*/
|
||||
public Vector getPos1() {
|
||||
return pos1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set position 1.
|
||||
*
|
||||
* @param pos1
|
||||
*/
|
||||
public void setPos1(Vector pos1) {
|
||||
this.pos1 = pos1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get position 2.
|
||||
*
|
||||
* @return position 2
|
||||
*/
|
||||
public Vector getPos2() {
|
||||
return pos2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set position 2.
|
||||
*
|
||||
* @param pos2
|
||||
*/
|
||||
public void setPos2(Vector pos2) {
|
||||
this.pos2 = pos2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iterator.
|
||||
*
|
||||
|
@ -60,4 +60,16 @@ public interface Region extends Iterable<Vector> {
|
||||
* @return length
|
||||
*/
|
||||
public int getLength();
|
||||
/**
|
||||
* Expand the region.
|
||||
*
|
||||
* @param change
|
||||
*/
|
||||
public void expand(Vector change);
|
||||
/**
|
||||
* Contract the region.
|
||||
*
|
||||
* @param change
|
||||
*/
|
||||
public void contract(Vector change);
|
||||
}
|
||||
|
36
src/com/sk89q/worldedit/UnknownDirectionException.java
Normal file
36
src/com/sk89q/worldedit/UnknownDirectionException.java
Normal file
@ -0,0 +1,36 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class UnknownDirectionException extends WorldEditException {
|
||||
private String dir;
|
||||
|
||||
public UnknownDirectionException(String dir) {
|
||||
this.dir = dir;
|
||||
}
|
||||
|
||||
public String getDirection() {
|
||||
return dir;
|
||||
}
|
||||
}
|
@ -280,6 +280,36 @@ public class Vector {
|
||||
return new Vector(newX, newY, newZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scalar multiplication.
|
||||
*
|
||||
* @param n
|
||||
* @return New point
|
||||
*/
|
||||
public Vector multiply(double n) {
|
||||
return new Vector(this.x * n, this.y * n, this.z * n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scalar multiplication.
|
||||
*
|
||||
* @param n
|
||||
* @return New point
|
||||
*/
|
||||
public Vector multiply(float n) {
|
||||
return new Vector(this.x * n, this.y * n, this.z * n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scalar multiplication.
|
||||
*
|
||||
* @param n
|
||||
* @return New point
|
||||
*/
|
||||
public Vector multiply(int n) {
|
||||
return new Vector(this.x * n, this.y * n, this.z * n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide two points.
|
||||
*
|
||||
|
Reference in New Issue
Block a user