mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Current progress with update
This commit is contained in:
@ -19,7 +19,9 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||
|
||||
import java.util.Map;
|
||||
@ -167,9 +169,9 @@ public final class NBTUtils {
|
||||
* @param listTag the list tag
|
||||
* @return a vector
|
||||
*/
|
||||
public static Vector toVector(ListTag listTag) {
|
||||
public static Vector3 toVector(ListTag listTag) {
|
||||
checkNotNull(listTag);
|
||||
return new Vector(listTag.asDouble(0), listTag.asDouble(1), listTag.asDouble(2));
|
||||
return new Vector3(listTag.asDouble(0), listTag.asDouble(1), listTag.asDouble(2));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package com.sk89q.util.yaml;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
@ -110,9 +110,9 @@ public class YAMLNode {
|
||||
* @return the new object
|
||||
*/
|
||||
private Object prepareSerialization(Object value) {
|
||||
if (value instanceof Vector) {
|
||||
if (value instanceof Vector3) {
|
||||
Map<String, Double> out = new LinkedHashMap<>();
|
||||
Vector vec = (Vector) value;
|
||||
Vector3 vec = (Vector3) value;
|
||||
out.put("x", vec.getX());
|
||||
out.put("y", vec.getY());
|
||||
out.put("z", vec.getZ());
|
||||
@ -200,7 +200,7 @@ public class YAMLNode {
|
||||
* @param path path to node (dot notation)
|
||||
* @return string or default
|
||||
*/
|
||||
public Vector getVector(String path) {
|
||||
public Vector3 getVector(String path) {
|
||||
YAMLNode o = getNode(path);
|
||||
if (o == null) {
|
||||
return null;
|
||||
@ -214,7 +214,7 @@ public class YAMLNode {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Vector(x, y, z);
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -225,7 +225,7 @@ public class YAMLNode {
|
||||
* @param path path to node (dot notation)
|
||||
* @return string or default
|
||||
*/
|
||||
public Vector2D getVector2d(String path) {
|
||||
public Vector2 getVector2(String path) {
|
||||
YAMLNode o = getNode(path);
|
||||
if (o == null) {
|
||||
return null;
|
||||
@ -238,7 +238,7 @@ public class YAMLNode {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Vector2D(x, z);
|
||||
return new Vector2(x, z);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,8 +250,8 @@ public class YAMLNode {
|
||||
* @param def default value
|
||||
* @return string or default
|
||||
*/
|
||||
public Vector getVector(String path, Vector def) {
|
||||
Vector v = getVector(path);
|
||||
public Vector3 getVector(String path, Vector3 def) {
|
||||
Vector3 v = getVector(path);
|
||||
if (v == null) {
|
||||
if (writeDefaults) setProperty(path, def);
|
||||
return def;
|
||||
@ -557,9 +557,9 @@ public class YAMLNode {
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
*/
|
||||
public List<Vector> getVectorList(String path, List<Vector> def) {
|
||||
public List<Vector3> getVectorList(String path, List<Vector3> def) {
|
||||
List<YAMLNode> raw = getNodeList(path, null);
|
||||
List<Vector> list = new ArrayList<>();
|
||||
List<Vector3> list = new ArrayList<>();
|
||||
|
||||
for (YAMLNode o : raw) {
|
||||
Double x = o.getDouble("x");
|
||||
@ -570,7 +570,7 @@ public class YAMLNode {
|
||||
continue;
|
||||
}
|
||||
|
||||
list.add(new Vector(x, y, z));
|
||||
list.add(new Vector3(x, y, z));
|
||||
}
|
||||
|
||||
return list;
|
||||
@ -587,10 +587,10 @@ public class YAMLNode {
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
*/
|
||||
public List<Vector2D> getVector2dList(String path, List<Vector2D> def) {
|
||||
public List<Vector2> getVector2List(String path, List<Vector2> def) {
|
||||
|
||||
List<YAMLNode> raw = getNodeList(path, null);
|
||||
List<Vector2D> list = new ArrayList<>();
|
||||
List<Vector2> list = new ArrayList<>();
|
||||
|
||||
for (YAMLNode o : raw) {
|
||||
Double x = o.getDouble("x");
|
||||
@ -600,7 +600,7 @@ public class YAMLNode {
|
||||
continue;
|
||||
}
|
||||
|
||||
list.add(new Vector2D(x, z));
|
||||
list.add(new Vector2(x, z));
|
||||
}
|
||||
|
||||
return list;
|
||||
@ -617,10 +617,10 @@ public class YAMLNode {
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
*/
|
||||
public List<BlockVector2D> getBlockVector2dList(String path, List<BlockVector2D> def) {
|
||||
public List<BlockVector2> getBlockVector2List(String path, List<BlockVector2> def) {
|
||||
|
||||
List<YAMLNode> raw = getNodeList(path, null);
|
||||
List<BlockVector2D> list = new ArrayList<>();
|
||||
List<BlockVector2> list = new ArrayList<>();
|
||||
|
||||
for (YAMLNode o : raw) {
|
||||
Double x = o.getDouble("x");
|
||||
@ -630,7 +630,7 @@ public class YAMLNode {
|
||||
continue;
|
||||
}
|
||||
|
||||
list.add(new BlockVector2D(x, z));
|
||||
list.add(new BlockVector2(x, z));
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -1,120 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Extension of {@code Vector} that that compares with other instances
|
||||
* using integer components.
|
||||
*/
|
||||
public class BlockVector extends Vector {
|
||||
|
||||
public static final BlockVector ZERO = new BlockVector(0, 0, 0);
|
||||
public static final BlockVector UNIT_X = new BlockVector(1, 0, 0);
|
||||
public static final BlockVector UNIT_Y = new BlockVector(0, 1, 0);
|
||||
public static final BlockVector UNIT_Z = new BlockVector(0, 0, 1);
|
||||
public static final BlockVector ONE = new BlockVector(1, 1, 1);
|
||||
|
||||
/**
|
||||
* Construct an instance as a copy of another instance.
|
||||
*
|
||||
* @param position the other position
|
||||
*/
|
||||
public BlockVector(Vector position) {
|
||||
this(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public BlockVector(int x, int y, int z) {
|
||||
super(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public BlockVector(float x, float y, float z) {
|
||||
this((int) x, (int) y, (int) z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public BlockVector(double x, double y, double z) {
|
||||
this((int) x, (int) y, (int) z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Vector)) {
|
||||
return false;
|
||||
}
|
||||
Vector other = (Vector) obj;
|
||||
return (int) other.getX() == (int) this.getX() && (int) other.getY() == (int) this.getY()
|
||||
&& (int) other.getZ() == (int) this.getZ();
|
||||
|
||||
}
|
||||
|
||||
public boolean equals(BlockVector obj) {
|
||||
return obj.getBlockX() == this.getBlockX() && obj.getBlockY() == this.getBlockY() && obj.getBlockZ() == this.getBlockZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ((int) getX() ^ ((int) getZ() << 16)) ^ ((int) getY() << 30);
|
||||
}
|
||||
|
||||
private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
|
||||
if (!(this instanceof MutableBlockVector)) {
|
||||
stream.writeInt(getBlockX());
|
||||
stream.writeInt(getBlockY());
|
||||
stream.writeInt(getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
if (this instanceof MutableBlockVector) return;
|
||||
this.setComponents(stream.readInt(), stream.readInt(), stream.readInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector toBlockVector() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + getBlockX() + ", " + getBlockY() + ", " + getBlockZ() + ")";
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
/**
|
||||
* Extension of {@code Vector2D} that that compares with other instances
|
||||
* using integer components.
|
||||
*/
|
||||
public class BlockVector2D extends Vector2D {
|
||||
|
||||
public static final BlockVector2D ZERO = new BlockVector2D(0, 0);
|
||||
public static final BlockVector2D UNIT_X = new BlockVector2D(1, 0);
|
||||
public static final BlockVector2D UNIT_Z = new BlockVector2D(0, 1);
|
||||
public static final BlockVector2D ONE = new BlockVector2D(1, 1);
|
||||
|
||||
/**
|
||||
* Construct an instance from another instance.
|
||||
*
|
||||
* @param position the position to copy
|
||||
*/
|
||||
public BlockVector2D(Vector2D position) {
|
||||
this(position.getBlockX(), position.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public BlockVector2D(int x, int z) {
|
||||
super(x, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public BlockVector2D(float x, float z) {
|
||||
this((int) x, (int) z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public BlockVector2D(double x, double z) {
|
||||
this((int) x, (int) z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ((int) x << 16) ^ (int) z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Vector2D)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2D other = (Vector2D) obj;
|
||||
return (int) other.x == (int) this.x && (int) other.z == (int) this.z;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector2D toBlockVector2D() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -55,6 +55,8 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
||||
import com.sk89q.worldedit.internal.cui.ServerCUIHandler;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
@ -128,12 +130,12 @@ public class LocalSession implements TextureHolder {
|
||||
private transient TextureUtil texture;
|
||||
private transient ResettableExtent transform = null;
|
||||
private transient TimeZone timezone = TimeZone.getDefault();
|
||||
|
||||
private transient World currentWorld;
|
||||
private transient UUID uuid;
|
||||
private transient volatile long historySize = 0;
|
||||
|
||||
private transient VirtualWorld virtual;
|
||||
private transient BlockVector3 cuiTemporaryBlock;
|
||||
|
||||
// Saved properties
|
||||
private String lastScript;
|
||||
@ -870,10 +872,10 @@ public class LocalSession implements TextureHolder {
|
||||
* @return the position to use
|
||||
* @throws IncompleteRegionException thrown if a region is not fully selected
|
||||
*/
|
||||
public Vector getPlacementPosition(Player player) throws IncompleteRegionException {
|
||||
public BlockVector3 getPlacementPosition(Player player) throws IncompleteRegionException {
|
||||
checkNotNull(player);
|
||||
if (!placeAtPos1) {
|
||||
return player.getBlockIn();
|
||||
return player.getBlockIn().toVector().toBlockPoint();
|
||||
}
|
||||
|
||||
return selector.getPrimaryPosition();
|
||||
@ -1105,6 +1107,60 @@ public class LocalSession implements TextureHolder {
|
||||
public void tellVersion(Actor player) {
|
||||
}
|
||||
|
||||
|
||||
public boolean shouldUseServerCUI() {
|
||||
return this.useServerCUI;
|
||||
}
|
||||
|
||||
public void setUseServerCUI(boolean useServerCUI) {
|
||||
this.useServerCUI = useServerCUI;
|
||||
setDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update server-side WorldEdit CUI.
|
||||
*
|
||||
* @param actor The player
|
||||
*/
|
||||
public void updateServerCUI(Actor actor) {
|
||||
if (!actor.isPlayer()) {
|
||||
return; // This is for players only.
|
||||
}
|
||||
|
||||
if (!config.serverSideCUI) {
|
||||
return; // Disabled in config.
|
||||
}
|
||||
|
||||
Player player = (Player) actor;
|
||||
|
||||
if (!useServerCUI || hasCUISupport) {
|
||||
if (cuiTemporaryBlock != null) {
|
||||
player.sendFakeBlock(cuiTemporaryBlock, null);
|
||||
cuiTemporaryBlock = null;
|
||||
}
|
||||
return; // If it's not enabled, ignore this.
|
||||
}
|
||||
|
||||
// Remove the old block.
|
||||
if (cuiTemporaryBlock != null) {
|
||||
player.sendFakeBlock(cuiTemporaryBlock, null);
|
||||
cuiTemporaryBlock = null;
|
||||
}
|
||||
|
||||
BaseBlock block = ServerCUIHandler.createStructureBlock(player);
|
||||
if (block != null) {
|
||||
// If it's null, we don't need to do anything. The old was already removed.
|
||||
Map<String, Tag> tags = block.getNbtData().getValue();
|
||||
cuiTemporaryBlock = new BlockVector3(
|
||||
((IntTag) tags.get("x")).getValue(),
|
||||
((IntTag) tags.get("y")).getValue(),
|
||||
((IntTag) tags.get("z")).getValue()
|
||||
);
|
||||
|
||||
player.sendFakeBlock(cuiTemporaryBlock, block);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a CUI event but only if the actor has CUI support.
|
||||
*
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
|
||||
/**
|
||||
@ -28,26 +29,26 @@ import com.sk89q.worldedit.util.Direction;
|
||||
*/
|
||||
public enum PlayerDirection {
|
||||
|
||||
NORTH(new Vector(0, 0, -1), true),
|
||||
NORTH_EAST((new Vector(1, 0, -1)).normalize(), false),
|
||||
EAST(new Vector(1, 0, 0), true),
|
||||
SOUTH_EAST((new Vector(1, 0, 1)).normalize(), false),
|
||||
SOUTH(new Vector(0, 0, 1), true),
|
||||
SOUTH_WEST((new Vector(-1, 0, 1)).normalize(), false),
|
||||
WEST(new Vector(-1, 0, 0), true),
|
||||
NORTH_WEST((new Vector(-1, 0, -1)).normalize(), false),
|
||||
UP(new Vector(0, 1, 0), true),
|
||||
DOWN(new Vector(0, -1, 0), true);
|
||||
NORTH(new Vector3(0, 0, -1), true),
|
||||
NORTH_EAST((new Vector3(1, 0, -1)).normalize(), false),
|
||||
EAST(new Vector3(1, 0, 0), true),
|
||||
SOUTH_EAST((new Vector3(1, 0, 1)).normalize(), false),
|
||||
SOUTH(new Vector3(0, 0, 1), true),
|
||||
SOUTH_WEST((new Vector3(-1, 0, 1)).normalize(), false),
|
||||
WEST(new Vector3(-1, 0, 0), true),
|
||||
NORTH_WEST((new Vector3(-1, 0, -1)).normalize(), false),
|
||||
UP(new Vector3(0, 1, 0), true),
|
||||
DOWN(new Vector3(0, -1, 0), true);
|
||||
|
||||
private final Vector dir;
|
||||
private final Vector3 dir;
|
||||
private final boolean isOrthogonal;
|
||||
|
||||
PlayerDirection(Vector vec, boolean isOrthogonal) {
|
||||
PlayerDirection(Vector3 vec, boolean isOrthogonal) {
|
||||
this.dir = vec;
|
||||
this.isOrthogonal = isOrthogonal;
|
||||
}
|
||||
|
||||
public Vector vector() {
|
||||
public Vector3 vector() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
@ -1,915 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An immutable 3-dimensional vector.
|
||||
*/
|
||||
public class Vector extends Vector2D implements Comparable<Vector>, Serializable {
|
||||
|
||||
public static final Vector ZERO = new Vector(0, 0, 0);
|
||||
public static final Vector UNIT_X = new Vector(1, 0, 0);
|
||||
public static final Vector UNIT_Y = new Vector(0, 1, 0);
|
||||
public static final Vector UNIT_Z = new Vector(0, 0, 1);
|
||||
public static final Vector ONE = new Vector(1, 1, 1);
|
||||
|
||||
private transient double y;
|
||||
|
||||
/**
|
||||
* Construct an instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public Vector(double x, double y, double z) {
|
||||
this.mutX(x);
|
||||
this.mutY(y);
|
||||
this.mutZ(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public Vector(int x, int y, int z) {
|
||||
this.mutX(x);
|
||||
this.mutY(y);
|
||||
this.mutZ(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public Vector(float x, float y, float z) {
|
||||
this.mutX(x);
|
||||
this.mutY(y);
|
||||
this.mutZ(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy another vector.
|
||||
*
|
||||
* @param other another vector to make a copy of
|
||||
*/
|
||||
public Vector(Vector other) {
|
||||
this.mutX(other.getX());
|
||||
this.mutY(other.getY());
|
||||
this.mutZ(other.getZ());
|
||||
}
|
||||
|
||||
public Vector(double[] arr) {
|
||||
this.mutX(arr[0]);
|
||||
this.mutY(arr[1]);
|
||||
this.mutZ(arr[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance with X, Y, and Z coordinates set to 0.
|
||||
* <p>
|
||||
* <p>One can also refer to a static {@link #ZERO}.</p>
|
||||
*/
|
||||
public Vector() {
|
||||
this.mutX(0);
|
||||
this.mutY(0);
|
||||
this.mutZ(0);
|
||||
}
|
||||
|
||||
public Vector setComponents(int x, int y, int z) {
|
||||
this.mutX(x);
|
||||
this.mutY(y);
|
||||
this.mutZ(z);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector setComponents(double x, double y, double z) {
|
||||
this.mutX(x);
|
||||
this.mutY(y);
|
||||
this.mutZ(z);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void mutX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void mutY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void mutZ(int z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void mutX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void mutY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void mutZ(double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
*/
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate rounded.
|
||||
*
|
||||
* @return the x coordinate
|
||||
*/
|
||||
public int getBlockX() {
|
||||
return MathMan.roundInt(getX());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the X coordinate.
|
||||
*
|
||||
* @param x the new X
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector setX(double x) {
|
||||
return new Vector(x, getY(), getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the X coordinate.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @return new vector
|
||||
*/
|
||||
public Vector setX(int x) {
|
||||
return new Vector(x, getY(), getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Y coordinate.
|
||||
*
|
||||
* @return the y coordinate
|
||||
*/
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Y coordinate rounded.
|
||||
*
|
||||
* @return the y coordinate
|
||||
*/
|
||||
public int getBlockY() {
|
||||
return MathMan.roundInt(getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Y coordinate.
|
||||
*
|
||||
* @param y the new Y
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector setY(double y) {
|
||||
return new Vector(getX(), y, getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Y coordinate.
|
||||
*
|
||||
* @param y the new Y
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector setY(int y) {
|
||||
return new Vector(getX(), y, getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
*/
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate rounded.
|
||||
*
|
||||
* @return the z coordinate
|
||||
*/
|
||||
public int getBlockZ() {
|
||||
return MathMan.roundInt(getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Z coordinate.
|
||||
*
|
||||
* @param z the new Z
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector setZ(double z) {
|
||||
return new Vector(getX(), getY(), z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Z coordinate.
|
||||
*
|
||||
* @param z the new Z
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector setZ(int z) {
|
||||
return new Vector(getX(), getY(), z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another vector to this vector and return the result as a new vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector add(Vector other) {
|
||||
return new Vector(getX() + other.getX(), getY() + other.getY(), getZ() + other.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another vector to this vector and return the result as a new vector.
|
||||
*
|
||||
* @param x the value to add
|
||||
* @param y the value to add
|
||||
* @param z the value to add
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector add(double x, double y, double z) {
|
||||
return new Vector(this.getX() + x, this.getY() + y, this.getZ() + z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another vector to this vector and return the result as a new vector.
|
||||
*
|
||||
* @param x the value to add
|
||||
* @param y the value to add
|
||||
* @param z the value to add
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector add(int x, int y, int z) {
|
||||
return new Vector(this.getX() + x, this.getY() + y, this.getZ() + z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a list of vectors to this vector and return the
|
||||
* result as a new vector.
|
||||
*
|
||||
* @param others an array of vectors
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector add(Vector... others) {
|
||||
double newX = getX(), newY = getY(), newZ = getZ();
|
||||
|
||||
for (Vector other : others) {
|
||||
newX += other.getX();
|
||||
newY += other.getY();
|
||||
newZ += other.getZ();
|
||||
}
|
||||
|
||||
return new Vector(newX, newY, newZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract another vector from this vector and return the result
|
||||
* as a new vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector subtract(Vector other) {
|
||||
return new Vector(getX() - other.getX(), getY() - other.getY(), getZ() - other.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract another vector from this vector and return the result
|
||||
* as a new vector.
|
||||
*
|
||||
* @param x the value to subtract
|
||||
* @param y the value to subtract
|
||||
* @param z the value to subtract
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector subtract(double x, double y, double z) {
|
||||
return new Vector(this.getX() - x, this.getY() - y, this.getZ() - z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract another vector from this vector and return the result
|
||||
* as a new vector.
|
||||
*
|
||||
* @param x the value to subtract
|
||||
* @param y the value to subtract
|
||||
* @param z the value to subtract
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector subtract(int x, int y, int z) {
|
||||
return new Vector(this.getX() - x, this.getY() - y, this.getZ() - z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract a list of vectors from this vector and return the result
|
||||
* as a new vector.
|
||||
*
|
||||
* @param others an array of vectors
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector subtract(Vector... others) {
|
||||
double newX = getX(), newY = getY(), newZ = getZ();
|
||||
|
||||
for (Vector other : others) {
|
||||
newX -= other.getX();
|
||||
newY -= other.getY();
|
||||
newZ -= other.getZ();
|
||||
}
|
||||
|
||||
return new Vector(newX, newY, newZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by another vector on each component.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector multiply(Vector other) {
|
||||
return new Vector(getX() * other.getX(), getY() * other.getY(), getZ() * other.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by another vector on each component.
|
||||
*
|
||||
* @param x the value to multiply
|
||||
* @param y the value to multiply
|
||||
* @param z the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector multiply(double x, double y, double z) {
|
||||
return new Vector(this.getX() * x, this.getY() * y, this.getZ() * z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by another vector on each component.
|
||||
*
|
||||
* @param x the value to multiply
|
||||
* @param y the value to multiply
|
||||
* @param z the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector multiply(int x, int y, int z) {
|
||||
return new Vector(this.getX() * x, this.getY() * y, this.getZ() * z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by zero or more vectors on each component.
|
||||
*
|
||||
* @param others an array of vectors
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector multiply(Vector... others) {
|
||||
double newX = getX(), newY = getY(), newZ = getZ();
|
||||
|
||||
for (Vector other : others) {
|
||||
newX *= other.getX();
|
||||
newY *= other.getY();
|
||||
newZ *= other.getZ();
|
||||
}
|
||||
|
||||
return new Vector(newX, newY, newZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar multiplication and return a new vector.
|
||||
*
|
||||
* @param n the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector multiply(double n) {
|
||||
return new Vector(this.getX() * n, this.getY() * n, this.getZ() * n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar multiplication and return a new vector.
|
||||
*
|
||||
* @param n the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector multiply(float n) {
|
||||
return new Vector(this.getX() * n, this.getY() * n, this.getZ() * n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar multiplication and return a new vector.
|
||||
*
|
||||
* @param n the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector multiply(int n) {
|
||||
return new Vector(this.getX() * n, this.getY() * n, this.getZ() * n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by another vector on each component.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector divide(Vector other) {
|
||||
return new Vector(getX() / other.getX(), getY() / other.getY(), getZ() / other.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by another vector on each component.
|
||||
*
|
||||
* @param x the value to divide by
|
||||
* @param y the value to divide by
|
||||
* @param z the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector divide(double x, double y, double z) {
|
||||
return new Vector(this.getX() / x, this.getY() / y, this.getZ() / z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by another vector on each component.
|
||||
*
|
||||
* @param x the value to divide by
|
||||
* @param y the value to divide by
|
||||
* @param z the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector divide(int x, int y, int z) {
|
||||
return new Vector(this.getX() / x, this.getY() / y, this.getZ() / z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar division and return a new vector.
|
||||
*
|
||||
* @param n the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector divide(int n) {
|
||||
return new Vector(getX() / n, getY() / n, getZ() / n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar division and return a new vector.
|
||||
*
|
||||
* @param n the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector divide(double n) {
|
||||
return new Vector(getX() / n, getY() / n, getZ() / n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar division and return a new vector.
|
||||
*
|
||||
* @param n the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector divide(float n) {
|
||||
return new Vector(getX() / n, getY() / n, getZ() / n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the vector.
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public double length() {
|
||||
return Math.sqrt(getX() * getX() + getY() * getY() + getZ() * getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length, squared, of the vector.
|
||||
*
|
||||
* @return length, squared
|
||||
*/
|
||||
public double lengthSq() {
|
||||
return getX() * getX() + getY() * getY() + getZ() * getZ();
|
||||
}
|
||||
|
||||
public double volume() {
|
||||
return getX() * getY() * getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between this vector and another vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return distance
|
||||
*/
|
||||
public double distance(Vector other) {
|
||||
return Math.sqrt(Math.pow(other.getX() - getX(), 2) +
|
||||
Math.pow(other.getY() - getY(), 2) +
|
||||
Math.pow(other.getZ() - getZ(), 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between this vector and another vector, squared.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return distance
|
||||
*/
|
||||
public double distanceSq(Vector other) {
|
||||
return Math.pow(other.getX() - getX(), 2) +
|
||||
Math.pow(other.getY() - getY(), 2) +
|
||||
Math.pow(other.getZ() - getZ(), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the normalized vector, which is the vector divided by its
|
||||
* length, as a new vector.
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector normalize() {
|
||||
return divide(length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dot product of this and another vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return the dot product of this and the other vector
|
||||
*/
|
||||
public double dot(Vector other) {
|
||||
return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cross product of this and another vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return the cross product of this and the other vector
|
||||
*/
|
||||
public Vector cross(Vector other) {
|
||||
return new Vector(
|
||||
getY() * other.getZ() - getZ() * other.getY(),
|
||||
getZ() * other.getX() - getX() * other.getZ(),
|
||||
getX() * other.getY() - getY() * other.getX()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a vector is contained with another.
|
||||
*
|
||||
* @param min the minimum point (X, Y, and Z are the lowest)
|
||||
* @param max the maximum point (X, Y, and Z are the lowest)
|
||||
* @return true if the vector is contained
|
||||
*/
|
||||
public boolean containedWithin(Vector min, Vector max) {
|
||||
return getX() >= min.getX() && getX() <= max.getX() && getY() >= min.getY() && getY() <= max.getY() && getZ() >= min.getZ() && getZ() <= max.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a vector is contained with another, comparing
|
||||
* using discrete comparisons, inclusively.
|
||||
*
|
||||
* @param min the minimum point (X, Y, and Z are the lowest)
|
||||
* @param max the maximum point (X, Y, and Z are the lowest)
|
||||
* @return true if the vector is contained
|
||||
*/
|
||||
public boolean containedWithinBlock(Vector min, Vector max) {
|
||||
return getBlockX() >= min.getBlockX() && getBlockX() <= max.getBlockX()
|
||||
&& getBlockY() >= min.getBlockY() && getBlockY() <= max.getBlockY()
|
||||
&& getBlockZ() >= min.getBlockZ() && getBlockZ() <= max.getBlockZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp the Y component.
|
||||
*
|
||||
* @param min the minimum value
|
||||
* @param max the maximum value
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector clampY(int min, int max) {
|
||||
return new Vector(getX(), Math.max(min, Math.min(max, getY())), getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Floors the values of all components.
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector floor() {
|
||||
return new Vector(Math.floor(getX()), Math.floor(getY()), Math.floor(getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounds all components up.
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector ceil() {
|
||||
return new Vector(Math.ceil(getX()), Math.ceil(getY()), Math.ceil(getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounds all components to the closest integer.
|
||||
* <p>
|
||||
* <p>Components < 0.5 are rounded down, otherwise up.</p>
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector round() {
|
||||
return new Vector(Math.floor(getX() + 0.5), Math.floor(getY() + 0.5), Math.floor(getZ() + 0.5));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a vector with the absolute values of the components of
|
||||
* this vector.
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector positive() {
|
||||
return new Vector(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a 2D transformation on this vector and return a new one.
|
||||
*
|
||||
* @param angle in degrees
|
||||
* @param aboutX about which x coordinate to rotate
|
||||
* @param aboutZ about which z coordinate to rotate
|
||||
* @param translateX what to add after rotation
|
||||
* @param translateZ what to add after rotation
|
||||
* @return a new vector
|
||||
* @see AffineTransform another method to transform vectors
|
||||
*/
|
||||
public Vector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
||||
angle = Math.toRadians(angle);
|
||||
double x = this.getX() - aboutX;
|
||||
double z = this.getZ() - aboutZ;
|
||||
double x2 = x * Math.cos(angle) - z * Math.sin(angle);
|
||||
double z2 = x * Math.sin(angle) + z * Math.cos(angle);
|
||||
|
||||
return new Vector(
|
||||
x2 + aboutX + translateX,
|
||||
getY(),
|
||||
z2 + aboutZ + translateZ
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this vector is collinear with another vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return true if collinear
|
||||
*/
|
||||
public boolean isCollinearWith(Vector other) {
|
||||
if (getX() == 0 && getY() == 0 && getZ() == 0) {
|
||||
// this is a zero vector
|
||||
return true;
|
||||
}
|
||||
|
||||
final double otherX = other.getX();
|
||||
final double otherY = other.getY();
|
||||
final double otherZ = other.getZ();
|
||||
|
||||
if (otherX == 0 && otherY == 0 && otherZ == 0) {
|
||||
// other is a zero vector
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((getX() == 0) != (otherX == 0)) return false;
|
||||
if ((getY() == 0) != (otherY == 0)) return false;
|
||||
if ((getZ() == 0) != (otherZ == 0)) return false;
|
||||
|
||||
final double quotientX = otherX / getX();
|
||||
if (!Double.isNaN(quotientX)) {
|
||||
return other.equals(multiply(quotientX));
|
||||
}
|
||||
|
||||
final double quotientY = otherY / getY();
|
||||
if (!Double.isNaN(quotientY)) {
|
||||
return other.equals(multiply(quotientY));
|
||||
}
|
||||
|
||||
final double quotientZ = otherZ / getZ();
|
||||
if (!Double.isNaN(quotientZ)) {
|
||||
return other.equals(multiply(quotientZ));
|
||||
}
|
||||
|
||||
throw new RuntimeException("This should not happen");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this vector's pitch as used within the game.
|
||||
*
|
||||
* @return pitch in radians
|
||||
*/
|
||||
public float toPitch() {
|
||||
double x = getX();
|
||||
double z = getZ();
|
||||
|
||||
if (x == 0 && z == 0) {
|
||||
return getY() > 0 ? -90 : 90;
|
||||
} else {
|
||||
double x2 = x * x;
|
||||
double z2 = z * z;
|
||||
double xz = Math.sqrt(x2 + z2);
|
||||
return (float) Math.toDegrees(Math.atan(-getY() / xz));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this vector's yaw as used within the game.
|
||||
*
|
||||
* @return yaw in radians
|
||||
*/
|
||||
public float toYaw() {
|
||||
double x = getX();
|
||||
double z = getZ();
|
||||
|
||||
double t = Math.atan2(-x, z);
|
||||
double _2pi = 2 * Math.PI;
|
||||
|
||||
return (float) Math.toDegrees(((t + _2pi) % _2pi));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code BlockVector} using the given components.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
* @return a new {@code BlockVector}
|
||||
*/
|
||||
public static BlockVector toBlockPoint(double x, double y, double z) {
|
||||
return new BlockVector(
|
||||
Math.floor(x),
|
||||
Math.floor(y),
|
||||
Math.floor(z)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code BlockVector} from this vector.
|
||||
*
|
||||
* @return a new {@code BlockVector}
|
||||
*/
|
||||
public BlockVector toBlockPoint() {
|
||||
return new BlockVector(
|
||||
Math.floor(getX()),
|
||||
Math.floor(getY()),
|
||||
Math.floor(getZ())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code BlockVector} from this vector.
|
||||
*
|
||||
* @return a new {@code BlockVector}
|
||||
*/
|
||||
public BlockVector toBlockVector() {
|
||||
return new BlockVector(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a 2D vector by dropping the Y component from this vector.
|
||||
*
|
||||
* @return a new {@code Vector2D}
|
||||
*/
|
||||
public Vector2D toVector2D() {
|
||||
return new Vector2D(getX(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (!(obj instanceof Vector)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector other = (Vector) obj;
|
||||
return other.getX() == this.getX() && other.getZ() == this.getZ() && other.getY() == this.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@Nullable Vector other) {
|
||||
if (other == null) {
|
||||
throw new IllegalArgumentException("null not supported");
|
||||
}
|
||||
if (getY() != other.getY()) return Double.compare(getY(), other.getY());
|
||||
if (getZ() != other.getZ()) return Double.compare(getZ(), other.getZ());
|
||||
if (getX() != other.getX()) return Double.compare(getX(), other.getX());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ((int) getX() ^ ((int) getZ() << 16)) ^ ((int) getY() << 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String x = (getX() == getBlockX() ? "" + getBlockX() : "" + getX());
|
||||
String y = (getY() == getBlockY() ? "" + getBlockY() : "" + getY());
|
||||
String z = (getZ() == getBlockZ() ? "" + getBlockZ() : "" + getZ());
|
||||
return "(" + x + ", " + y + ", " + z + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minimum components of two vectors.
|
||||
*
|
||||
* @param v1 the first vector
|
||||
* @param v2 the second vector
|
||||
* @return minimum
|
||||
*/
|
||||
public static Vector getMinimum(Vector v1, Vector v2) {
|
||||
return new Vector(
|
||||
Math.min(v1.getX(), v2.getX()),
|
||||
Math.min(v1.getY(), v2.getY()),
|
||||
Math.min(v1.getZ(), v2.getZ())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum components of two vectors.
|
||||
*
|
||||
* @param v1 the first vector
|
||||
* @param v2 the second vector
|
||||
* @return maximum
|
||||
*/
|
||||
public static Vector getMaximum(Vector v1, Vector v2) {
|
||||
return new Vector(
|
||||
Math.max(v1.getX(), v2.getX()),
|
||||
Math.max(v1.getY(), v2.getY()),
|
||||
Math.max(v1.getZ(), v2.getZ())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the midpoint of two vectors.
|
||||
*
|
||||
* @param v1 the first vector
|
||||
* @param v2 the second vector
|
||||
* @return maximum
|
||||
*/
|
||||
public static Vector getMidpoint(Vector v1, Vector v2) {
|
||||
return new Vector(
|
||||
(v1.getX() + v2.getX()) / 2,
|
||||
(v1.getY() + v2.getY()) / 2,
|
||||
(v1.getZ() + v2.getZ()) / 2
|
||||
);
|
||||
}
|
||||
|
||||
private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
|
||||
if (!(this instanceof MutableBlockVector)) {
|
||||
stream.writeDouble(x);
|
||||
stream.writeDouble(y);
|
||||
stream.writeDouble(z);
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
if (this instanceof MutableBlockVector) return;
|
||||
this.x = stream.readDouble();
|
||||
this.y = stream.readDouble();
|
||||
this.z = stream.readDouble();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,681 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An immutable 2-dimensional vector.
|
||||
*/
|
||||
public class Vector2D implements Serializable {
|
||||
public static final Vector2D ZERO = new Vector2D(0, 0);
|
||||
public static final Vector2D UNIT_X = new Vector2D(1, 0);
|
||||
public static final Vector2D UNIT_Z = new Vector2D(0, 1);
|
||||
public static final Vector2D ONE = new Vector2D(1, 1);
|
||||
|
||||
public transient double x, z;
|
||||
|
||||
/**
|
||||
* Construct an instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public Vector2D(double x, double z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public Vector2D(int x, int z) {
|
||||
this.x = (double) x;
|
||||
this.z = (double) z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public Vector2D(float x, float z) {
|
||||
this.x = (double) x;
|
||||
this.z = (double) z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy another vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
*/
|
||||
public Vector2D(Vector2D other) {
|
||||
this.x = other.getX();
|
||||
this.z = other.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance with X and Z coordinates set to 0.
|
||||
* <p>
|
||||
* <p>One can also refer to a static {@link #ZERO}.</p>
|
||||
*/
|
||||
public Vector2D() {
|
||||
this.x = 0;
|
||||
this.z = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
*/
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate rounded.
|
||||
*
|
||||
* @return the x coordinate
|
||||
*/
|
||||
public int getBlockX() {
|
||||
return MathMan.roundInt(getX());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the X coordinate.
|
||||
*
|
||||
* @param x the new X
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D setX(double x) {
|
||||
return new Vector2D(x, getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the X coordinate.
|
||||
*
|
||||
* @param x the new X
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D setX(int x) {
|
||||
return new Vector2D(x, getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
*/
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate rounded.
|
||||
*
|
||||
* @return the z coordinate
|
||||
*/
|
||||
public int getBlockZ() {
|
||||
return MathMan.roundInt(getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Z coordinate.
|
||||
*
|
||||
* @param z the new Z
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D setZ(double z) {
|
||||
return new Vector2D(getX(), z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Z coordinate.
|
||||
*
|
||||
* @param z the new Z
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D setZ(int z) {
|
||||
return new Vector2D(getX(), z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another vector to this vector and return the result as a new vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D add(Vector2D other) {
|
||||
return new Vector2D(getX() + other.getX(), getZ() + other.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another vector to this vector and return the result as a new vector.
|
||||
*
|
||||
* @param x the value to add
|
||||
* @param z the value to add
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D add(double x, double z) {
|
||||
return new Vector2D(this.getX() + x, this.getZ() + z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another vector to this vector and return the result as a new vector.
|
||||
*
|
||||
* @param x the value to add
|
||||
* @param z the value to add
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D add(int x, int z) {
|
||||
return new Vector2D(this.getX() + x, this.getZ() + z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a list of vectors to this vector and return the
|
||||
* result as a new vector.
|
||||
*
|
||||
* @param others an array of vectors
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D add(Vector2D... others) {
|
||||
double newX = getX(), newZ = getZ();
|
||||
|
||||
for (Vector2D other : others) {
|
||||
newX += other.getX();
|
||||
newZ += other.getZ();
|
||||
}
|
||||
|
||||
return new Vector2D(newX, newZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract another vector from this vector and return the result
|
||||
* as a new vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D subtract(Vector2D other) {
|
||||
return new Vector2D(getX() - other.getX(), getZ() - other.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract another vector from this vector and return the result
|
||||
* as a new vector.
|
||||
*
|
||||
* @param x the value to subtract
|
||||
* @param z the value to subtract
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D subtract(double x, double z) {
|
||||
return new Vector2D(this.getX() - x, this.getZ() - z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract another vector from this vector and return the result
|
||||
* as a new vector.
|
||||
*
|
||||
* @param x the value to subtract
|
||||
* @param z the value to subtract
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D subtract(int x, int z) {
|
||||
return new Vector2D(this.getX() - x, this.getZ() - z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract a list of vectors from this vector and return the result
|
||||
* as a new vector.
|
||||
*
|
||||
* @param others an array of vectors
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D subtract(Vector2D... others) {
|
||||
double newX = getX(), newZ = getZ();
|
||||
|
||||
for (Vector2D other : others) {
|
||||
newX -= other.getX();
|
||||
newZ -= other.getZ();
|
||||
}
|
||||
|
||||
return new Vector2D(newX, newZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by another vector on each component.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D multiply(Vector2D other) {
|
||||
return new Vector2D(getX() * other.getX(), getZ() * other.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by another vector on each component.
|
||||
*
|
||||
* @param x the value to multiply
|
||||
* @param z the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D multiply(double x, double z) {
|
||||
return new Vector2D(this.getX() * x, this.getZ() * z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by another vector on each component.
|
||||
*
|
||||
* @param x the value to multiply
|
||||
* @param z the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D multiply(int x, int z) {
|
||||
return new Vector2D(this.getX() * x, this.getZ() * z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by zero or more vectors on each component.
|
||||
*
|
||||
* @param others an array of vectors
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D multiply(Vector2D... others) {
|
||||
double newX = getX(), newZ = getZ();
|
||||
|
||||
for (Vector2D other : others) {
|
||||
newX *= other.getX();
|
||||
newZ *= other.getZ();
|
||||
}
|
||||
|
||||
return new Vector2D(newX, newZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar multiplication and return a new vector.
|
||||
*
|
||||
* @param n the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D multiply(double n) {
|
||||
return new Vector2D(this.getX() * n, this.getZ() * n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar multiplication and return a new vector.
|
||||
*
|
||||
* @param n the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D multiply(float n) {
|
||||
return new Vector2D(this.getX() * n, this.getZ() * n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar multiplication and return a new vector.
|
||||
*
|
||||
* @param n the value to multiply
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D multiply(int n) {
|
||||
return new Vector2D(this.getX() * n, this.getZ() * n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by another vector on each component.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D divide(Vector2D other) {
|
||||
return new Vector2D(getX() / other.getX(), getZ() / other.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by another vector on each component.
|
||||
*
|
||||
* @param x the value to divide by
|
||||
* @param z the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D divide(double x, double z) {
|
||||
return new Vector2D(this.getX() / x, this.getZ() / z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by another vector on each component.
|
||||
*
|
||||
* @param x the value to divide by
|
||||
* @param z the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D divide(int x, int z) {
|
||||
return new Vector2D(this.getX() / x, this.getZ() / z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar division and return a new vector.
|
||||
*
|
||||
* @param n the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D divide(int n) {
|
||||
return new Vector2D(getX() / n, getZ() / n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar division and return a new vector.
|
||||
*
|
||||
* @param n the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D divide(double n) {
|
||||
return new Vector2D(getX() / n, getZ() / n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform scalar division and return a new vector.
|
||||
*
|
||||
* @param n the value to divide by
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D divide(float n) {
|
||||
return new Vector2D(getX() / n, getZ() / n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the vector.
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public double length() {
|
||||
return Math.sqrt(getX() * getX() + getZ() * getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length, squared, of the vector.
|
||||
*
|
||||
* @return length, squared
|
||||
*/
|
||||
public double lengthSq() {
|
||||
return getX() * getX() + getZ() * getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between this vector and another vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return distance
|
||||
*/
|
||||
public double distance(Vector2D other) {
|
||||
return Math.sqrt(Math.pow(other.getX() - getX(), 2) + Math.pow(other.getZ() - getZ(), 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between this vector and another vector, squared.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return distance
|
||||
*/
|
||||
public double distanceSq(Vector2D other) {
|
||||
return Math.pow(other.getX() - getX(), 2) +
|
||||
Math.pow(other.getZ() - getZ(), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the normalized vector, which is the vector divided by its
|
||||
* length, as a new vector.
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D normalize() {
|
||||
return divide(length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dot product of this and another vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return the dot product of this and the other vector
|
||||
*/
|
||||
public double dot(Vector2D other) {
|
||||
return getX() * other.getX() + getZ() * other.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a vector is contained with another.
|
||||
*
|
||||
* @param min the minimum point (X, Y, and Z are the lowest)
|
||||
* @param max the maximum point (X, Y, and Z are the lowest)
|
||||
* @return true if the vector is contained
|
||||
*/
|
||||
public boolean containedWithin(Vector2D min, Vector2D max) {
|
||||
return getX() >= min.getX() && getX() <= max.getX()
|
||||
&& getZ() >= min.getZ() && getZ() <= max.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a vector is contained with another.
|
||||
*
|
||||
* @param min the minimum point (X, Y, and Z are the lowest)
|
||||
* @param max the maximum point (X, Y, and Z are the lowest)
|
||||
* @return true if the vector is contained
|
||||
*/
|
||||
public boolean containedWithinBlock(Vector2D min, Vector2D max) {
|
||||
return getBlockX() >= min.getBlockX() && getBlockX() <= max.getBlockX()
|
||||
&& getBlockZ() >= min.getBlockZ() && getBlockZ() <= max.getBlockZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Floors the values of all components.
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D floor() {
|
||||
return new Vector2D(Math.floor(getX()), Math.floor(getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounds all components up.
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D ceil() {
|
||||
return new Vector2D(Math.ceil(getX()), Math.ceil(getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounds all components to the closest integer.
|
||||
* <p>
|
||||
* <p>Components < 0.5 are rounded down, otherwise up.</p>
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D round() {
|
||||
return new Vector2D(Math.floor(getX() + 0.5), Math.floor(getZ() + 0.5));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a vector with the absolute values of the components of
|
||||
* this vector.
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector2D positive() {
|
||||
return new Vector2D(Math.abs(getX()), Math.abs(getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a 2D transformation on this vector and return a new one.
|
||||
*
|
||||
* @param angle in degrees
|
||||
* @param aboutX about which x coordinate to rotate
|
||||
* @param aboutZ about which z coordinate to rotate
|
||||
* @param translateX what to add after rotation
|
||||
* @param translateZ what to add after rotation
|
||||
* @return a new vector
|
||||
* @see AffineTransform another method to transform vectors
|
||||
*/
|
||||
public Vector2D transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
||||
angle = Math.toRadians(angle);
|
||||
double x = this.getX() - aboutX;
|
||||
double z = this.getZ() - aboutZ;
|
||||
double x2 = x * Math.cos(angle) - z * Math.sin(angle);
|
||||
double z2 = x * Math.sin(angle) + z * Math.cos(angle);
|
||||
return new Vector2D(
|
||||
x2 + aboutX + translateX,
|
||||
z2 + aboutZ + translateZ
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this vector is collinear with another vector.
|
||||
*
|
||||
* @param other the other vector
|
||||
* @return true if collinear
|
||||
*/
|
||||
public boolean isCollinearWith(Vector2D other) {
|
||||
if (getX() == 0 && getZ() == 0) {
|
||||
// this is a zero vector
|
||||
return true;
|
||||
}
|
||||
|
||||
final double otherX = other.getX();
|
||||
final double otherZ = other.getZ();
|
||||
|
||||
if (otherX == 0 && otherZ == 0) {
|
||||
// other is a zero vector
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((getX() == 0) != (otherX == 0)) return false;
|
||||
if ((getZ() == 0) != (otherZ == 0)) return false;
|
||||
|
||||
final double quotientX = otherX / getX();
|
||||
if (!Double.isNaN(quotientX)) {
|
||||
return other.equals(multiply(quotientX));
|
||||
}
|
||||
|
||||
final double quotientZ = otherZ / getZ();
|
||||
if (!Double.isNaN(quotientZ)) {
|
||||
return other.equals(multiply(quotientZ));
|
||||
}
|
||||
|
||||
throw new RuntimeException("This should not happen");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code BlockVector2D} from this vector.
|
||||
*
|
||||
* @return a new {@code BlockVector2D}
|
||||
*/
|
||||
public BlockVector2D toBlockVector2D() {
|
||||
return new BlockVector2D(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a 3D vector by adding a zero Y component to this vector.
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector toVector() {
|
||||
return new Vector(getX(), 0, getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a 3D vector by adding the specified Y component to this vector.
|
||||
*
|
||||
* @param y the Y component
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector toVector(double y) {
|
||||
return new Vector(getX(), y, getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Vector2D)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2D other = (Vector2D) obj;
|
||||
return other.getX() == this.getX() && other.getZ() == this.getZ();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ((new Double(getX())).hashCode() >> 13) ^
|
||||
(new Double(getZ())).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + getX() + ", " + getZ() + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minimum components of two vectors.
|
||||
*
|
||||
* @param v1 the first vector
|
||||
* @param v2 the second vector
|
||||
* @return minimum
|
||||
*/
|
||||
public static Vector2D getMinimum(Vector2D v1, Vector2D v2) {
|
||||
return new Vector2D(
|
||||
Math.min(v1.getX(), v2.getX()),
|
||||
Math.min(v1.getZ(), v2.getZ())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum components of two vectors.
|
||||
*
|
||||
* @param v1 the first vector
|
||||
* @param v2 the second vector
|
||||
* @return maximum
|
||||
*/
|
||||
public static Vector2D getMaximum(Vector2D v1, Vector2D v2) {
|
||||
return new Vector2D(
|
||||
Math.max(v1.getX(), v2.getX()),
|
||||
Math.max(v1.getZ(), v2.getZ())
|
||||
);
|
||||
}
|
||||
|
||||
private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
|
||||
if (this instanceof MutableBlockVector2D) return;
|
||||
stream.writeDouble(x);
|
||||
stream.writeDouble(z);
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
if (this instanceof MutableBlockVector2D) return;
|
||||
this.x = stream.readDouble();
|
||||
this.z = stream.readDouble();
|
||||
}
|
||||
}
|
@ -38,6 +38,8 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.Constant;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.scripting.CraftScriptContext;
|
||||
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
||||
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
||||
@ -378,7 +380,7 @@ public class WorldEdit {
|
||||
* @return a direction vector
|
||||
* @throws UnknownDirectionException thrown if the direction is not known
|
||||
*/
|
||||
public Vector getDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
public BlockVector3 getDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
dirStr = dirStr.toLowerCase();
|
||||
|
||||
final PlayerDirection dir = getPlayerDirection(player, dirStr);
|
||||
@ -390,7 +392,7 @@ public class WorldEdit {
|
||||
case NORTH:
|
||||
case UP:
|
||||
case DOWN:
|
||||
return dir.vector();
|
||||
return dir.vector().toBlockPoint();
|
||||
|
||||
default:
|
||||
throw new UnknownDirectionException(dir.name());
|
||||
|
@ -30,8 +30,6 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
@ -44,7 +42,12 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -150,6 +153,7 @@ public class BiomeCommands extends MethodCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toVector2D());
|
||||
biomes[biome.getId()]++;
|
||||
size = 1;
|
||||
@ -157,11 +161,23 @@ public class BiomeCommands extends MethodCommands {
|
||||
BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toVector2D());
|
||||
biomes[biome.getId()]++;
|
||||
size = 1;
|
||||
=======
|
||||
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at line of sight point";
|
||||
} else if (args.hasFlag('p')) {
|
||||
BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2());
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at your position";
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
} else {
|
||||
World world = player.getWorld();
|
||||
Region region = session.getSelection(world);
|
||||
|
||||
if (region instanceof FlatRegion) {
|
||||
<<<<<<< HEAD
|
||||
for (Vector2D pt : new Fast2DIterator(((FlatRegion) region).asFlatRegion(), editSession)) {
|
||||
biomes[editSession.getBiome(pt).getId()]++;
|
||||
size++;
|
||||
@ -176,6 +192,15 @@ public class BiomeCommands extends MethodCommands {
|
||||
}, editSession);
|
||||
Operations.completeBlindly(visitor);
|
||||
size += visitor.getAffected();
|
||||
=======
|
||||
for (BlockVector2 pt : ((FlatRegion) region).asFlatRegion()) {
|
||||
biomes.add(world.getBiome(pt));
|
||||
}
|
||||
} else {
|
||||
for (BlockVector3 pt : region) {
|
||||
biomes.add(world.getBiome(pt.toBlockVector2()));
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +244,7 @@ public class BiomeCommands extends MethodCommands {
|
||||
Mask2D mask2d = mask != null ? mask.toMask2D() : null;
|
||||
|
||||
if (atPosition) {
|
||||
region = new CuboidRegion(player.getLocation().toVector(), player.getLocation().toVector());
|
||||
region = new CuboidRegion(player.getLocation().toVector().toBlockPoint(), player.getLocation().toVector().toBlockPoint());
|
||||
} else {
|
||||
region = session.getSelection(world);
|
||||
}
|
||||
|
@ -39,6 +39,19 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Step;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.command.tool.brush.*;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.tool.brush.ButcherBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.ClipboardBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.CylinderBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.GravityBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.HollowSphereBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.SmoothBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
|
||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
@ -47,9 +60,10 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.command.InvalidUsageException;
|
||||
import com.sk89q.worldedit.util.command.binding.Range;
|
||||
@ -63,9 +77,6 @@ import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -268,8 +279,8 @@ public class BrushCommands extends BrushProcessor {
|
||||
max = 5
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.rock")
|
||||
public BrushSettings blobBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Optional("10") Vector radius, @Optional("100") double sphericity, @Optional("30") double frequency, @Optional("50") double amplitude, CommandContext context) throws WorldEditException {
|
||||
double max = MathMan.max(radius.getBlockX(), radius.getBlockY(), radius.getBlockZ());
|
||||
public BrushSettings blobBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Optional("10") Vector3 radius, @Optional("100") double sphericity, @Optional("30") double frequency, @Optional("50") double amplitude, CommandContext context) throws WorldEditException {
|
||||
double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
|
||||
getWorldEdit().checkMaxBrushRadius(max);
|
||||
Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100);
|
||||
return set(session, context,
|
||||
@ -600,7 +611,7 @@ public class BrushCommands extends BrushProcessor {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
|
||||
Vector size = clipboard.getDimensions();
|
||||
BlockVector3 size = clipboard.getDimensions();
|
||||
|
||||
getWorldEdit().checkMaxBrushRadius(size.getBlockX());
|
||||
getWorldEdit().checkMaxBrushRadius(size.getBlockY());
|
||||
|
@ -26,11 +26,15 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.storage.LegacyChunkStore;
|
||||
@ -75,10 +79,17 @@ public class ChunkCommands {
|
||||
String filename = "c." + Integer.toString(chunkX, 36)
|
||||
+ "." + Integer.toString(chunkZ, 36) + ".dat";
|
||||
|
||||
<<<<<<< HEAD
|
||||
player.print(BBC.getPrefix() + "Chunk: " + chunkX + ", " + chunkZ);
|
||||
player.print(BBC.getPrefix() + "Old format: " + folder1 + "/" + folder2 + "/" + filename);
|
||||
player.print(BBC.getPrefix() + "McRegion: region/" + McRegionChunkStore.getFilename(
|
||||
new Vector2D(chunkX, chunkZ)));
|
||||
=======
|
||||
player.print("Chunk: " + chunkX + ", " + chunkZ);
|
||||
player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename);
|
||||
player.print("McRegion: region/" + McRegionChunkStore.getFilename(
|
||||
new BlockVector2(chunkX, chunkZ)));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -89,11 +100,19 @@ public class ChunkCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.listchunks")
|
||||
<<<<<<< HEAD
|
||||
public void listChunks(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
|
||||
for (Vector2D chunk : chunks) {
|
||||
player.print(BBC.getPrefix() + LegacyChunkStore.getFilename(chunk));
|
||||
=======
|
||||
public void listChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
|
||||
for (BlockVector2 chunk : chunks) {
|
||||
player.print(LegacyChunkStore.getFilename(chunk));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +129,7 @@ public class ChunkCommands {
|
||||
player.print(BBC.getPrefix() + "Note that this command does not yet support the mcregion format.");
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
FileOutputStream out = null;
|
||||
|
||||
if (config.shellSaveType == null) {
|
||||
@ -127,7 +146,7 @@ public class ChunkCommands {
|
||||
writer.write("ECHO.\r\n");
|
||||
writer.write("PAUSE\r\n");
|
||||
|
||||
for (Vector2D chunk : chunks) {
|
||||
for (BlockVector2 chunk : chunks) {
|
||||
String filename = LegacyChunkStore.getFilename(chunk);
|
||||
writer.write("ECHO " + filename + "\r\n");
|
||||
writer.write("DEL \"world/" + filename + "\"\r\n");
|
||||
@ -159,7 +178,7 @@ public class ChunkCommands {
|
||||
writer.write("echo\n");
|
||||
writer.write("read -p \"Press any key to continue...\"\n");
|
||||
|
||||
for (Vector2D chunk : chunks) {
|
||||
for (BlockVector2 chunk : chunks) {
|
||||
String filename = LegacyChunkStore.getFilename(chunk);
|
||||
writer.write("echo " + filename + "\n");
|
||||
writer.write("rm \"world/" + filename + "\"\n");
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
@ -40,6 +41,19 @@ import com.boydti.fawe.util.gui.FormBuilder;
|
||||
import com.boydti.fawe.wrappers.FakePlayer;
|
||||
import com.sk89q.minecraft.util.commands.*;
|
||||
import com.sk89q.worldedit.*;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.extent.PasteEvent;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
@ -55,6 +69,8 @@ import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -465,9 +481,14 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
Region region = clipboard.getRegion();
|
||||
<<<<<<< HEAD
|
||||
Vector to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
|
||||
checkPaste(player, editSession, to, holder, clipboard);
|
||||
|
||||
=======
|
||||
|
||||
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
Operation operation = holder
|
||||
.createPaste(editSession)
|
||||
.to(to)
|
||||
@ -478,10 +499,17 @@ public class ClipboardCommands extends MethodCommands {
|
||||
Operations.completeLegacy(operation);
|
||||
|
||||
if (selectPasted) {
|
||||
<<<<<<< HEAD
|
||||
Vector clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
Vector realTo = to.add(new Vector(holder.getTransform().apply(clipboardOffset)));
|
||||
Vector max = realTo.add(new Vector(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()))));
|
||||
RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo, max);
|
||||
=======
|
||||
BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
Vector3 realTo = to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3()));
|
||||
Vector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()));
|
||||
RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo.toBlockPoint(), max.toBlockPoint());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
session.setRegionSelector(player.getWorld(), selector);
|
||||
selector.learnChanges();
|
||||
selector.explainRegionAdjust(player, session);
|
||||
@ -577,14 +605,24 @@ public class ClipboardCommands extends MethodCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.flip")
|
||||
<<<<<<< HEAD
|
||||
public void flip(Player player, LocalSession session,
|
||||
@Optional(Direction.AIM) @Direction Vector direction) throws WorldEditException {
|
||||
=======
|
||||
public void flip(Player player, LocalSession session, EditSession editSession,
|
||||
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
AffineTransform transform = new AffineTransform();
|
||||
<<<<<<< HEAD
|
||||
transform = transform.scale(direction.positive().multiply(-2).add(1, 1, 1));
|
||||
holder.setTransform(transform.combine(holder.getTransform()));
|
||||
BBC.COMMAND_FLIPPED.send(player);
|
||||
=======
|
||||
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
|
||||
holder.setTransform(holder.getTransform().combine(transform));
|
||||
player.print("The clipboard copy has been flipped.");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Deprecated // See SchematicCommands#clear
|
||||
|
@ -19,12 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.CombinedTransform;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
@ -67,8 +73,8 @@ public class FlattenedClipboardTransform {
|
||||
*/
|
||||
public Region getTransformedRegion() {
|
||||
Region region = original.getRegion();
|
||||
Vector minimum = region.getMinimumPoint();
|
||||
Vector maximum = region.getMaximumPoint();
|
||||
Vector3 minimum = region.getMinimumPoint().toVector3();
|
||||
Vector3 maximum = region.getMaximumPoint().toVector3();
|
||||
|
||||
Transform transformAround =
|
||||
new CombinedTransform(
|
||||
@ -76,6 +82,7 @@ public class FlattenedClipboardTransform {
|
||||
transform,
|
||||
new AffineTransform().translate(original.getOrigin()));
|
||||
|
||||
<<<<<<< HEAD
|
||||
// new Vector(minimum.getX(), minimum.getY(), minimum.getZ())
|
||||
// new Vector(maximum.getX(), maximum.getY(), maximum.getZ())
|
||||
Vector[] corners = new Vector[]{
|
||||
@ -87,26 +94,44 @@ public class FlattenedClipboardTransform {
|
||||
new Vector(minimum.getX(), maximum.getY(), maximum.getZ()),
|
||||
new Vector(maximum.getX(), minimum.getY(), maximum.getZ()),
|
||||
new Vector(maximum.getX(), maximum.getY(), minimum.getZ())};
|
||||
=======
|
||||
Vector3[] corners = new Vector3[] {
|
||||
minimum,
|
||||
maximum,
|
||||
minimum.withX(maximum.getX()),
|
||||
minimum.withY(maximum.getY()),
|
||||
minimum.withZ(maximum.getZ()),
|
||||
maximum.withX(minimum.getX()),
|
||||
maximum.withY(minimum.getY()),
|
||||
maximum.withZ(minimum.getZ()) };
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
for (int i = 0; i < corners.length; i++) {
|
||||
corners[i] = transformAround.apply(new Vector(corners[i]));
|
||||
}
|
||||
|
||||
Vector newMinimum = corners[0];
|
||||
Vector newMaximum = corners[0];
|
||||
Vector3 newMinimum = corners[0];
|
||||
Vector3 newMaximum = corners[0];
|
||||
|
||||
for (int i = 1; i < corners.length; i++) {
|
||||
newMinimum = Vector.getMinimum(newMinimum, corners[i]);
|
||||
newMaximum = Vector.getMaximum(newMaximum, corners[i]);
|
||||
newMinimum = newMinimum.getMinimum(corners[i]);
|
||||
newMaximum = newMaximum.getMaximum(corners[i]);
|
||||
}
|
||||
|
||||
// After transformation, the points may not really sit on a block,
|
||||
// so we should expand the region for edge cases
|
||||
<<<<<<< HEAD
|
||||
newMinimum.mutX(Math.ceil(Math.floor(newMinimum.getX())));
|
||||
newMinimum.mutY(Math.ceil(Math.floor(newMinimum.getY())));
|
||||
newMinimum.mutZ(Math.ceil(Math.floor(newMinimum.getZ())));
|
||||
|
||||
return new CuboidRegion(newMinimum, newMaximum);
|
||||
=======
|
||||
newMinimum = newMinimum.floor();
|
||||
newMaximum = newMaximum.ceil();
|
||||
|
||||
return new CuboidRegion(newMinimum.toBlockPoint(), newMaximum.toBlockPoint());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,9 +31,16 @@ import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
@ -42,7 +49,12 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
@ -201,6 +213,7 @@ public class GenerationCommands extends MethodCommands {
|
||||
}, getArguments(context), (int) max, context);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
@Command(
|
||||
aliases = {"/cyl"},
|
||||
usage = "<pattern> <radius>[,<radius>] [height]",
|
||||
@ -224,6 +237,11 @@ public class GenerationCommands extends MethodCommands {
|
||||
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow);
|
||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||
}, getArguments(context), (int) max, context);
|
||||
=======
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
|
||||
player.print(affected + " block(s) have been created.");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -259,6 +277,7 @@ public class GenerationCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.sphere")
|
||||
@Logging(PLACEMENT)
|
||||
<<<<<<< HEAD
|
||||
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector radius, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
||||
double max = MathMan.max(radius.getBlockX(), radius.getBlockY(), radius.getBlockZ());
|
||||
worldEdit.checkMaxRadius(max);
|
||||
@ -269,6 +288,39 @@ public class GenerationCommands extends MethodCommands {
|
||||
player.findFreePosition();
|
||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||
}, getArguments(context), (int) max, context);
|
||||
=======
|
||||
public void sphere(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("false") boolean raised, @Switch('h') boolean hollow) throws WorldEditException {
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = Math.max(1, Double.parseDouble(radii[0]));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
radiusX = Math.max(1, Double.parseDouble(radii[0]));
|
||||
radiusY = Math.max(1, Double.parseDouble(radii[1]));
|
||||
radiusZ = Math.max(1, Double.parseDouble(radii[2]));
|
||||
break;
|
||||
|
||||
default:
|
||||
player.printError("You must either specify 1 or 3 radius values.");
|
||||
return;
|
||||
}
|
||||
|
||||
worldEdit.checkMaxRadius(radiusX);
|
||||
worldEdit.checkMaxRadius(radiusY);
|
||||
worldEdit.checkMaxRadius(radiusZ);
|
||||
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
if (raised) {
|
||||
pos = pos.add(0, (int) radiusY, 0);
|
||||
}
|
||||
|
||||
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -324,7 +376,12 @@ public class GenerationCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.pyramid")
|
||||
@Logging(PLACEMENT)
|
||||
<<<<<<< HEAD
|
||||
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
||||
=======
|
||||
public void pyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow) throws WorldEditException {
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
worldEdit.checkMaxRadius(size);
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
fp.checkConfirmationRadius(() -> {
|
||||
@ -362,33 +419,46 @@ public class GenerationCommands extends MethodCommands {
|
||||
@Switch('h') boolean hollow,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
<<<<<<< HEAD
|
||||
@Switch('c') boolean offsetCenter,
|
||||
CommandContext context) throws WorldEditException, ParameterException {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
=======
|
||||
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
||||
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
zero = Vector3.ZERO;
|
||||
unit = Vector3.ONE;
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
zero = session.getPlacementPosition(player).toVector3();
|
||||
unit = Vector3.ONE;
|
||||
} else if (offsetCenter) {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = Vector.ONE;
|
||||
unit = Vector3.ONE;
|
||||
} else {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (unit.getX() == 0) unit.mutX(1);
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
=======
|
||||
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
@ -430,33 +500,53 @@ public class GenerationCommands extends MethodCommands {
|
||||
@Switch('h') boolean hollow,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
<<<<<<< HEAD
|
||||
@Switch('c') boolean offsetCenter,
|
||||
CommandContext context) throws WorldEditException, ParameterException {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
=======
|
||||
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
zero = Vector3.ZERO;
|
||||
unit = Vector3.ONE;
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
zero = session.getPlacementPosition(player).toVector3();
|
||||
unit = Vector3.ONE;
|
||||
} else if (offsetCenter) {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = Vector.ONE;
|
||||
unit = Vector3.ONE;
|
||||
} else {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (unit.getX() == 0) unit.mutX(1);
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
=======
|
||||
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||
}
|
||||
|
||||
try {
|
||||
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
|
||||
player.findFreePosition();
|
||||
player.print("" + affected + " columns affected.");
|
||||
} catch (ExpressionException e) {
|
||||
player.printError(e.getMessage());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
|
@ -34,9 +34,16 @@ import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.function.GroundFunction;
|
||||
@ -51,6 +58,8 @@ import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||
@ -247,8 +256,8 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
CuboidRegion cuboidregion = (CuboidRegion) region;
|
||||
Vector pos1 = cuboidregion.getPos1();
|
||||
Vector pos2 = cuboidregion.getPos2();
|
||||
BlockVector3 pos1 = cuboidregion.getPos1();
|
||||
BlockVector3 pos2 = cuboidregion.getPos2();
|
||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
||||
|
||||
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
||||
@ -281,9 +290,14 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
worldEdit.checkMaxRadius(thickness);
|
||||
|
||||
<<<<<<< HEAD
|
||||
player.checkConfirmationRegion(() -> {
|
||||
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||
List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());
|
||||
=======
|
||||
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
||||
|
||||
@ -537,6 +551,7 @@ public class RegionCommands extends MethodCommands {
|
||||
public void move(FawePlayer player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Optional("1") @Range(min = 1) int count,
|
||||
<<<<<<< HEAD
|
||||
@Optional(Direction.AIM) @Direction Vector direction,
|
||||
@Optional("air") Pattern replace,
|
||||
@Switch('b') boolean copyBiomes,
|
||||
@ -556,6 +571,22 @@ public class RegionCommands extends MethodCommands {
|
||||
} catch (RegionOperationException e) {
|
||||
player.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||
}
|
||||
=======
|
||||
@Optional(Direction.AIM) @Direction BlockVector3 direction,
|
||||
@Optional("air") BlockStateHolder replace,
|
||||
@Switch('s') boolean moveSelection) throws WorldEditException {
|
||||
|
||||
int affected = editSession.moveRegion(region, direction, count, true, replace);
|
||||
|
||||
if (moveSelection) {
|
||||
try {
|
||||
region.shift(direction.multiply(count));
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
@ -604,8 +635,9 @@ public class RegionCommands extends MethodCommands {
|
||||
public void stack(FawePlayer player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Optional("1") @Range(min = 1) int count,
|
||||
@Optional(Direction.AIM) @Direction Vector direction,
|
||||
@Optional(Direction.AIM) @Direction BlockVector3 direction,
|
||||
@Switch('s') boolean moveSelection,
|
||||
<<<<<<< HEAD
|
||||
@Switch('b') boolean copyBiomes,
|
||||
@Switch('e') boolean skipEntities,
|
||||
@Switch('a') boolean ignoreAirBlocks, @Switch('m') Mask sourceMask, CommandContext context) throws WorldEditException {
|
||||
@ -626,6 +658,22 @@ public class RegionCommands extends MethodCommands {
|
||||
} catch (RegionOperationException e) {
|
||||
player.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||
}
|
||||
=======
|
||||
@Switch('a') boolean ignoreAirBlocks) throws WorldEditException {
|
||||
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks);
|
||||
|
||||
if (moveSelection) {
|
||||
try {
|
||||
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
||||
|
||||
final BlockVector3 shiftVector = direction.toVector3().multiply(count * (Math.abs(direction.dot(size)) + 1)).toBlockPoint();
|
||||
region.shift(shiftVector);
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
@ -651,27 +699,39 @@ public class RegionCommands extends MethodCommands {
|
||||
@Selection Region region,
|
||||
@Text String expression,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
<<<<<<< HEAD
|
||||
@Switch('o') boolean offset,
|
||||
CommandContext context) throws WorldEditException {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
=======
|
||||
@Switch('o') boolean offset) throws WorldEditException {
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
zero = Vector3.ZERO;
|
||||
unit = Vector3.ONE;
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
zero = session.getPlacementPosition(player).toVector3();
|
||||
unit = Vector3.ONE;
|
||||
} else {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
zero = max.add(min).divide(2);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (unit.getX() == 0) unit.mutX(1);
|
||||
if (unit.getY() == 0) unit.mutY(1);
|
||||
if (unit.getZ() == 0) unit.mutZ(1);
|
||||
=======
|
||||
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
|
@ -32,8 +32,6 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
@ -45,7 +43,12 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
@ -66,7 +69,10 @@ import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import java.io.File;
|
||||
@ -117,6 +123,7 @@ public class SelectionCommands {
|
||||
} else {
|
||||
pos = player.getBlockIn().toVector();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY());
|
||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(player);
|
||||
@ -124,6 +131,16 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld()).explainPrimarySelection(player, session, pos);
|
||||
=======
|
||||
|
||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||
player.printError("Position already set.");
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
.explainPrimarySelection(player, session, pos.toVector().toBlockPoint());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -150,14 +167,24 @@ public class SelectionCommands {
|
||||
} else {
|
||||
pos = player.getBlockIn().toVector();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY());
|
||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(player);
|
||||
=======
|
||||
|
||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||
player.printError("Position already set.");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
<<<<<<< HEAD
|
||||
.explainSecondarySelection(player, session, pos);
|
||||
=======
|
||||
.explainSecondarySelection(player, session, pos.toVector().toBlockPoint());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -172,13 +199,22 @@ public class SelectionCommands {
|
||||
Vector pos = player.getBlockTrace(300).toVector();
|
||||
|
||||
if (pos != null) {
|
||||
<<<<<<< HEAD
|
||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(player);
|
||||
=======
|
||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||
player.printError("Position already set.");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
<<<<<<< HEAD
|
||||
.explainPrimarySelection(player, session, pos);
|
||||
=======
|
||||
.explainPrimarySelection(player, session, pos.toVector().toBlockPoint());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
} else {
|
||||
player.printError("No block in sight!");
|
||||
}
|
||||
@ -196,13 +232,22 @@ public class SelectionCommands {
|
||||
Vector pos = player.getBlockTrace(300).toVector();
|
||||
|
||||
if (pos != null) {
|
||||
<<<<<<< HEAD
|
||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(player);
|
||||
=======
|
||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||
player.printError("Position already set.");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
<<<<<<< HEAD
|
||||
.explainSecondarySelection(player, session, pos);
|
||||
=======
|
||||
.explainSecondarySelection(player, session, pos.toVector().toBlockPoint());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
} else {
|
||||
player.printError("No block in sight!");
|
||||
}
|
||||
@ -226,22 +271,28 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.chunk")
|
||||
<<<<<<< HEAD
|
||||
public void chunk(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
final Vector min;
|
||||
final Vector max;
|
||||
=======
|
||||
public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
final BlockVector3 min;
|
||||
final BlockVector3 max;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
final World world = player.getWorld();
|
||||
if (args.hasFlag('s')) {
|
||||
Region region = session.getSelection(world);
|
||||
|
||||
final Vector2D min2D = ChunkStore.toChunk(region.getMinimumPoint());
|
||||
final Vector2D max2D = ChunkStore.toChunk(region.getMaximumPoint());
|
||||
final BlockVector2 min2D = ChunkStore.toChunk(region.getMinimumPoint());
|
||||
final BlockVector2 max2D = ChunkStore.toChunk(region.getMaximumPoint());
|
||||
|
||||
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||
max = new Vector(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15);
|
||||
min = new BlockVector3(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||
max = new BlockVector3(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15);
|
||||
|
||||
BBC.SELECTION_CHUNKS.send(player, min2D.getBlockX() + ", " + min2D.getBlockZ(), max2D.getBlockX() + ", " + max2D.getBlockZ());
|
||||
} else {
|
||||
final Vector2D min2D;
|
||||
final BlockVector2 min2D;
|
||||
if (args.argsLength() == 1) {
|
||||
// coords specified
|
||||
String[] coords = args.getString(0).split(",");
|
||||
@ -250,14 +301,14 @@ public class SelectionCommands {
|
||||
}
|
||||
int x = Integer.parseInt(coords[0]);
|
||||
int z = Integer.parseInt(coords[1]);
|
||||
Vector2D pos = new Vector2D(x, z);
|
||||
min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toVector());
|
||||
BlockVector2 pos = new BlockVector2(x, z);
|
||||
min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toBlockVector3());
|
||||
} else {
|
||||
// use player loc
|
||||
min2D = ChunkStore.toChunk(player.getBlockIn().toVector());
|
||||
min2D = ChunkStore.toChunk(player.getBlockIn().toVector().toBlockPoint());
|
||||
}
|
||||
|
||||
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||
min = new BlockVector3(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||
max = min.add(15, world.getMaxY(), 15);
|
||||
|
||||
BBC.SELECTION_CHUNK.send(player, min2D.getBlockX() + ", " + min2D.getBlockZ());
|
||||
@ -327,8 +378,8 @@ public class SelectionCommands {
|
||||
try {
|
||||
int oldSize = region.getArea();
|
||||
region.expand(
|
||||
new Vector(0, (player.getWorld().getMaxY() + 1), 0),
|
||||
new Vector(0, -(player.getWorld().getMaxY() + 1), 0));
|
||||
new BlockVector3(0, (player.getWorld().getMaxY() + 1), 0),
|
||||
new BlockVector3(0, -(player.getWorld().getMaxY() + 1), 0));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
int newSize = region.getArea();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
@ -340,7 +391,11 @@ public class SelectionCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
List<Vector> dirs = new ArrayList<Vector>();
|
||||
=======
|
||||
List<BlockVector3> dirs = new ArrayList<>();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
int change = args.getInteger(0);
|
||||
int reverseChange = 0;
|
||||
|
||||
@ -385,11 +440,11 @@ public class SelectionCommands {
|
||||
int oldSize = region.getArea();
|
||||
|
||||
if (reverseChange == 0) {
|
||||
for (Vector dir : dirs) {
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.expand(dir.multiply(change));
|
||||
}
|
||||
} else {
|
||||
for (Vector dir : dirs) {
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.expand(dir.multiply(change), dir.multiply(-reverseChange));
|
||||
}
|
||||
}
|
||||
@ -410,8 +465,14 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.contract")
|
||||
<<<<<<< HEAD
|
||||
public void contract(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
List<Vector> dirs = new ArrayList<Vector>();
|
||||
=======
|
||||
public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
List<BlockVector3> dirs = new ArrayList<>();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
int change = args.getInteger(0);
|
||||
int reverseChange = 0;
|
||||
|
||||
@ -455,11 +516,11 @@ public class SelectionCommands {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
int oldSize = region.getArea();
|
||||
if (reverseChange == 0) {
|
||||
for (Vector dir : dirs) {
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.contract(dir.multiply(change));
|
||||
}
|
||||
} else {
|
||||
for (Vector dir : dirs) {
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.contract(dir.multiply(change), dir.multiply(-reverseChange));
|
||||
}
|
||||
}
|
||||
@ -483,8 +544,14 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.shift")
|
||||
<<<<<<< HEAD
|
||||
public void shift(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
List<Vector> dirs = new ArrayList<Vector>();
|
||||
=======
|
||||
public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
List<BlockVector3> dirs = new ArrayList<>();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
int change = args.getInteger(0);
|
||||
if (args.argsLength() == 2) {
|
||||
if (args.getString(1).contains(",")) {
|
||||
@ -501,7 +568,7 @@ public class SelectionCommands {
|
||||
try {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
|
||||
for (Vector dir : dirs) {
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.shift(dir.multiply(change));
|
||||
}
|
||||
|
||||
@ -560,23 +627,28 @@ public class SelectionCommands {
|
||||
BBC.SELECTION_INSET.send(player);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
private Vector[] getChangesForEachDir(CommandContext args) {
|
||||
List<Vector> changes = new ArrayList<Vector>(6);
|
||||
=======
|
||||
private BlockVector3[] getChangesForEachDir(CommandContext args) {
|
||||
List<BlockVector3> changes = new ArrayList<>(6);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
int change = args.getInteger(0);
|
||||
|
||||
if (!args.hasFlag('h')) {
|
||||
changes.add((new Vector(0, 1, 0)).multiply(change));
|
||||
changes.add((new Vector(0, -1, 0)).multiply(change));
|
||||
changes.add((new BlockVector3(0, 1, 0)).multiply(change));
|
||||
changes.add((new BlockVector3(0, -1, 0)).multiply(change));
|
||||
}
|
||||
|
||||
if (!args.hasFlag('v')) {
|
||||
changes.add((new Vector(1, 0, 0)).multiply(change));
|
||||
changes.add((new Vector(-1, 0, 0)).multiply(change));
|
||||
changes.add((new Vector(0, 0, 1)).multiply(change));
|
||||
changes.add((new Vector(0, 0, -1)).multiply(change));
|
||||
changes.add((new BlockVector3(1, 0, 0)).multiply(change));
|
||||
changes.add((new BlockVector3(-1, 0, 0)).multiply(change));
|
||||
changes.add((new BlockVector3(0, 0, 1)).multiply(change));
|
||||
changes.add((new BlockVector3(0, 0, -1)).multiply(change));
|
||||
}
|
||||
|
||||
return changes.toArray(new Vector[0]);
|
||||
return changes.toArray(new BlockVector3[0]);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -588,6 +660,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.selection.size")
|
||||
<<<<<<< HEAD
|
||||
public void size(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
if (args.hasFlag('c')) {
|
||||
ClipboardHolder root = session.getClipboard();
|
||||
@ -628,15 +701,33 @@ public class SelectionCommands {
|
||||
// player.print(BBC.getPrefix() + "Offset: " + origin);
|
||||
// player.print(BBC.getPrefix() + "Cuboid distance: " + size.distance(Vector.ONE));
|
||||
// player.print(BBC.getPrefix() + "# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
|
||||
=======
|
||||
public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
if (args.hasFlag('c')) {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
Region region = clipboard.getRegion();
|
||||
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
||||
BlockVector3 origin = clipboard.getOrigin();
|
||||
|
||||
player.print("Cuboid dimensions (max - min): " + size);
|
||||
player.print("Offset: " + origin);
|
||||
player.print("Cuboid distance: " + size.distance(BlockVector3.ONE));
|
||||
player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return;
|
||||
}
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
Vector size = region.getMaximumPoint()
|
||||
BlockVector3 size = region.getMaximumPoint()
|
||||
.subtract(region.getMinimumPoint())
|
||||
.add(1, 1, 1);
|
||||
|
||||
<<<<<<< HEAD
|
||||
player.print(BBC.getPrefix() + "Type: " + session.getRegionSelector(player.getWorld())
|
||||
=======
|
||||
player.print("Type: " + session.getRegionSelector(player.getWorld())
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
.getTypeName());
|
||||
|
||||
for (String line : session.getRegionSelector(player.getWorld())
|
||||
@ -644,9 +735,15 @@ public class SelectionCommands {
|
||||
player.print(BBC.getPrefix() + line);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
player.print(BBC.getPrefix() + "Size: " + size);
|
||||
player.print(BBC.getPrefix() + "Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
|
||||
player.print(BBC.getPrefix() + "# of blocks: " + region.getArea());
|
||||
=======
|
||||
player.print("Size: " + size);
|
||||
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
|
||||
player.print("# of blocks: " + region.getArea());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.command.FaweParser;
|
||||
@ -42,6 +43,21 @@ import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||
import com.sk89q.worldedit.command.util.EntityRemover;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
@ -64,6 +80,7 @@ import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -243,6 +260,7 @@ public class UtilityCommands extends MethodCommands {
|
||||
BBC.WORLDEDIT_CANCEL_COUNT.send(player, cancelled);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
@Command(
|
||||
aliases = {"/fill"},
|
||||
usage = "<pattern> <radius> [depth] [direction]",
|
||||
@ -258,6 +276,11 @@ public class UtilityCommands extends MethodCommands {
|
||||
int affected;
|
||||
affected = editSession.fillDirection(pos, pattern, radius, (int) depth, direction);
|
||||
player.print(BBC.getPrefix() + affected + " block(s) have been created.");
|
||||
=======
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
int affected = editSession.fillXZ(pos, pattern, radius, depth, false);
|
||||
player.print(affected + " block(s) have been created.");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -269,12 +292,35 @@ public class UtilityCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.fill.recursive")
|
||||
@Logging(PLACEMENT)
|
||||
<<<<<<< HEAD
|
||||
public void fillr(Player player, LocalSession session, EditSession editSession, Pattern pattern, double radius, @Optional("-1") double depth) throws WorldEditException {
|
||||
worldEdit.checkMaxRadius(radius);
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
if (depth == -1) depth = Integer.MAX_VALUE;
|
||||
int affected = editSession.fillXZ(pos, pattern, radius, (int) depth, true);
|
||||
player.print(BBC.getPrefix() + affected + " block(s) have been created.");
|
||||
=======
|
||||
public void fillr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context);
|
||||
|
||||
double radius = Math.max(1, args.getDouble(1));
|
||||
we.checkMaxRadius(radius);
|
||||
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE;
|
||||
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
int affected = 0;
|
||||
if (pattern instanceof BlockPattern) {
|
||||
affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true);
|
||||
} else {
|
||||
affected = editSession.fillXZ(pos, pattern, radius, depth, true);
|
||||
}
|
||||
player.print(affected + " block(s) have been created.");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -384,9 +430,16 @@ public class UtilityCommands extends MethodCommands {
|
||||
if (from == null) {
|
||||
from = new ExistingBlockMask(editSession);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
Vector base = session.getPlacementPosition(player);
|
||||
Vector min = base.subtract(size, size, size);
|
||||
Vector max = base.add(size, size, size);
|
||||
=======
|
||||
|
||||
BlockVector3 base = session.getPlacementPosition(player);
|
||||
BlockVector3 min = base.subtract(size, size, size);
|
||||
BlockVector3 max = base.add(size, size, size);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
Region region = new CuboidRegion(player.getWorld(), min, max);
|
||||
|
||||
int affected = editSession.replaceBlocks(region, from, to);
|
||||
@ -521,8 +574,13 @@ public class UtilityCommands extends MethodCommands {
|
||||
EditSession editSession = null;
|
||||
|
||||
if (player != null) {
|
||||
<<<<<<< HEAD
|
||||
session = worldEdit.getSessionManager().get(player);
|
||||
Vector center = session.getPlacementPosition(player);
|
||||
=======
|
||||
session = we.getSessionManager().get(player);
|
||||
BlockVector3 center = session.getPlacementPosition(player);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
editSession = session.createEditSession(player);
|
||||
List<? extends Entity> entities;
|
||||
if (radius >= 0) {
|
||||
@ -581,8 +639,13 @@ public class UtilityCommands extends MethodCommands {
|
||||
EditSession editSession = null;
|
||||
|
||||
if (player != null) {
|
||||
<<<<<<< HEAD
|
||||
session = worldEdit.getSessionManager().get(player);
|
||||
Vector center = session.getPlacementPosition(player);
|
||||
=======
|
||||
session = we.getSessionManager().get(player);
|
||||
BlockVector3 center = session.getPlacementPosition(player);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
editSession = session.createEditSession(player);
|
||||
List<? extends Entity> entities;
|
||||
if (radius >= 0) {
|
||||
|
@ -22,12 +22,12 @@ package com.sk89q.worldedit.command.argument;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.EditContext;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.command.argument.CommandArgs;
|
||||
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
||||
@ -82,7 +82,7 @@ public class ItemUseParser extends SimpleCommand<Contextual<RegionFunction>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return world.useItem(position, item, Direction.UP);
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class DeformCommand extends SimpleCommand<Contextual<? extends Operation>
|
||||
Player player = (Player) locals.get(Actor.class);
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(locals.get(Actor.class));
|
||||
try {
|
||||
deform.setOffset(session.getPlacementPosition(player));
|
||||
deform.setOffset(session.getPlacementPosition(player).toVector3());
|
||||
} catch (IncompleteRegionException e) {
|
||||
throw new WrappedCommandException(e);
|
||||
}
|
||||
|
@ -3,9 +3,18 @@ package com.sk89q.worldedit.command.tool;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
=======
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -30,7 +39,7 @@ public class AreaPickaxe implements BlockTool {
|
||||
int ox = clicked.getBlockX();
|
||||
int oy = clicked.getBlockY();
|
||||
int oz = clicked.getBlockZ();
|
||||
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector()).getBlockType();
|
||||
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector().toBlockPoint()).getBlockType();
|
||||
|
||||
if (initialType.getMaterial().isAir()) {
|
||||
return true;
|
||||
@ -40,6 +49,7 @@ public class AreaPickaxe implements BlockTool {
|
||||
return true;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||
|
||||
@ -48,6 +58,24 @@ public class AreaPickaxe implements BlockTool {
|
||||
for (int y = oy + range; y >= oy - range; --y) {
|
||||
if (initialType.equals(editSession.getLazyBlock(x, y, z))) {
|
||||
continue;
|
||||
=======
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||
|
||||
try {
|
||||
for (int x = ox - range; x <= ox + range; ++x) {
|
||||
for (int y = oy - range; y <= oy + range; ++y) {
|
||||
for (int z = oz - range; z <= oz + range; ++z) {
|
||||
BlockVector3 pos = new BlockVector3(x, y, z);
|
||||
if (editSession.getBlock(pos).getBlockType() != initialType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().toBlockPoint().distanceSq(pos));
|
||||
|
||||
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
|
||||
}
|
||||
|
@ -26,6 +26,11 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -45,7 +50,12 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
|
||||
World world = (World) clicked.getExtent();
|
||||
|
||||
<<<<<<< HEAD
|
||||
BlockStateHolder block = world.getBlock(clicked.toVector());
|
||||
=======
|
||||
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||
BlockState block = world.getBlock(blockPoint);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (!config.allowedDataCycleBlocks.isEmpty()
|
||||
&& !player.hasPermission("worldedit.override.data-cycler")
|
||||
@ -57,6 +67,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
if (block.getBlockType().getProperties().isEmpty()) {
|
||||
player.printError("That block's data cannot be cycled!");
|
||||
} else {
|
||||
<<<<<<< HEAD
|
||||
BlockStateHolder newBlock = block;
|
||||
|
||||
// TODO Forward = cycle value, Backward = Next property
|
||||
@ -70,6 +81,40 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
=======
|
||||
Property currentProperty = selectedProperties.get(player.getUniqueId());
|
||||
|
||||
if (currentProperty == null || (forward && block.getState(currentProperty) == null)) {
|
||||
currentProperty = block.getStates().keySet().stream().findFirst().get();
|
||||
selectedProperties.put(player.getUniqueId(), currentProperty);
|
||||
}
|
||||
|
||||
if (forward) {
|
||||
block.getState(currentProperty);
|
||||
int index = currentProperty.getValues().indexOf(block.getState(currentProperty));
|
||||
index = (index + 1) % currentProperty.getValues().size();
|
||||
BlockState newBlock = block.with(currentProperty, currentProperty.getValues().get(index));
|
||||
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
editSession.disableBuffering();
|
||||
|
||||
try {
|
||||
editSession.setBlock(blockPoint, newBlock);
|
||||
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<Property<?>> properties = Lists.newArrayList(block.getStates().keySet());
|
||||
int index = properties.indexOf(currentProperty);
|
||||
index = (index + 1) % properties.size();
|
||||
currentProperty = properties.get(index);
|
||||
selectedProperties.put(player.getUniqueId(), currentProperty);
|
||||
player.print("Now cycling " + currentProperty.getName());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,13 +29,13 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
@ -58,10 +58,22 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||
BlockBag bag = session.getBlockBag(player);
|
||||
|
||||
<<<<<<< HEAD
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
|
||||
try {
|
||||
editSession.setBlock(clicked.toVector(), pattern);
|
||||
=======
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
try {
|
||||
editSession.disableBuffering();
|
||||
BlockVector3 position = clicked.toVector().toBlockPoint();
|
||||
editSession.setBlock(position, pattern.apply(position));
|
||||
} catch (MaxChangedBlocksException ignored) {
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
} finally {
|
||||
if (bag != null) {
|
||||
bag.flushChanges();
|
||||
@ -75,9 +87,13 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
|
||||
@Override
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||
<<<<<<< HEAD
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
BlockStateHolder targetBlock = (editSession).getBlock(clicked.toVector());
|
||||
BlockType type = targetBlock.getBlockType();
|
||||
=======
|
||||
BlockStateHolder targetBlock = player.getWorld().getBlock(clicked.toVector().toBlockPoint());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (type != null) {
|
||||
this.pattern = targetBlock;
|
||||
|
@ -432,6 +432,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
||||
});
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public boolean act(BrushAction action, Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||
switch (action) {
|
||||
case PRIMARY:
|
||||
@ -474,6 +475,14 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
||||
MaskIntersection newMask = new MaskIntersection(existingMask);
|
||||
newMask.add(mask);
|
||||
editSession.setMask(newMask);
|
||||
=======
|
||||
try {
|
||||
brush.build(editSession, target.toVector().toBlockPoint(), material, size);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
Mask sourceMask = current.getSourceMask();
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
@ -48,8 +49,9 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
||||
if (target == null) return true;
|
||||
|
||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||
if (selector.selectPrimary(target.toVector(), ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainPrimarySelection(player, session, target.toVector());
|
||||
BlockVector3 blockPoint = target.toVector().toBlockPoint();
|
||||
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainPrimarySelection(player, session, blockPoint);
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -65,8 +67,9 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
||||
if (target == null) return true;
|
||||
|
||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||
if (selector.selectSecondary(target.toVector(), ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainSecondarySelection(player, session, target.toVector());
|
||||
BlockVector3 blockPoint = target.toVector().toBlockPoint();
|
||||
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainSecondarySelection(player, session, blockPoint);
|
||||
}
|
||||
return true;
|
||||
|
||||
|
@ -23,10 +23,10 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -69,13 +69,14 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
Player player, LocalSession session, Location clicked) {
|
||||
|
||||
final World world = (World) clicked.getExtent();
|
||||
final BlockState state = world.getBlock(clicked.toVector());
|
||||
final BlockState state = world.getBlock(clicked.toVector().toBlockPoint());
|
||||
|
||||
if (!isTreeBlock(state.getBlockType())) {
|
||||
player.printError("That's not a tree.");
|
||||
return true;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
final EditSession editSession = session.createEditSession(player);
|
||||
|
||||
try {
|
||||
@ -89,6 +90,21 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
final BlockState otherState = editSession.getBlock(blockVector);
|
||||
if (isTreeBlock(otherState.getBlockType())) {
|
||||
editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState());
|
||||
=======
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
try {
|
||||
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
|
||||
if (blockSet == null) {
|
||||
player.printError("That's not a floating tree.");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (BlockVector3 blockVector : blockSet) {
|
||||
final BlockState otherState = editSession.getBlock(blockVector);
|
||||
if (isTreeBlock(otherState.getBlockType())) {
|
||||
editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState());
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
@ -100,13 +116,13 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
return true;
|
||||
}
|
||||
|
||||
private Vector[] recurseDirections = {
|
||||
Direction.NORTH.toVector(),
|
||||
Direction.EAST.toVector(),
|
||||
Direction.SOUTH.toVector(),
|
||||
Direction.WEST.toVector(),
|
||||
Direction.UP.toVector(),
|
||||
Direction.DOWN.toVector(),
|
||||
private BlockVector3[] recurseDirections = {
|
||||
Direction.NORTH.toBlockVector(),
|
||||
Direction.EAST.toBlockVector(),
|
||||
Direction.SOUTH.toBlockVector(),
|
||||
Direction.WEST.toBlockVector(),
|
||||
Direction.UP.toBlockVector(),
|
||||
Direction.DOWN.toBlockVector(),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -116,17 +132,17 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
* @param origin any point contained in the floating tree
|
||||
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
|
||||
*/
|
||||
private Set<Vector> bfs(World world, Vector origin) throws MaxChangedBlocksException {
|
||||
final Set<Vector> visited = new HashSet<>();
|
||||
final LinkedList<Vector> queue = new LinkedList<>();
|
||||
private Set<BlockVector3> bfs(World world, BlockVector3 origin) throws MaxChangedBlocksException {
|
||||
final Set<BlockVector3> visited = new HashSet<>();
|
||||
final LinkedList<BlockVector3> queue = new LinkedList<>();
|
||||
|
||||
queue.addLast(origin);
|
||||
visited.add(origin);
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
final Vector current = queue.removeFirst();
|
||||
for (Vector recurseDirection : recurseDirections) {
|
||||
final Vector next = current.add(recurseDirection);
|
||||
final BlockVector3 current = queue.removeFirst();
|
||||
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||
final BlockVector3 next = current.add(recurseDirection);
|
||||
if (origin.distanceSq(next) > rangeSq) {
|
||||
// Maximum range exceeded => stop walking
|
||||
continue;
|
||||
|
@ -19,11 +19,19 @@
|
||||
|
||||
package com.sk89q.worldedit.command.tool;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.*;
|
||||
=======
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -54,7 +62,12 @@ public class FloodFillTool implements BlockTool {
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||
World world = (World) clicked.getExtent();
|
||||
|
||||
<<<<<<< HEAD
|
||||
BlockType initialType = world.getBlockType(clicked.toVector());
|
||||
=======
|
||||
BlockVector3 origin = clicked.toVector().toBlockPoint();
|
||||
BlockType initialType = world.getBlock(origin).getBlockType();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (initialType.getMaterial().isAir()) {
|
||||
return true;
|
||||
@ -64,7 +77,19 @@ public class FloodFillTool implements BlockTool {
|
||||
return true;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
=======
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
try {
|
||||
recurse(editSession, origin, origin, range, initialType, new HashSet<>());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
try {
|
||||
recurse(editSession, clicked.toVector().toBlockVector(),
|
||||
@ -77,8 +102,13 @@ public class FloodFillTool implements BlockTool {
|
||||
return true;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
private void recurse(EditSession editSession, BlockVector pos, Vector origin, int size, BlockType initialType,
|
||||
Set<BlockVector> visited) throws WorldEditException {
|
||||
=======
|
||||
private void recurse(EditSession editSession, BlockVector3 pos, BlockVector3 origin, int size, BlockType initialType,
|
||||
Set<BlockVector3> visited) throws MaxChangedBlocksException {
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (origin.distance(pos) > size || visited.contains(pos)) {
|
||||
return;
|
||||
@ -92,17 +122,17 @@ public class FloodFillTool implements BlockTool {
|
||||
return;
|
||||
}
|
||||
|
||||
recurse(editSession, pos.add(1, 0, 0).toBlockVector(),
|
||||
recurse(editSession, pos.add(1, 0, 0),
|
||||
origin, size, initialType, visited);
|
||||
recurse(editSession, pos.add(-1, 0, 0).toBlockVector(),
|
||||
recurse(editSession, pos.add(-1, 0, 0),
|
||||
origin, size, initialType, visited);
|
||||
recurse(editSession, pos.add(0, 0, 1).toBlockVector(),
|
||||
recurse(editSession, pos.add(0, 0, 1),
|
||||
origin, size, initialType, visited);
|
||||
recurse(editSession, pos.add(0, 0, -1).toBlockVector(),
|
||||
recurse(editSession, pos.add(0, 0, -1),
|
||||
origin, size, initialType, visited);
|
||||
recurse(editSession, pos.add(0, 1, 0).toBlockVector(),
|
||||
recurse(editSession, pos.add(0, 1, 0),
|
||||
origin, size, initialType, visited);
|
||||
recurse(editSession, pos.add(0, -1, 0).toBlockVector(),
|
||||
recurse(editSession, pos.add(0, -1, 0),
|
||||
origin, size, initialType, visited);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -55,7 +56,24 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||
Location pos = getTargetFace(player);
|
||||
if (pos == null) return false;
|
||||
<<<<<<< HEAD
|
||||
EditSession eS = session.createEditSession(player);
|
||||
=======
|
||||
try (EditSession eS = session.createEditSession(player)) {
|
||||
eS.disableBuffering();
|
||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||
BlockStateHolder applied = secondary.apply(blockPoint);
|
||||
if (applied.getBlockType().getMaterial().isAir()) {
|
||||
eS.setBlock(blockPoint, secondary);
|
||||
} else {
|
||||
eS.setBlock(pos.getDirection().toBlockPoint(), secondary);
|
||||
}
|
||||
return true;
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
// one block? eat it
|
||||
}
|
||||
return false;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
BlockStateHolder applied = secondary.apply(pos.toVector());
|
||||
if (applied.getBlockType().getMaterial().isAir()) {
|
||||
@ -70,12 +88,27 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||
Location pos = getTargetFace(player);
|
||||
if (pos == null) return false;
|
||||
<<<<<<< HEAD
|
||||
EditSession eS = session.createEditSession(player);
|
||||
BlockStateHolder applied = primary.apply(pos.toVector());
|
||||
if (applied.getBlockType().getMaterial().isAir()) {
|
||||
eS.setBlock(pos.toVector(), primary);
|
||||
} else {
|
||||
eS.setBlock(pos.add(pos.getDirection()), primary);
|
||||
=======
|
||||
try (EditSession eS = session.createEditSession(player)) {
|
||||
eS.disableBuffering();
|
||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||
BlockStateHolder applied = primary.apply(blockPoint);
|
||||
if (applied.getBlockType().getMaterial().isAir()) {
|
||||
eS.setBlock(blockPoint, primary);
|
||||
} else {
|
||||
eS.setBlock(pos.getDirection().toBlockPoint(), primary);
|
||||
}
|
||||
return true;
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
// one block? eat it
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
/**
|
||||
@ -44,13 +45,14 @@ public class QueryTool implements BlockTool {
|
||||
|
||||
World world = (World) clicked.getExtent();
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
BlockStateHolder block = editSession.getFullBlock(clicked.toVector());
|
||||
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||
BlockStateHolder block = editSession.getFullBlock(blockPoint);
|
||||
|
||||
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
|
||||
+ block.getBlockType().getName() + "\u00A77" + " ("
|
||||
+ block.toString() + ") "
|
||||
+ "\u00A7f"
|
||||
+ " (" + world.getBlockLightLevel(clicked.toVector()) + "/" + world.getBlockLightLevel(clicked.toVector().add(0, 1, 0)) + ")");
|
||||
+ " (" + world.getBlockLightLevel(blockPoint) + "/" + world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")");
|
||||
|
||||
if (block instanceof MobSpawnerBlock) {
|
||||
player.printRaw("\u00A7e" + "Mob Type: "
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.sk89q.worldedit.command.tool;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.mask.IdMask;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
@ -12,6 +13,16 @@ import com.sk89q.worldedit.function.block.BlockReplace;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
||||
=======
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -37,7 +48,12 @@ public class RecursivePickaxe implements BlockTool {
|
||||
World world = (World) clicked.getExtent();
|
||||
final Vector pos = clicked.toVector();
|
||||
|
||||
<<<<<<< HEAD
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
=======
|
||||
BlockVector3 origin = clicked.toVector().toBlockPoint();
|
||||
BlockType initialType = world.getBlock(origin).getBlockType();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
BlockStateHolder block = editSession.getBlock(pos);
|
||||
if (block.getBlockType().getMaterial().isAir()) {
|
||||
@ -50,6 +66,7 @@ public class RecursivePickaxe implements BlockTool {
|
||||
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||
|
||||
<<<<<<< HEAD
|
||||
final int radius = (int) range;
|
||||
final BlockReplace replace = new BlockReplace(editSession, (editSession.nullBlock));
|
||||
editSession.setMask((Mask) null);
|
||||
@ -59,9 +76,54 @@ public class RecursivePickaxe implements BlockTool {
|
||||
|
||||
editSession.flushQueue();
|
||||
session.remember(editSession);
|
||||
=======
|
||||
try {
|
||||
recurse(server, editSession, world, clicked.toVector().toBlockPoint(),
|
||||
clicked.toVector().toBlockPoint(), range, initialType, new HashSet<>());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
private static void recurse(Platform server, EditSession editSession, World world, BlockVector3 pos,
|
||||
BlockVector3 origin, double size, BlockType initialType, Set<BlockVector3> visited) throws MaxChangedBlocksException {
|
||||
|
||||
final double distanceSq = origin.distanceSq(pos);
|
||||
if (distanceSq > size*size || visited.contains(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
visited.add(pos);
|
||||
|
||||
if (editSession.getBlock(pos).getBlockType() != initialType) {
|
||||
return;
|
||||
}
|
||||
|
||||
world.queueBlockBreakEffect(server, pos, initialType, distanceSq);
|
||||
|
||||
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
||||
|
||||
recurse(server, editSession, world, pos.add(1, 0, 0),
|
||||
origin, size, initialType, visited);
|
||||
recurse(server, editSession, world, pos.add(-1, 0, 0),
|
||||
origin, size, initialType, visited);
|
||||
recurse(server, editSession, world, pos.add(0, 0, 1),
|
||||
origin, size, initialType, visited);
|
||||
recurse(server, editSession, world, pos.add(0, 0, -1),
|
||||
origin, size, initialType, visited);
|
||||
recurse(server, editSession, world, pos.add(0, 1, 0),
|
||||
origin, size, initialType, visited);
|
||||
recurse(server, editSession, world, pos.add(0, -1, 0),
|
||||
origin, size, initialType, visited);
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
}
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -42,6 +43,7 @@ public class SinglePickaxe implements BlockTool {
|
||||
@Override
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||
World world = (World) clicked.getExtent();
|
||||
<<<<<<< HEAD
|
||||
final BlockType blockType = world.getLazyBlock(clicked.toVector()).getBlockType();
|
||||
if (blockType == BlockTypes.BEDROCK && !player.canDestroyBedrock()) {
|
||||
return true;
|
||||
@ -49,6 +51,21 @@ public class SinglePickaxe implements BlockTool {
|
||||
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
||||
=======
|
||||
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||
final BlockType blockType = world.getBlock(blockPoint).getBlockType();
|
||||
if (blockType == BlockTypes.BEDROCK
|
||||
&& !player.canDestroyBedrock()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
||||
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
try {
|
||||
if (editSession.setBlock(clicked.getBlockX(), clicked.getBlockY(), clicked.getBlockZ(), EditSession.nullBlock)) {
|
||||
|
@ -50,6 +50,7 @@ public class TreePlanter implements BlockTool {
|
||||
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
|
||||
<<<<<<< HEAD
|
||||
try {
|
||||
boolean successful = false;
|
||||
|
||||
@ -57,6 +58,13 @@ public class TreePlanter implements BlockTool {
|
||||
if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0))) {
|
||||
successful = true;
|
||||
break;
|
||||
=======
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0).toBlockPoint())) {
|
||||
successful = true;
|
||||
break;
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,8 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* A brush is a long-range build tool.
|
||||
@ -39,6 +38,6 @@ public interface Brush {
|
||||
* @param size the size of the brush
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
void build(EditSession editSession, Vector position, Pattern pattern, double size) throws WorldEditException;
|
||||
void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException;
|
||||
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
|
||||
import java.util.List;
|
||||
@ -40,7 +40,7 @@ public class ButcherBrush implements Brush {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
CylinderRegion region = CylinderRegion.createRadius(editSession, position, size);
|
||||
List<? extends Entity> entities = editSession.getEntities(region);
|
||||
Operations.completeLegacy(new EntityVisitor(entities.iterator(), flags.createFunction()));
|
||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
|
||||
@ -42,10 +42,10 @@ public class ClipboardBrush implements Brush {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
Region region = clipboard.getRegion();
|
||||
Vector centerOffset = region.getCenter().subtract(clipboard.getOrigin());
|
||||
BlockVector3 centerOffset = region.getCenter().toBlockPoint().subtract(clipboard.getOrigin());
|
||||
|
||||
Operation operation = holder
|
||||
.createPaste(editSession)
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class CylinderBrush implements Brush {
|
||||
|
||||
@ -35,7 +35,7 @@ public class CylinderBrush implements Brush {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class GravityBrush implements Brush {
|
||||
@ -38,7 +38,7 @@ public class GravityBrush implements Brush {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
|
||||
Mask mask = editSession.getMask();
|
||||
if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) {
|
||||
mask = null;
|
||||
@ -47,12 +47,23 @@ public class GravityBrush implements Brush {
|
||||
int endY = position.getBlockY() + size;
|
||||
int startPerformY = Math.max(0, position.getBlockY() - size);
|
||||
int startCheckY = fullHeight ? 0 : startPerformY;
|
||||
Vector mutablePos = new Vector(0, 0, 0);
|
||||
// Vector mutablePos = new Vector(0, 0, 0);
|
||||
for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
||||
for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
||||
int freeSpot = startCheckY;
|
||||
for (int y = startCheckY; y <= endY; y++) {
|
||||
BlockStateHolder block = editSession.getLazyBlock(x, y, z);
|
||||
//=======
|
||||
// public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
// final double startY = fullHeight ? editSession.getWorld().getMaxY() : position.getBlockY() + size;
|
||||
// for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
||||
// for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
||||
// double y = startY;
|
||||
// final List<BlockStateHolder> blockTypes = new ArrayList<>();
|
||||
// for (; y > position.getBlockY() - size; --y) {
|
||||
// final BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
// final BlockStateHolder block = editSession.getBlock(pt);
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
if (!block.getBlockType().getMaterial().isAir()) {
|
||||
if (y != freeSpot) {
|
||||
editSession.setBlock(x, y, z, EditSession.nullBlock);
|
||||
@ -61,6 +72,17 @@ public class GravityBrush implements Brush {
|
||||
freeSpot = y + 1;
|
||||
}
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
//=======
|
||||
// BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
// Collections.reverse(blockTypes);
|
||||
// for (int i = 0; i < blockTypes.size();) {
|
||||
// if (editSession.getBlock(pt).getBlockType().getMaterial().isAir()) {
|
||||
// editSession.setBlock(pt, blockTypes.get(i++));
|
||||
// }
|
||||
// pt = pt.add(0, 1, 0);
|
||||
// }
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,12 +21,10 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class HollowCylinderBrush implements Brush {
|
||||
|
||||
@ -37,7 +35,7 @@ public class HollowCylinderBrush implements Brush {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
if (pattern == null) {
|
||||
pattern = BlockTypes.COBBLESTONE.getDefaultState();
|
||||
}
|
||||
|
@ -21,17 +21,15 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class HollowSphereBrush implements Brush {
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
if (pattern == null) {
|
||||
pattern = BlockTypes.COBBLESTONE.getDefaultState();
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.EditContext;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||
|
||||
public class OperationFactoryBrush implements Brush {
|
||||
@ -40,7 +40,7 @@ public class OperationFactoryBrush implements Brush {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
EditContext context = new EditContext();
|
||||
context.setDestination(editSession);
|
||||
context.setRegion(regionFactory.createCenteredAt(position, size));
|
||||
|
@ -23,7 +23,9 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
@ -39,10 +41,11 @@ public class SmoothBrush implements Brush {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
Location min = new Location(editSession.getWorld(), position.subtract(size, size, size));
|
||||
Vector max = position.add(size, size + 10, size);
|
||||
Region region = new CuboidRegion(editSession.getWorld(), min.toVector(), max);
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
Vector3 posDouble = position.toVector3();
|
||||
Location min = new Location(editSession.getWorld(), posDouble.subtract(size, size, size));
|
||||
BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint();
|
||||
Region region = new CuboidRegion(editSession.getWorld(), min.toVector().toBlockPoint(), max);
|
||||
HeightMap heightMap = new HeightMap(editSession, region);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
heightMap.applyFilter(filter, iterations);
|
||||
|
@ -21,17 +21,16 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class SphereBrush implements Brush {
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
|
@ -19,17 +19,20 @@
|
||||
|
||||
package com.sk89q.worldedit.entity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.sk89q.worldedit.PlayerDirection;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
|
||||
/**
|
||||
@ -254,13 +257,24 @@ public interface Player extends Entity, Actor {
|
||||
* @param pitch the pitch (up/down) of the player's view in degrees
|
||||
* @param yaw the yaw (left/right) of the player's view in degrees
|
||||
*/
|
||||
void setPosition(Vector pos, float pitch, float yaw);
|
||||
void setPosition(Vector3 pos, float pitch, float yaw);
|
||||
|
||||
/**
|
||||
* Move the player.
|
||||
*
|
||||
* @param pos where to move them
|
||||
*/
|
||||
void setPosition(Vector pos);
|
||||
void setPosition(Vector3 pos);
|
||||
|
||||
/**
|
||||
* Sends a fake block to the client.
|
||||
*
|
||||
* <p>
|
||||
* This block isn't real.
|
||||
* </p>
|
||||
*
|
||||
* @param pos The position of the block
|
||||
* @param block The block to send, null to reset
|
||||
*/
|
||||
void sendFakeBlock(BlockVector3 pos, @Nullable BlockStateHolder block);
|
||||
}
|
||||
|
@ -20,13 +20,17 @@
|
||||
package com.sk89q.worldedit.event.extent;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.event.Cancellable;
|
||||
=======
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.event.Event;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -55,7 +59,11 @@ import static com.sk89q.worldedit.EditSession.Stage;
|
||||
* is set to {@link Stage#BEFORE_HISTORY}, then you can drop (or log) changes
|
||||
* before the change has reached the history, reordering, and actual change
|
||||
* extents, <em>but</em> that means that any changes made with
|
||||
<<<<<<< HEAD
|
||||
* {@link EditSession#rawSetBlock(Vector, BaseBlock)} will skip your
|
||||
=======
|
||||
* {@link EditSession#rawSetBlock(BlockVector3, BlockStateHolder)} will skip your
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
* custom {@link Extent} because that method bypasses history (and reorder).
|
||||
* It is thus recommended that loggers intercept at {@link Stage#BEFORE_CHANGE}
|
||||
* and block interceptors intercept at BOTH {@link Stage#BEFORE_CHANGE} and
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.extension.factory;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.command.SuggestInputParseException;
|
||||
import com.boydti.fawe.jnbt.JSON2NBT;
|
||||
import com.boydti.fawe.jnbt.NBTException;
|
||||
@ -30,6 +31,13 @@ import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
=======
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.NotABlockException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
|
||||
import com.sk89q.worldedit.blocks.SignBlock;
|
||||
import com.sk89q.worldedit.blocks.SkullBlock;
|
||||
@ -44,6 +52,11 @@ import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -198,7 +211,11 @@ public class DefaultBlockParser extends InputParser<BlockStateHolder> {
|
||||
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
|
||||
// Get the block type from the "primary position"
|
||||
final World world = context.requireWorld();
|
||||
<<<<<<< HEAD
|
||||
final Vector primaryPosition;
|
||||
=======
|
||||
final BlockVector3 primaryPosition;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
try {
|
||||
primaryPosition = context.requireSession().getRegionSelector(world).getVerticies().get(index - 1);
|
||||
} catch (IncompleteRegionException e) {
|
||||
|
@ -1,11 +1,15 @@
|
||||
package com.sk89q.worldedit.extension.factory;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.command.FaweParser;
|
||||
import com.boydti.fawe.command.SuggestInputParseException;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
=======
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.MaskCommands;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
@ -16,9 +20,24 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
import com.sk89q.worldedit.internal.command.ActorAuthorizer;
|
||||
import com.sk89q.worldedit.internal.command.WorldEditBinding;
|
||||
=======
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.NoiseFilter;
|
||||
import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.util.command.SimpleDispatcher;
|
||||
@ -150,6 +169,7 @@ public class DefaultMaskParser extends FaweParser<Mask> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
<<<<<<< HEAD
|
||||
List<String> args = entry.getValue();
|
||||
String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
|
||||
try {
|
||||
@ -178,10 +198,55 @@ public class DefaultMaskParser extends FaweParser<Mask> {
|
||||
throw new InputParseException(e2.getMessage());
|
||||
}
|
||||
});
|
||||
=======
|
||||
throw new NoMatchException("Unrecognized mask '" + component + '\'');
|
||||
}
|
||||
|
||||
case '>':
|
||||
case '<':
|
||||
Mask submask;
|
||||
if (component.length() > 1) {
|
||||
submask = getBlockMaskComponent(masks, component.substring(1), context);
|
||||
} else {
|
||||
submask = new ExistingBlockMask(extent);
|
||||
}
|
||||
OffsetMask offsetMask = new OffsetMask(submask, new BlockVector3(0, firstChar == '>' ? -1 : 1, 0));
|
||||
return new MaskIntersection(offsetMask, Masks.negate(submask));
|
||||
|
||||
case '$':
|
||||
Set<BaseBiome> biomes = new HashSet<>();
|
||||
String[] biomesList = component.substring(1).split(",");
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
|
||||
for (String biomeName : biomesList) {
|
||||
BaseBiome biome = Biomes.findBiomeByName(knownBiomes, biomeName, biomeRegistry);
|
||||
if (biome == null) {
|
||||
throw new InputParseException("Unknown biome '" + biomeName + '\'');
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
if (pe.and) {
|
||||
masks.add(new ArrayList<>());
|
||||
=======
|
||||
|
||||
return Masks.asMask(new BiomeMask2D(context.requireExtent(), biomes));
|
||||
|
||||
case '%':
|
||||
int i = Integer.parseInt(component.substring(1));
|
||||
return new NoiseFilter(new RandomNoise(), ((double) i) / 100);
|
||||
|
||||
case '=':
|
||||
try {
|
||||
Expression exp = Expression.compile(component.substring(1), "x", "y", "z");
|
||||
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(
|
||||
Request.request().getEditSession(), Vector3.ONE, Vector3.ZERO);
|
||||
exp.setEnvironment(env);
|
||||
return new ExpressionMask(exp);
|
||||
} catch (ExpressionException e) {
|
||||
throw new InputParseException("Invalid expression: " + e.getMessage());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
masks.get(masks.size() - 1).add(mask);
|
||||
}
|
||||
|
@ -21,10 +21,22 @@ package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
import com.sk89q.worldedit.NotABlockException;
|
||||
import com.sk89q.worldedit.PlayerDirection;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
=======
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TargetBlock;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -107,7 +119,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
byte free = 0;
|
||||
|
||||
while (y <= world.getMaximumPoint().getBlockY() + 2) {
|
||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
@ -115,9 +127,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
if (free == 2) {
|
||||
if (y - 1 != origY) {
|
||||
<<<<<<< HEAD
|
||||
final Vector pos = new Vector(x, y - 2, z);
|
||||
final BlockStateHolder state = world.getBlock(pos);
|
||||
setPosition(new Vector(x + 0.5, y - 2 + BlockType.centralTopLimit(state), z + 0.5));
|
||||
=======
|
||||
setPosition(new Vector3(x + 0.5, y - 2 + 1, z + 0.5));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
return;
|
||||
@ -135,10 +151,17 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
int z = searchPos.getBlockZ();
|
||||
|
||||
while (y >= 0) {
|
||||
<<<<<<< HEAD
|
||||
final Vector pos = new Vector(x, y, z);
|
||||
final BlockStateHolder id = world.getBlock(pos);
|
||||
if (id.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id), z + 0.5));
|
||||
=======
|
||||
final BlockVector3 pos = new BlockVector3(x, y, z);
|
||||
final BlockState id = world.getBlock(pos);
|
||||
if (id.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
setPosition(new Vector3(x + 0.5, y + 1, z + 0.5));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return;
|
||||
}
|
||||
|
||||
@ -162,6 +185,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
int maxY = world.getMaxY();
|
||||
if (y >= maxY) return false;
|
||||
|
||||
<<<<<<< HEAD
|
||||
BlockMaterial initialMaterial = world.getBlockType(new Vector(x, y, z)).getMaterial();
|
||||
|
||||
boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube();
|
||||
@ -180,6 +204,29 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
if (!lastState) {
|
||||
lastState = BlockType.centralBottomLimit(state) != 1;
|
||||
continue;
|
||||
=======
|
||||
while (y <= world.getMaximumPoint().getY() + 2) {
|
||||
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
}
|
||||
|
||||
if (free == 2) {
|
||||
++spots;
|
||||
if (spots == 2) {
|
||||
final BlockVector3 platform = new BlockVector3(x, y - 2, z);
|
||||
final BlockStateHolder block = world.getBlock(platform);
|
||||
final com.sk89q.worldedit.world.block.BlockType type = block.getBlockType();
|
||||
|
||||
// Don't get put in lava!
|
||||
if (type == BlockTypes.LAVA) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setPosition(platform.toVector3().add(0.5, 1, 0.5));
|
||||
return true;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
if (freeStart == -1) {
|
||||
freeStart = level + BlockType.centralTopLimit(state);
|
||||
@ -213,6 +260,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
BlockMaterial initialMaterial = world.getBlockType(new Vector(x, y, z)).getMaterial();
|
||||
|
||||
<<<<<<< HEAD
|
||||
boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube();
|
||||
|
||||
double height = 1.85;
|
||||
@ -241,6 +289,28 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
double space = freeEnd - freeStart;
|
||||
if (space >= height) {
|
||||
setPosition(new Vector(x + 0.5, freeStart, z + 0.5));
|
||||
=======
|
||||
while (y >= 1) {
|
||||
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
}
|
||||
|
||||
if (free == 2) {
|
||||
// So we've found a spot, but we have to drop the player
|
||||
// lightly and also check to see if there's something to
|
||||
// stand upon
|
||||
while (y >= 0) {
|
||||
final BlockVector3 platform = new BlockVector3(x, y, z);
|
||||
final BlockStateHolder block = world.getBlock(platform);
|
||||
final BlockType type = block.getBlockType();
|
||||
|
||||
// Don't want to end up in lava
|
||||
if (!type.getMaterial().isAir() && type != BlockTypes.LAVA) {
|
||||
// Found a block!
|
||||
setPosition(platform.toVector3().add(0.5, 1, 0.5));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return true;
|
||||
}
|
||||
// Not enough room, reset the free position
|
||||
@ -271,13 +341,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
Extent world = getLocation().getExtent();
|
||||
|
||||
// No free space above
|
||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isAir()) {
|
||||
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (y <= world.getMaximumPoint().getY()) {
|
||||
// Found a ceiling!
|
||||
if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
int platformY = Math.max(initialY, y - 3 - clearance);
|
||||
floatAt(x, platformY + 1, z, alwaysGlass);
|
||||
return true;
|
||||
@ -305,7 +375,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
final Extent world = getLocation().getExtent();
|
||||
|
||||
while (y <= world.getMaximumPoint().getY() + 2) {
|
||||
if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
break; // Hit something
|
||||
} else if (y > maxY + 1) {
|
||||
break;
|
||||
@ -322,26 +392,41 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
@Override
|
||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
||||
<<<<<<< HEAD
|
||||
Vector spot = new Vector(x, y - 1, z);
|
||||
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
try {
|
||||
getLocation().getExtent().setBlock(new Vector(x, y - 1, z), BlockTypes.GLASS.getDefaultState());
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
=======
|
||||
try {
|
||||
BlockVector3 spot = new BlockVector3(x, y - 1, z);
|
||||
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
setPosition(new Vector(x + 0.5, y, z + 0.5));
|
||||
setPosition(new Vector3(x + 0.5, y, z + 0.5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBlockIn() {
|
||||
<<<<<<< HEAD
|
||||
Location loc = getLocation();
|
||||
return new Location(loc.getExtent(), loc.toBlockVector(), loc.getDirection());
|
||||
=======
|
||||
return getLocation().setPosition(getLocation().toVector().floor());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBlockOn() {
|
||||
<<<<<<< HEAD
|
||||
return getLocation().setY(getLocation().getY() - 1);
|
||||
=======
|
||||
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -416,7 +501,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
boolean inFree = false;
|
||||
|
||||
while ((block = hitBlox.getNextBlock()) != null) {
|
||||
boolean free = !world.getBlock(block.toVector()).getBlockType().getMaterial().isMovementBlocker();
|
||||
boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType().getMaterial().isMovementBlocker();
|
||||
|
||||
if (firstBlock) {
|
||||
firstBlock = false;
|
||||
@ -450,7 +535,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos) {
|
||||
public void setPosition(Vector3 pos) {
|
||||
setPosition(pos, getLocation().getPitch(), getLocation().getYaw());
|
||||
}
|
||||
|
||||
@ -522,4 +607,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
@Override
|
||||
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
|
||||
|
||||
}
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||
@ -31,9 +32,23 @@ import com.boydti.fawe.wrappers.WorldWrapper;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.command.tool.*;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.tool.BlockTool;
|
||||
import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
|
||||
import com.sk89q.worldedit.command.tool.DoubleActionTraceTool;
|
||||
import com.sk89q.worldedit.command.tool.Tool;
|
||||
import com.sk89q.worldedit.command.tool.TraceTool;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.*;
|
||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
@ -290,6 +305,7 @@ public class PlatformManager {
|
||||
public void handleBlockInteract(BlockInteractEvent event) {
|
||||
// Create a proxy actor with a potentially different world for
|
||||
// making changes to the world
|
||||
<<<<<<< HEAD
|
||||
Request.reset();
|
||||
final Actor actor = createProxyActor(event.getCause());
|
||||
try {
|
||||
@ -306,6 +322,12 @@ public class PlatformManager {
|
||||
virtual.handleBlockInteract(playerActor, vector, event);
|
||||
if (event.isCancelled()) return;
|
||||
}
|
||||
=======
|
||||
Actor actor = createProxyActor(event.getCause());
|
||||
|
||||
Location location = event.getLocation();
|
||||
Vector3 vector = location.toVector();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (event.getType() == Interaction.HIT) {
|
||||
if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().equals(getConfiguration().wandItem)) {
|
||||
@ -342,6 +364,7 @@ public class PlatformManager {
|
||||
return;
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
final Tool tool = session.getTool(playerActor);
|
||||
if (tool != null && tool instanceof DoubleActionBlockTool) {
|
||||
if (tool.canUse(playerActor)) {
|
||||
@ -356,6 +379,14 @@ public class PlatformManager {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
=======
|
||||
|
||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||
|
||||
BlockVector3 blockPoint = vector.toBlockPoint();
|
||||
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainPrimarySelection(actor, session, blockPoint);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
} else if (event.getType() == Interaction.OPEN) {
|
||||
if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().equals(getConfiguration().wandItem)) {
|
||||
@ -379,6 +410,7 @@ public class PlatformManager {
|
||||
return;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
final Tool tool = session.getTool(playerActor);
|
||||
if (tool != null && tool instanceof BlockTool) {
|
||||
if (tool.canUse(playerActor)) {
|
||||
@ -399,6 +431,23 @@ public class PlatformManager {
|
||||
return;
|
||||
}
|
||||
}
|
||||
=======
|
||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||
BlockVector3 blockPoint = vector.toBlockPoint();
|
||||
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainSecondarySelection(actor, session, blockPoint);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
if (tool instanceof BlockTool) {
|
||||
if (tool.canUse(player)) {
|
||||
((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||
event.setCancelled(true);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,15 +19,20 @@
|
||||
|
||||
package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -46,7 +51,7 @@ public class PlayerProxy extends AbstractPlayerActor {
|
||||
private final Actor permActor;
|
||||
private final Actor cuiActor;
|
||||
private final World world;
|
||||
private Vector offset = Vector.ZERO;
|
||||
private Vector3 offset = Vector3.ZERO;
|
||||
|
||||
public PlayerProxy(Player basePlayer, Actor permActor, Actor cuiActor, World world) {
|
||||
checkNotNull(basePlayer);
|
||||
@ -59,7 +64,7 @@ public class PlayerProxy extends AbstractPlayerActor {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void setOffset(Vector position) {
|
||||
public void setOffset(Vector3 position) {
|
||||
this.offset = position;
|
||||
}
|
||||
|
||||
@ -106,7 +111,7 @@ public class PlayerProxy extends AbstractPlayerActor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||
basePlayer.setPosition(pos, pitch, yaw);
|
||||
}
|
||||
|
||||
@ -170,4 +175,10 @@ public class PlayerProxy extends AbstractPlayerActor {
|
||||
public void setGameMode(GameMode gameMode) {
|
||||
basePlayer.setGameMode(gameMode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
|
||||
basePlayer.sendFakeBlock(pos, block);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,32 +22,29 @@ package com.sk89q.worldedit.extent;
|
||||
import com.boydti.fawe.jnbt.anvil.generator.GenBase;
|
||||
import com.boydti.fawe.jnbt.anvil.generator.Resource;
|
||||
import com.boydti.fawe.object.extent.LightingExtent;
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* A base class for {@link Extent}s that merely passes extents onto another.
|
||||
*/
|
||||
@ -79,12 +76,12 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getBlockType(Vector position) {
|
||||
public BlockType getBlockType(BlockVector3 position) {
|
||||
return extent.getBlockType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getFullBlock(Vector position) {
|
||||
public BlockState getFullBlock(BlockVector3 position) {
|
||||
return extent.getFullBlock(position);
|
||||
}
|
||||
|
||||
@ -127,11 +124,6 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
return extent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
return extent.getLazyBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
mutable.mutX(x);
|
||||
@ -141,7 +133,7 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(Vector position) {
|
||||
public BlockState getLazyBlock(BlockVector3 position) {
|
||||
return extent.getLazyBlock(position);
|
||||
}
|
||||
|
||||
@ -152,9 +144,13 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
mutable.mutZ(z);
|
||||
return setBlock(mutable, block);
|
||||
}
|
||||
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return extent.getBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return extent.setBlock(location, block);
|
||||
}
|
||||
|
||||
@ -175,12 +171,12 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return extent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return extent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@ -195,12 +191,12 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return extent.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return extent.getMaximumPoint();
|
||||
}
|
||||
|
||||
@ -254,7 +250,7 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector pt) {
|
||||
public boolean contains(BlockVector3 pt) {
|
||||
return extent.contains(pt);
|
||||
}
|
||||
|
||||
|
@ -19,20 +19,32 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
import com.sk89q.worldedit.history.change.EntityCreate;
|
||||
import com.sk89q.worldedit.history.change.EntityRemove;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
<<<<<<< HEAD
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -59,9 +71,15 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
BlockStateHolder previous = getBlock(location);
|
||||
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
||||
=======
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
BaseBlock previous = getFullBlock(location);
|
||||
changeSet.add(new BlockChange(location, previous, block));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,11 @@ import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.registry.state.PropertyGroup;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
@ -63,7 +66,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
*
|
||||
* @return the minimum point
|
||||
*/
|
||||
Vector getMinimumPoint();
|
||||
BlockVector3 getMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the maximum point in the extent.
|
||||
@ -73,7 +76,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
*
|
||||
* @return the maximum point
|
||||
*/
|
||||
Vector getMaximumPoint();
|
||||
BlockVector3 getMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get a list of all entities within the given region.
|
||||
@ -114,25 +117,25 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
default BlockState getBlock(Vector position) {
|
||||
default BlockState getBlock(BlockVector3 position) {
|
||||
return getFullBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
default BlockState getLazyBlock(Vector position) {
|
||||
default BlockState getLazyBlock(BlockVector3 position) {
|
||||
return getFullBlock(position);
|
||||
}
|
||||
|
||||
default BlockState getLazyBlock(int x, int y, int z) {
|
||||
return getLazyBlock(MutableBlockVector.get(x, y, z));
|
||||
return getLazyBlock(new BlockVector3(x, y, z));
|
||||
}
|
||||
|
||||
default boolean setBlock(int x, int y, int z, BlockStateHolder state) throws WorldEditException {
|
||||
return setBlock(MutableBlockVector.get(x, y, z), state);
|
||||
return setBlock(new BlockVector3(x, y, z), state);
|
||||
}
|
||||
|
||||
default boolean setBiome(int x, int y, int z, BaseBiome biome) {
|
||||
return setBiome(MutableBlockVector2D.get(x, z), biome);
|
||||
return setBiome(new BlockVector2(x, z), biome);
|
||||
}
|
||||
|
||||
default int getHighestTerrainBlock(final int x, final int z, int minY, int maxY) {
|
||||
@ -252,7 +255,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
|
||||
default void generate(Region region, GenBase gen) throws WorldEditException {
|
||||
for (Vector2D chunkPos : region.getChunks()) {
|
||||
for (BlockVector2 chunkPos : region.getChunks()) {
|
||||
gen.generate(chunkPos, this);
|
||||
}
|
||||
}
|
||||
@ -263,7 +266,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
|
||||
default void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
for (Vector2D chunkPos : region.getChunks()) {
|
||||
for (BlockVector2 chunkPos : region.getChunks()) {
|
||||
for (int i = 0; i < frequency; i++) {
|
||||
if (random.nextInt(100) > rarity) {
|
||||
continue;
|
||||
@ -275,9 +278,9 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
}
|
||||
|
||||
default boolean contains(Vector pt) {
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
default boolean contains(BlockVector3 pt) {
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
return (pt.containedWithin(min, max));
|
||||
}
|
||||
|
||||
@ -309,7 +312,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
default List<Countable<BlockType>> getBlockDistribution(final Region region) {
|
||||
int[] counter = new int[BlockTypes.size()];
|
||||
|
||||
for (final Vector pt : region) {
|
||||
for (final BlockVector3 pt : region) {
|
||||
BlockType type = getBlockType(pt);
|
||||
counter[type.getInternalId()]++;
|
||||
}
|
||||
@ -333,7 +336,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
default List<Countable<BlockStateHolder>> getBlockDistributionWithData(final Region region) {
|
||||
int[][] counter = new int[BlockTypes.size()][];
|
||||
|
||||
for (final Vector pt : region) {
|
||||
for (final BlockVector3 pt : region) {
|
||||
BlockStateHolder blk = this.getBlock(pt);
|
||||
BlockType type = blk.getBlockType();
|
||||
int[] stateCounter = counter[type.getInternalId()];
|
||||
|
@ -19,14 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
@ -49,9 +45,9 @@ public interface InputExtent {
|
||||
* @param position position of the block
|
||||
* @return the block
|
||||
*/
|
||||
BlockState getBlock(Vector position);
|
||||
BlockState getBlock(BlockVector3 position);
|
||||
|
||||
default BlockType getBlockType(Vector position) {
|
||||
default BlockType getBlockType(BlockVector3 position) {
|
||||
return getBlock(position).getBlockType();
|
||||
}
|
||||
|
||||
@ -76,7 +72,7 @@ public interface InputExtent {
|
||||
* @param position position of the block
|
||||
* @return the block
|
||||
*/
|
||||
BlockState getLazyBlock(Vector position);
|
||||
BlockState getLazyBlock(BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Get a immutable snapshot of the block at the given location.
|
||||
@ -84,7 +80,7 @@ public interface InputExtent {
|
||||
* @param position position of the block
|
||||
* @return the block
|
||||
*/
|
||||
BlockState getFullBlock(Vector position);
|
||||
BlockState getFullBlock(BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Get the biome at the given location.
|
||||
@ -95,6 +91,6 @@ public interface InputExtent {
|
||||
* @param position the (x, z) location to check the biome at
|
||||
* @return the biome at the location
|
||||
*/
|
||||
BaseBiome getBiome(Vector2D position);
|
||||
BaseBiome getBiome(BlockVector2 position);
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,23 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
|
||||
@ -72,7 +81,7 @@ public class MaskingExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return mask.test(location) && super.setBlock(location, block);
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||
@ -32,9 +31,24 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
=======
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
@ -46,18 +60,21 @@ import java.util.List;
|
||||
*/
|
||||
public class NullExtent implements Extent {
|
||||
|
||||
<<<<<<< HEAD
|
||||
private final Vector nullPoint = new Vector(0, 0, 0);
|
||||
|
||||
public static final NullExtent INSTANCE = new NullExtent();
|
||||
|
||||
=======
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return nullPoint;
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return nullPoint;
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,11 +94,12 @@ public class NullExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public BlockState getLazyBlock(Vector position) {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
@ -89,21 +107,25 @@ public class NullExtent implements Extent {
|
||||
@Override
|
||||
public BlockState getFullBlock(Vector position) {
|
||||
return new BaseBlock(getBlock(position));
|
||||
=======
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return getBlock(position).toBaseBlock();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -51,7 +51,7 @@ public interface OutputExtent {
|
||||
* @return true if the block was successfully set (return value may not be accurate)
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException;
|
||||
boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException;
|
||||
|
||||
/**
|
||||
* Set the biome.
|
||||
@ -60,7 +60,7 @@ public interface OutputExtent {
|
||||
* @param biome the biome to set to
|
||||
* @return true if the biome was successfully set (return value may not be accurate)
|
||||
*/
|
||||
boolean setBiome(Vector2D position, BaseBiome biome);
|
||||
boolean setBiome(BlockVector2 position, BaseBiome biome);
|
||||
|
||||
/**
|
||||
* Return an {@link Operation} that should be called to tie up loose ends
|
||||
|
@ -21,8 +21,6 @@ package com.sk89q.worldedit.extent.buffer;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -32,6 +30,8 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
@ -45,19 +45,19 @@ import java.util.Map;
|
||||
* actual application of the changes.
|
||||
*
|
||||
* <p>This buffer will not attempt to return results from the buffer when
|
||||
* accessor methods (such as {@link #getBlock(Vector)}) are called.</p>
|
||||
* accessor methods (such as {@link #getBlock(BlockVector3)}) are called.</p>
|
||||
*/
|
||||
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
|
||||
|
||||
private final Map<BlockVector, BlockStateHolder> buffer = new LinkedHashMap<>();
|
||||
private final Map<BlockVector3, BlockStateHolder> buffer = new LinkedHashMap<>();
|
||||
private final Mask mask;
|
||||
private Vector min = null;
|
||||
private Vector max = null;
|
||||
private BlockVector3 min = null;
|
||||
private BlockVector3 max = null;
|
||||
|
||||
/**
|
||||
* Create a new extent buffer that will buffer every change.
|
||||
*
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(Vector)}, etc. calls
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||
*/
|
||||
public ForgetfulExtentBuffer(Extent delegate) {
|
||||
this(delegate, Masks.alwaysTrue());
|
||||
@ -67,7 +67,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
* Create a new extent buffer that will buffer changes that meet the criteria
|
||||
* of the given mask.
|
||||
*
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(Vector)}, etc. calls
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||
* @param mask the mask
|
||||
*/
|
||||
public ForgetfulExtentBuffer(Extent delegate, Mask mask) {
|
||||
@ -78,22 +78,22 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
// Update minimum
|
||||
if (min == null) {
|
||||
min = location;
|
||||
} else {
|
||||
min = Vector.getMinimum(min, location);
|
||||
min = min.getMinimum(location);
|
||||
}
|
||||
|
||||
// Update maximum
|
||||
if (max == null) {
|
||||
max = location;
|
||||
} else {
|
||||
max = Vector.getMaximum(max, location);
|
||||
max = max.getMaximum(location);
|
||||
}
|
||||
|
||||
BlockVector blockVector = location.toBlockVector();
|
||||
BlockVector3 blockVector = location;
|
||||
if (mask.test(blockVector)) {
|
||||
buffer.put(blockVector, block);
|
||||
return true;
|
||||
@ -103,8 +103,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector pos) {
|
||||
BlockStateHolder block = buffer.get(pos.toBlockVector());
|
||||
public BlockStateHolder apply(BlockVector3 pos) {
|
||||
BlockStateHolder block = buffer.get(pos);
|
||||
if (block != null) {
|
||||
return block;
|
||||
} else {
|
||||
@ -120,32 +120,32 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
public Region asRegion() {
|
||||
return new AbstractRegion(null) {
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return min != null ? min : new Vector();
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return min != null ? min : BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return max != null ? max : new Vector();
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return max != null ? max : BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new UnsupportedOperationException("Cannot change the size of this region");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new UnsupportedOperationException("Cannot change the size of this region");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
return buffer.containsKey(position.toBlockVector());
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return buffer.containsKey(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return buffer.keySet().iterator();
|
||||
}
|
||||
};
|
||||
|
@ -19,15 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.cache;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
/**
|
||||
* Returns the same cached {@link BlockState} for repeated calls to
|
||||
* {@link #getBlock(Vector)} with the same position.
|
||||
* {@link #getBlock(BlockVector3)} with the same position.
|
||||
*/
|
||||
public class LastAccessExtentCache extends AbstractDelegateExtent {
|
||||
|
||||
@ -43,23 +43,22 @@ public class LastAccessExtentCache extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
BlockVector blockVector = position.toBlockVector();
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
CachedBlock lastBlock = this.lastBlock;
|
||||
if (lastBlock != null && lastBlock.position.equals(blockVector)) {
|
||||
if (lastBlock != null && lastBlock.position.equals(position)) {
|
||||
return lastBlock.block;
|
||||
} else {
|
||||
BlockState block = super.getBlock(position);
|
||||
this.lastBlock = new CachedBlock(blockVector, block);
|
||||
this.lastBlock = new CachedBlock(position, block);
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
private static class CachedBlock {
|
||||
private final BlockVector position;
|
||||
private final BlockVector3 position;
|
||||
private final BlockState block;
|
||||
|
||||
private CachedBlock(BlockVector position, BlockState block) {
|
||||
private CachedBlock(BlockVector3 position, BlockState block) {
|
||||
this.position = position;
|
||||
this.block = block;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard;
|
||||
import com.boydti.fawe.object.clipboard.FaweClipboard;
|
||||
@ -32,12 +33,24 @@ import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import java.io.Closeable;
|
||||
@ -56,6 +69,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable {
|
||||
|
||||
<<<<<<< HEAD
|
||||
private Region region;
|
||||
public FaweClipboard IMP;
|
||||
private Vector size;
|
||||
@ -75,6 +89,12 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
this.my = origin.getBlockY();
|
||||
this.mz = origin.getBlockZ();
|
||||
}
|
||||
=======
|
||||
private final Region region;
|
||||
private BlockVector3 origin;
|
||||
private final BlockStateHolder[][][] blocks;
|
||||
private final List<ClipboardEntity> entities = new ArrayList<>();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -94,6 +114,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
this.mz = origin.getBlockZ();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public BlockArrayClipboard(Region region, FaweClipboard clipboard) {
|
||||
checkNotNull(region);
|
||||
this.region = region.clone();
|
||||
@ -125,6 +146,10 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
@Override
|
||||
public void close() {
|
||||
IMP.close();
|
||||
=======
|
||||
BlockVector3 dimensions = getDimensions();
|
||||
blocks = new BlockStateHolder[dimensions.getBlockX()][dimensions.getBlockY()][dimensions.getBlockZ()];
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,36 +162,42 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getOrigin() {
|
||||
public BlockVector3 getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrigin(Vector origin) {
|
||||
public void setOrigin(BlockVector3 origin) {
|
||||
this.origin = origin;
|
||||
IMP.setOrigin(origin.subtract(region.getMinimumPoint()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getDimensions() {
|
||||
public BlockVector3 getDimensions() {
|
||||
return region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
<<<<<<< HEAD
|
||||
List<Entity> filtered = new ArrayList<Entity>();
|
||||
for (Entity entity : getEntities()) {
|
||||
if (region.contains(entity.getLocation().toVector())) {
|
||||
=======
|
||||
List<Entity> filtered = new ArrayList<>();
|
||||
for (Entity entity : entities) {
|
||||
if (region.contains(entity.getLocation().toVector().toBlockPoint())) {
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
filtered.add(entity);
|
||||
}
|
||||
}
|
||||
@ -185,12 +216,20 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
if (region.contains(position)) {
|
||||
<<<<<<< HEAD
|
||||
int x = position.getBlockX() - mx;
|
||||
int y = position.getBlockY() - my;
|
||||
int z = position.getBlockZ() - mz;
|
||||
return IMP.getBlock(x, y, z);
|
||||
=======
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
||||
if (block != null) {
|
||||
return block.toImmutableState();
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
return EditSession.nullBlock;
|
||||
}
|
||||
@ -200,9 +239,20 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public BlockState getLazyBlock(Vector position) {
|
||||
return getBlock(position);
|
||||
}
|
||||
=======
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
if (region.contains(position)) {
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
||||
if (block != null) {
|
||||
return block.toBaseBlock();
|
||||
}
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
@Override
|
||||
public BlockState getFullBlock(Vector position) {
|
||||
@ -210,12 +260,22 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
if (region.contains(location)) {
|
||||
final int x = location.getBlockX();
|
||||
final int y = location.getBlockY();
|
||||
final int z = location.getBlockZ();
|
||||
return setBlock(x, y, z, block);
|
||||
=======
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
if (region.contains(position)) {
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = block;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -236,6 +296,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
int x = position.getBlockX() - mx;
|
||||
int z = position.getBlockZ() - mz;
|
||||
@ -248,6 +309,15 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
int z = position.getBlockZ() - mz;
|
||||
IMP.setBiome(x, z, biome.getId());
|
||||
return true;
|
||||
=======
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return new BaseBiome(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return false;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
@ -42,20 +42,20 @@ public interface Clipboard extends Extent {
|
||||
*
|
||||
* @return the dimensions
|
||||
*/
|
||||
Vector getDimensions();
|
||||
BlockVector3 getDimensions();
|
||||
|
||||
/**
|
||||
* Get the origin point from which the copy was made from.
|
||||
*
|
||||
* @return the origin
|
||||
*/
|
||||
Vector getOrigin();
|
||||
BlockVector3 getOrigin();
|
||||
|
||||
/**
|
||||
* Set the origin point from which the copy was made from.
|
||||
*
|
||||
* @param origin the origin
|
||||
*/
|
||||
void setOrigin(Vector origin);
|
||||
void setOrigin(BlockVector3 origin);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,316 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard.io;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.jnbt.ByteArrayTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NamedTag;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.SignCompatibilityHandler;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.storage.NBTConversions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Reads schematic files that are compatible with MCEdit and other editors.
|
||||
*/
|
||||
public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
|
||||
private static final List<NBTCompatibilityHandler> COMPATIBILITY_HANDLERS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
COMPATIBILITY_HANDLERS.add(new SignCompatibilityHandler());
|
||||
// TODO Add a handler for skulls, flower pots, note blocks, etc.
|
||||
}
|
||||
|
||||
private static final Logger log = Logger.getLogger(MCEditSchematicReader.class.getCanonicalName());
|
||||
private final NBTInputStream inputStream;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param inputStream the input stream to read from
|
||||
*/
|
||||
public MCEditSchematicReader(NBTInputStream inputStream) {
|
||||
checkNotNull(inputStream);
|
||||
this.inputStream = inputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clipboard read() throws IOException {
|
||||
// Schematic tag
|
||||
NamedTag rootTag = inputStream.readNamedTag();
|
||||
if (!rootTag.getName().equals("Schematic")) {
|
||||
throw new IOException("Tag 'Schematic' does not exist or is not first");
|
||||
}
|
||||
CompoundTag schematicTag = (CompoundTag) rootTag.getTag();
|
||||
|
||||
// Check
|
||||
Map<String, Tag> schematic = schematicTag.getValue();
|
||||
if (!schematic.containsKey("Blocks")) {
|
||||
throw new IOException("Schematic file is missing a 'Blocks' tag");
|
||||
}
|
||||
|
||||
// Check type of Schematic
|
||||
String materials = requireTag(schematic, "Materials", StringTag.class).getValue();
|
||||
if (!materials.equals("Alpha")) {
|
||||
throw new IOException("Schematic file is not an Alpha schematic");
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// Metadata
|
||||
// ====================================================================
|
||||
|
||||
BlockVector3 origin;
|
||||
Region region;
|
||||
|
||||
// Get information
|
||||
short width = requireTag(schematic, "Width", ShortTag.class).getValue();
|
||||
short height = requireTag(schematic, "Height", ShortTag.class).getValue();
|
||||
short length = requireTag(schematic, "Length", ShortTag.class).getValue();
|
||||
|
||||
try {
|
||||
int originX = requireTag(schematic, "WEOriginX", IntTag.class).getValue();
|
||||
int originY = requireTag(schematic, "WEOriginY", IntTag.class).getValue();
|
||||
int originZ = requireTag(schematic, "WEOriginZ", IntTag.class).getValue();
|
||||
BlockVector3 min = new BlockVector3(originX, originY, originZ);
|
||||
|
||||
int offsetX = requireTag(schematic, "WEOffsetX", IntTag.class).getValue();
|
||||
int offsetY = requireTag(schematic, "WEOffsetY", IntTag.class).getValue();
|
||||
int offsetZ = requireTag(schematic, "WEOffsetZ", IntTag.class).getValue();
|
||||
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
|
||||
|
||||
origin = min.subtract(offset);
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
} catch (IOException ignored) {
|
||||
origin = BlockVector3.ZERO;
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// Blocks
|
||||
// ====================================================================
|
||||
|
||||
// Get blocks
|
||||
byte[] blockId = requireTag(schematic, "Blocks", ByteArrayTag.class).getValue();
|
||||
byte[] blockData = requireTag(schematic, "Data", ByteArrayTag.class).getValue();
|
||||
byte[] addId = new byte[0];
|
||||
short[] blocks = new short[blockId.length]; // Have to later combine IDs
|
||||
|
||||
// We support 4096 block IDs using the same method as vanilla Minecraft, where
|
||||
// the highest 4 bits are stored in a separate byte array.
|
||||
if (schematic.containsKey("AddBlocks")) {
|
||||
addId = requireTag(schematic, "AddBlocks", ByteArrayTag.class).getValue();
|
||||
}
|
||||
|
||||
// Combine the AddBlocks data with the first 8-bit block ID
|
||||
for (int index = 0; index < blockId.length; index++) {
|
||||
if ((index >> 1) >= addId.length) { // No corresponding AddBlocks index
|
||||
blocks[index] = (short) (blockId[index] & 0xFF);
|
||||
} else {
|
||||
if ((index & 1) == 0) {
|
||||
blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (blockId[index] & 0xFF));
|
||||
} else {
|
||||
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (blockId[index] & 0xFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Need to pull out tile entities
|
||||
List<Tag> tileEntities = requireTag(schematic, "TileEntities", ListTag.class).getValue();
|
||||
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
|
||||
for (Tag tag : tileEntities) {
|
||||
if (!(tag instanceof CompoundTag)) continue;
|
||||
CompoundTag t = (CompoundTag) tag;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Tag> entry : t.getValue().entrySet()) {
|
||||
switch (entry.getKey()) {
|
||||
case "x":
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
x = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
case "y":
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
y = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
case "z":
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
z = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
int index = y * width * length + z * width + x;
|
||||
BlockState block = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
|
||||
if (block != null) {
|
||||
for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) {
|
||||
if (handler.isAffectedBlock(block)) {
|
||||
handler.updateNBT(block, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlockVector3 vec = new BlockVector3(x, y, z);
|
||||
tileEntitiesMap.put(vec, values);
|
||||
}
|
||||
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||
clipboard.setOrigin(origin);
|
||||
|
||||
// Don't log a torrent of errors
|
||||
int failedBlockSets = 0;
|
||||
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int z = 0; z < length; ++z) {
|
||||
int index = y * width * length + z * width + x;
|
||||
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
|
||||
|
||||
try {
|
||||
if (state != null) {
|
||||
if (tileEntitiesMap.containsKey(pt)) {
|
||||
clipboard.setBlock(region.getMinimumPoint().add(pt), state.toBaseBlock(new CompoundTag(tileEntitiesMap.get(pt))));
|
||||
} else {
|
||||
clipboard.setBlock(region.getMinimumPoint().add(pt), state);
|
||||
}
|
||||
} else {
|
||||
log.warning("Unknown block when pasting schematic: " + blocks[index] + ":" + blockData[index] + ". Please report this issue.");
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
switch (failedBlockSets) {
|
||||
case 0:
|
||||
log.log(Level.WARNING, "Failed to set block on a Clipboard", e);
|
||||
break;
|
||||
case 1:
|
||||
log.log(Level.WARNING, "Failed to set block on a Clipboard (again) -- no more messages will be logged", e);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
failedBlockSets++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// Entities
|
||||
// ====================================================================
|
||||
|
||||
try {
|
||||
List<Tag> entityTags = requireTag(schematic, "Entities", ListTag.class).getValue();
|
||||
|
||||
for (Tag tag : entityTags) {
|
||||
if (tag instanceof CompoundTag) {
|
||||
CompoundTag compound = (CompoundTag) tag;
|
||||
String id = convertEntityId(compound.getString("id"));
|
||||
Location location = NBTConversions.toLocation(clipboard, compound.getListTag("Pos"), compound.getListTag("Rotation"));
|
||||
|
||||
if (!id.isEmpty()) {
|
||||
EntityType entityType = EntityTypes.get(id.toLowerCase());
|
||||
if (entityType != null) {
|
||||
BaseEntity state = new BaseEntity(entityType, compound);
|
||||
clipboard.createEntity(location, state);
|
||||
} else {
|
||||
log.warning("Unknown entity when pasting schematic: " + id.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException ignored) { // No entities? No problem
|
||||
}
|
||||
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
private String convertEntityId(String id) {
|
||||
switch(id) {
|
||||
case "xp_orb":
|
||||
return "experience_orb";
|
||||
case "xp_bottle":
|
||||
return "experience_bottle";
|
||||
case "eye_of_ender_signal":
|
||||
return "eye_of_ender";
|
||||
case "ender_crystal":
|
||||
return "end_crystal";
|
||||
case "fireworks_rocket":
|
||||
return "firework_rocket";
|
||||
case "commandblock_minecart":
|
||||
return "command_block_minecart";
|
||||
case "snowman":
|
||||
return "snow_golem";
|
||||
case "villager_golem":
|
||||
return "iron_golem";
|
||||
case "evocation_fangs":
|
||||
return "evoker_fangs";
|
||||
case "evocation_illager":
|
||||
return "evoker";
|
||||
case "vindication_illager":
|
||||
return "vindicator";
|
||||
case "illusion_illager":
|
||||
return "illusioner";
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
@ -42,8 +42,12 @@ import com.sk89q.jnbt.NamedTag;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -51,6 +55,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -103,10 +108,18 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
return read(UUID.randomUUID());
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
@Override
|
||||
public Clipboard read(UUID uuid) throws IOException {
|
||||
return readVersion1(uuid);
|
||||
}
|
||||
=======
|
||||
private Clipboard readVersion1(Map<String, Tag> schematic) throws IOException {
|
||||
BlockVector3 origin;
|
||||
Region region;
|
||||
|
||||
Map<String, Tag> metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
private int width, height, length;
|
||||
private int offsetX, offsetY, offsetZ;
|
||||
@ -121,12 +134,35 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
return fc;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
if (Settings.IMP.CLIPBOARD.USE_DISK) {
|
||||
return fc = new DiskOptimizedClipboard(size, 1, 1, uuid);
|
||||
} else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) {
|
||||
return fc = new CPUOptimizedClipboard(size, 1, 1);
|
||||
} else {
|
||||
return fc = new MemoryOptimizedClipboard(size, 1, 1);
|
||||
=======
|
||||
|
||||
BlockVector3 min = new BlockVector3(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||
|
||||
if (metadata.containsKey("WEOffsetX")) {
|
||||
// We appear to have WorldEdit Metadata
|
||||
int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
|
||||
int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
|
||||
int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
|
||||
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
|
||||
origin = min.subtract(offset);
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
} else {
|
||||
origin = min;
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
}
|
||||
|
||||
int paletteMax = requireTag(schematic, "PaletteMax", IntTag.class).getValue();
|
||||
Map<String, Tag> paletteObject = requireTag(schematic, "Palette", CompoundTag.class).getValue();
|
||||
if (paletteObject.size() != paletteMax) {
|
||||
throw new IOException("Differing given palette size to actual size");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,6 +188,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
int index = ((IntTag) entry.getValue()).getValue();
|
||||
palette[index] = (char) state.getOrdinal();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
});
|
||||
streamer.addReader("Schematic.BlockData.#", new NBTStreamer.LazyReader() {
|
||||
@Override
|
||||
@ -161,6 +198,23 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
=======
|
||||
palette.put(id, state);
|
||||
}
|
||||
|
||||
byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
|
||||
|
||||
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
try {
|
||||
List<Map<String, Tag>> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream()
|
||||
.map(tag -> (CompoundTag) tag)
|
||||
.map(CompoundTag::getValue)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (Map<String, Tag> tileEntity : tileEntityTags) {
|
||||
int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
|
||||
tileEntitiesMap.put(new BlockVector3(pos[0], pos[1], pos[2]), tileEntity);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
});
|
||||
streamer.addReader("Schematic.Biomes.#", new NBTStreamer.LazyReader() {
|
||||
@ -207,6 +261,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
Fawe.debug("Invalid entity: " + id);
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
});
|
||||
streamer.readFully();
|
||||
if (fc == null) setupClipboard(length * width * height, uuid);
|
||||
@ -225,6 +280,21 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
for (int index = 0; index < volume; index++) {
|
||||
BlockState state = BlockTypes.states[palette[fis.read()]];
|
||||
fc.setBlock(index, state);
|
||||
=======
|
||||
// index = (y * length + z) * width + x
|
||||
int y = index / (width * length);
|
||||
int z = (index % (width * length)) / width;
|
||||
int x = (index % (width * length)) % width;
|
||||
BlockState state = palette.get(value);
|
||||
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
try {
|
||||
if (tileEntitiesMap.containsKey(pt)) {
|
||||
Map<String, Tag> values = Maps.newHashMap(tileEntitiesMap.get(pt));
|
||||
for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) {
|
||||
if (handler.isAffectedBlock(state)) {
|
||||
handler.updateNBT(state, values);
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
} else {
|
||||
for (int index = 0; index < volume; index++) {
|
||||
|
@ -27,15 +27,23 @@ import com.sk89q.jnbt.NBTConstants;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
=======
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -75,9 +83,15 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
public void write1(Clipboard clipboard) throws IOException {
|
||||
// metadata
|
||||
Region region = clipboard.getRegion();
|
||||
<<<<<<< HEAD
|
||||
Vector origin = clipboard.getOrigin();
|
||||
BlockVector min = region.getMinimumPoint().toBlockVector();
|
||||
Vector offset = min.subtract(origin);
|
||||
=======
|
||||
BlockVector3 origin = clipboard.getOrigin();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 offset = min.subtract(origin);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
int width = region.getWidth();
|
||||
int height = region.getHeight();
|
||||
int length = region.getLength();
|
||||
@ -90,6 +104,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
if (length > MAX_SIZE) {
|
||||
throw new IllegalArgumentException("Length of region too large for a .schematic");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
// output
|
||||
final DataOutput rawStream = outputStream.getOutputStream();
|
||||
outputStream.writeLazyCompoundTag("Schematic", out -> {
|
||||
@ -142,6 +157,49 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
}));
|
||||
numTiles[0]++;
|
||||
tilesOut.writeTagPayload(tile);
|
||||
=======
|
||||
|
||||
Map<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Version", new IntTag(1));
|
||||
|
||||
Map<String, Tag> metadata = new HashMap<>();
|
||||
metadata.put("WEOffsetX", new IntTag(offset.getBlockX()));
|
||||
metadata.put("WEOffsetY", new IntTag(offset.getBlockY()));
|
||||
metadata.put("WEOffsetZ", new IntTag(offset.getBlockZ()));
|
||||
|
||||
schematic.put("Metadata", new CompoundTag(metadata));
|
||||
|
||||
schematic.put("Width", new ShortTag((short) width));
|
||||
schematic.put("Height", new ShortTag((short) height));
|
||||
schematic.put("Length", new ShortTag((short) length));
|
||||
|
||||
// The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin'
|
||||
schematic.put("Offset", new IntArrayTag(new int[]{
|
||||
min.getBlockX(),
|
||||
min.getBlockY(),
|
||||
min.getBlockZ(),
|
||||
}));
|
||||
|
||||
int paletteMax = 0;
|
||||
Map<String, Integer> palette = new HashMap<>();
|
||||
|
||||
List<CompoundTag> tileEntities = new ArrayList<>();
|
||||
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length);
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
int y0 = min.getBlockY() + y;
|
||||
for (int z = 0; z < length; z++) {
|
||||
int z0 = min.getBlockZ() + z;
|
||||
for (int x = 0; x < width; x++) {
|
||||
int x0 = min.getBlockX() + x;
|
||||
BlockVector3 point = new BlockVector3(x0, y0, z0);
|
||||
BaseBlock block = clipboard.getFullBlock(point);
|
||||
if (block.getNbtData() != null) {
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
for (Map.Entry<String, Tag> entry : block.getNbtData().getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
int ordinal = block.getOrdinal();
|
||||
char value = palette[ordinal];
|
||||
|
@ -1,10 +1,18 @@
|
||||
package com.sk89q.worldedit.extent.inventory;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
=======
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -82,9 +90,15 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean setBlock(Vector pos, BlockStateHolder block) throws WorldEditException {
|
||||
return setBlock(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), block);
|
||||
}
|
||||
=======
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
if (blockBag != null) {
|
||||
BlockState existing = getExtent().getBlock(position);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.extent.reorder;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.collection.LocatedBlockList;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* A special extent that batches changes into Minecraft chunks. This helps
|
||||
* improve the speed of setting the blocks, since chunks do not need to be
|
||||
* loaded repeatedly, however it does take more memory due to caching the
|
||||
* blocks.
|
||||
*/
|
||||
public class ChunkBatchingExtent extends AbstractDelegateExtent {
|
||||
|
||||
/**
|
||||
* Comparator optimized for sorting chunks by the region file they reside
|
||||
* in. This allows for file caches to be used while loading the chunk.
|
||||
*/
|
||||
private static final Comparator<BlockVector2> REGION_OPTIMIZED_SORT =
|
||||
Comparator.comparing((BlockVector2 vec) -> vec.divide(32), BlockVector2.COMPARING_GRID_ARRANGEMENT)
|
||||
.thenComparing(BlockVector2.COMPARING_GRID_ARRANGEMENT);
|
||||
|
||||
private final SortedMap<BlockVector2, LocatedBlockList> batches = new TreeMap<>(REGION_OPTIMIZED_SORT);
|
||||
private boolean enabled;
|
||||
|
||||
public ChunkBatchingExtent(Extent extent) {
|
||||
this(extent, true);
|
||||
}
|
||||
|
||||
public ChunkBatchingExtent(Extent extent, boolean enabled) {
|
||||
super(extent);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (!enabled) {
|
||||
return getExtent().setBlock(location, block);
|
||||
}
|
||||
BlockVector2 chunkPos = new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
batches.computeIfAbsent(chunkPos, k -> new LocatedBlockList()).add(location, block);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Operation commitBefore() {
|
||||
if (!enabled) {
|
||||
return null;
|
||||
}
|
||||
return new Operation() {
|
||||
|
||||
// we get modified between create/resume -- only create this on resume to prevent CME
|
||||
private Iterator<LocatedBlockList> batchIterator;
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
if (batchIterator == null) {
|
||||
batchIterator = batches.values().iterator();
|
||||
}
|
||||
if (!batchIterator.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
new SetLocatedBlocks(getExtent(), batchIterator.next()).resume(run);
|
||||
batchIterator.remove();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -19,9 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.reorder;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import com.google.common.collect.Iterables;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.Blocks;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
@ -30,6 +34,11 @@ import com.sk89q.worldedit.function.operation.BlockMapEntryPlacer;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.collection.TupleArrayList;
|
||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||
@ -94,8 +103,13 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
BlockStateHolder existing = getBlock(location);
|
||||
=======
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
BlockState existing = getBlock(location);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (!enabled) {
|
||||
return super.setBlock(location, block);
|
||||
@ -103,18 +117,30 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
|
||||
if (Blocks.shouldPlaceLast(block.getBlockType())) {
|
||||
// Place torches, etc. last
|
||||
<<<<<<< HEAD
|
||||
stage2.put(location.toBlockVector(), block);
|
||||
return !existing.equalsFuzzy(block);
|
||||
} else if (Blocks.shouldPlaceFinal(block.getBlockType())) {
|
||||
// Place signs, reed, etc even later
|
||||
stage3.put(location.toBlockVector(), block);
|
||||
=======
|
||||
stage2.add(location, block);
|
||||
return !existing.equalsFuzzy(block);
|
||||
} else if (Blocks.shouldPlaceFinal(block.getBlockType())) {
|
||||
// Place signs, reed, etc even later
|
||||
stage3.add(location, block);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return !existing.equalsFuzzy(block);
|
||||
} else if (Blocks.shouldPlaceLast(existing.getBlockType())) {
|
||||
// Destroy torches, etc. first
|
||||
super.setBlock(location, BlockTypes.AIR.getDefaultState());
|
||||
return super.setBlock(location, block);
|
||||
} else {
|
||||
<<<<<<< HEAD
|
||||
stage1.put(location.toBlockVector(), block);
|
||||
=======
|
||||
stage1.add(location, block);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return !existing.equalsFuzzy(block);
|
||||
}
|
||||
}
|
||||
@ -134,21 +160,28 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
Extent extent = getExtent();
|
||||
|
||||
<<<<<<< HEAD
|
||||
final Set<BlockVector> blocks = new HashSet<>();
|
||||
final Map<BlockVector, BlockStateHolder> blockTypes = new HashMap<>();
|
||||
for (Map.Entry<BlockVector, BlockStateHolder> entry : stage3) {
|
||||
final BlockVector pt = entry.getKey();
|
||||
=======
|
||||
final Set<BlockVector3> blocks = new HashSet<>();
|
||||
final Map<BlockVector3, BlockStateHolder> blockTypes = new HashMap<>();
|
||||
for (LocatedBlock entry : stage3) {
|
||||
final BlockVector3 pt = entry.getLocation();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
blocks.add(pt);
|
||||
blockTypes.put(pt, entry.getValue());
|
||||
}
|
||||
|
||||
while (!blocks.isEmpty()) {
|
||||
BlockVector current = blocks.iterator().next();
|
||||
BlockVector3 current = blocks.iterator().next();
|
||||
if (!blocks.contains(current)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Deque<BlockVector> walked = new LinkedList<>();
|
||||
final Deque<BlockVector3> walked = new LinkedList<>();
|
||||
|
||||
while (true) {
|
||||
walked.addFirst(current);
|
||||
@ -161,13 +194,13 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
Property<Object> halfProperty = blockStateHolder.getBlockType().getProperty("half");
|
||||
if (blockStateHolder.getState(halfProperty).equals("lower")) {
|
||||
// Deal with lower door halves being attached to the floor AND the upper half
|
||||
BlockVector upperBlock = current.add(0, 1, 0).toBlockVector();
|
||||
BlockVector3 upperBlock = current.add(0, 1, 0);
|
||||
if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) {
|
||||
walked.addFirst(upperBlock);
|
||||
}
|
||||
}
|
||||
} else if (BlockCategories.RAILS.contains(blockStateHolder.getBlockType())) {
|
||||
BlockVector lowerBlock = current.add(0, -1, 0).toBlockVector();
|
||||
BlockVector3 lowerBlock = current.add(0, -1, 0);
|
||||
if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) {
|
||||
walked.addFirst(lowerBlock);
|
||||
}
|
||||
@ -191,7 +224,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockVector pt : walked) {
|
||||
for (BlockVector3 pt : walked) {
|
||||
extent.setBlock(pt, blockTypes.get(pt));
|
||||
blocks.remove(pt);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.sk89q.worldedit.extent.transform;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
@ -14,9 +15,25 @@ import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -60,11 +77,70 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
|
||||
case ROTATION:
|
||||
|
||||
<<<<<<< HEAD
|
||||
case AXIS:
|
||||
|
||||
case FACING:
|
||||
|
||||
case SHAPE:
|
||||
=======
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return transformBlock(super.getBlock(position), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return transformBlock(super.getFullBlock(position), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return super.setBlock(location, transformBlock(block, true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transform the given block using the given transform.
|
||||
*
|
||||
* <p>The provided block is modified.</p>
|
||||
*
|
||||
* @param block the block
|
||||
* @param transform the transform
|
||||
* @return the same block
|
||||
*/
|
||||
public static <T extends BlockStateHolder> T transform(T block, Transform transform) {
|
||||
return transform(block, transform, block);
|
||||
}
|
||||
|
||||
private static final Set<String> directionNames = Sets.newHashSet("north", "south", "east", "west");
|
||||
|
||||
/**
|
||||
* Transform the given block using the given transform.
|
||||
*
|
||||
* @param block the block
|
||||
* @param transform the transform
|
||||
* @param changedBlock the block to change
|
||||
* @return the changed block
|
||||
*/
|
||||
private static <T extends BlockStateHolder> T transform(T block, Transform transform, T changedBlock) {
|
||||
checkNotNull(block);
|
||||
checkNotNull(transform);
|
||||
|
||||
List<? extends Property> properties = block.getBlockType().getProperties();
|
||||
|
||||
for (Property property : properties) {
|
||||
if (property instanceof DirectionalProperty) {
|
||||
Direction value = (Direction) block.getState(property);
|
||||
if (value != null) {
|
||||
Vector3 newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector());
|
||||
if (newValue != null) {
|
||||
changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
case NORTH:
|
||||
case EAST:
|
||||
@ -76,12 +152,19 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
<<<<<<< HEAD
|
||||
private static Integer getNewStateIndex(Transform transform, List<Direction> directions, int oldIndex) {
|
||||
Direction oldDirection = directions.get(oldIndex);
|
||||
Vector oldVector = oldDirection.toVector();
|
||||
Vector newVector = transform.apply(oldVector).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||
int newIndex = oldIndex;
|
||||
double closest = oldVector.toVector().normalize().dot(newVector);
|
||||
=======
|
||||
private static Vector3 getNewStateValue(DirectionalProperty state, Transform transform, Vector3 oldDirection) {
|
||||
Vector3 newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
Vector3 newValue = null;
|
||||
double closest = -2;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
boolean found = false;
|
||||
|
||||
for (int i = 0; i < directions.size(); i++) {
|
||||
|
@ -20,14 +20,18 @@
|
||||
package com.sk89q.worldedit.extent.validation;
|
||||
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
<<<<<<< HEAD
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Limits the number of blocks that can be changed before a
|
||||
@ -78,7 +82,7 @@ public class BlockChangeLimiter extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (limit >= 0) {
|
||||
if (count >= limit) {
|
||||
throw new MaxChangedBlocksException(limit);
|
||||
|
@ -19,13 +19,19 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.validation;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -50,7 +56,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
final int y = location.getBlockY();
|
||||
final BlockType type = block.getBlockType();
|
||||
if (y < 0 || y > world.getMaxY()) {
|
||||
|
@ -21,8 +21,14 @@ package com.sk89q.worldedit.extent.world;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -52,7 +58,7 @@ public class BlockQuirkExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
BlockType existing = getExtent().getBlock(position).getBlockType();
|
||||
|
||||
if (existing.getMaterial().hasContainer()) {
|
||||
|
@ -19,12 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.world;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -62,7 +68,7 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
world.checkLoadedChunk(location);
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
|
@ -19,14 +19,21 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.world;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -41,7 +48,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class FastModeExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final World world;
|
||||
private final Set<BlockVector2D> dirtyChunks = new HashSet<>();
|
||||
private final Set<BlockVector2> dirtyChunks = new HashSet<>();
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
@ -85,9 +92,9 @@ public class FastModeExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (enabled) {
|
||||
dirtyChunks.add(new BlockVector2D(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||
dirtyChunks.add(new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||
return world.setBlock(location, block, false);
|
||||
} else {
|
||||
return world.setBlock(location, block, true);
|
||||
|
@ -19,11 +19,17 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.world;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -80,7 +86,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (toolUse && block.getBlockType().getMaterial().isAir()) {
|
||||
world.simulateBlockMine(location);
|
||||
return true;
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -95,7 +97,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
boolean ret = false;
|
||||
for (RegionFunction function : functions) {
|
||||
if (function.apply(position)) {
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
|
||||
/**
|
||||
@ -36,6 +36,6 @@ public interface FlatRegionFunction {
|
||||
* @return true if something was changed
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean apply(Vector2D position) throws WorldEditException;
|
||||
boolean apply(BlockVector2 position) throws WorldEditException;
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,20 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Passes calls to {@link #apply(com.sk89q.worldedit.Vector2D)} to the
|
||||
* Passes calls to {@link #apply(BlockVector2)} to the
|
||||
* delegate {@link com.sk89q.worldedit.function.FlatRegionFunction} if they
|
||||
* match the given mask.
|
||||
*/
|
||||
@ -50,7 +56,7 @@ public class FlatRegionMaskingFilter implements FlatRegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector2D position) throws WorldEditException {
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
return mask.test(position) && function.apply(position);
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -77,12 +83,12 @@ public class GroundFunction implements LayerFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGround(Vector position) {
|
||||
public boolean isGround(BlockVector3 position) {
|
||||
return mask.test(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||
if (depth == 0) {
|
||||
if (function.apply(position)) {
|
||||
affected++;
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* A function that takes a position and a depth.
|
||||
@ -35,7 +35,7 @@ public interface LayerFunction {
|
||||
* @param position return whether the given block is the ground
|
||||
* @return true if the search should stop
|
||||
*/
|
||||
boolean isGround(Vector position);
|
||||
boolean isGround(BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Apply the function to the given position.
|
||||
@ -48,5 +48,5 @@ public interface LayerFunction {
|
||||
* @return true whether this method should be called for further layers
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean apply(Vector position, int depth) throws WorldEditException;
|
||||
boolean apply(BlockVector3 position, int depth) throws WorldEditException;
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Performs a function on points in a region.
|
||||
@ -34,6 +34,6 @@ public interface RegionFunction {
|
||||
* @return true if something was changed
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean apply(Vector position) throws WorldEditException;
|
||||
boolean apply(BlockVector3 position) throws WorldEditException;
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,20 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Passes calls to {@link #apply(com.sk89q.worldedit.Vector)} to the
|
||||
* Passes calls to {@link #apply(BlockVector3)} to the
|
||||
* delegate {@link com.sk89q.worldedit.function.RegionFunction} if they
|
||||
* match the given mask.
|
||||
*/
|
||||
@ -49,7 +55,7 @@ public class RegionMaskingFilter implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return mask.test(position) && function.apply(position);
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.function.biome;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -49,7 +55,7 @@ public class BiomeReplace implements FlatRegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector2D position) throws WorldEditException {
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
return extent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockDistributionCounter implements RegionFunction {
|
||||
|
||||
private Extent extent;
|
||||
private boolean fuzzy;
|
||||
|
||||
private List<Countable<BlockStateHolder>> distribution = new ArrayList<>();
|
||||
private Map<BlockStateHolder, Countable<BlockStateHolder>> map = new HashMap<>();
|
||||
|
||||
public BlockDistributionCounter(Extent extent, boolean fuzzy) {
|
||||
this.extent = extent;
|
||||
this.fuzzy = fuzzy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockStateHolder blk = extent.getBlock(position);
|
||||
if (fuzzy) {
|
||||
blk = ((BlockState) blk).toFuzzy();
|
||||
}
|
||||
|
||||
if (map.containsKey(blk)) {
|
||||
map.get(blk).increment();
|
||||
} else {
|
||||
Countable<BlockStateHolder> c = new Countable<>(blk, 1);
|
||||
map.put(blk, c);
|
||||
distribution.add(c);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the distribution list.
|
||||
*
|
||||
* @return The distribution
|
||||
*/
|
||||
public List<Countable<BlockStateHolder>> getDistribution() {
|
||||
Collections.sort(distribution);
|
||||
Collections.reverse(distribution);
|
||||
return this.distribution;
|
||||
}
|
||||
}
|
@ -19,11 +19,17 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -50,8 +56,13 @@ public class BlockReplace implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
return pattern.apply(extent, position, position);
|
||||
=======
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return extent.setBlock(position, pattern.apply(position));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,17 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Keeps a count of the number of times that {@link #apply(Vector)} is called.
|
||||
* Keeps a count of the number of times that {@link #apply(BlockVector3)} is
|
||||
* called.
|
||||
*/
|
||||
public class Counter implements RegionFunction {
|
||||
public class Counter implements RegionFunction {
|
||||
|
||||
private int count;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of blocks that have been counted.
|
||||
*
|
||||
@ -40,7 +41,7 @@ import com.sk89q.worldedit.function.RegionFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
count++;
|
||||
return false;
|
||||
}
|
||||
|
@ -22,23 +22,34 @@ package com.sk89q.worldedit.function.block;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Direction.Flag;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Copies blocks from one extent to another.
|
||||
@ -47,8 +58,8 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
|
||||
private final Extent source;
|
||||
private final Extent destination;
|
||||
private final Vector from;
|
||||
private final Vector to;
|
||||
private final BlockVector3 from;
|
||||
private final BlockVector3 to;
|
||||
private final Transform transform;
|
||||
|
||||
/**
|
||||
@ -60,7 +71,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
* @param to the destination offset
|
||||
* @param transform a transform to apply to positions (after source offset, before destination offset)
|
||||
*/
|
||||
public ExtentBlockCopy(Extent source, Vector from, Extent destination, Vector to, Transform transform) {
|
||||
public ExtentBlockCopy(Extent source, BlockVector3 from, Extent destination, BlockVector3 to, Transform transform) {
|
||||
checkNotNull(source);
|
||||
checkNotNull(from);
|
||||
checkNotNull(destination);
|
||||
@ -74,9 +85,16 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
Vector orig = position.subtract(from);
|
||||
Vector transformed = transform.apply(orig);
|
||||
=======
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BaseBlock block = source.getFullBlock(position);
|
||||
BlockVector3 orig = position.subtract(from);
|
||||
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
// Apply transformations to NBT data if necessary
|
||||
BlockStateHolder block = transformNbtData(source.getBlock(position));
|
||||
@ -101,11 +119,16 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
Direction direction = MCDirections.fromRotation(rot);
|
||||
|
||||
if (direction != null) {
|
||||
<<<<<<< HEAD
|
||||
Vector applyAbsolute = transform.apply(direction.toVector());
|
||||
Vector applyOrigin = transform.apply(Vector.ZERO);
|
||||
applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX());
|
||||
applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY());
|
||||
applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ());
|
||||
=======
|
||||
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
|
||||
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -30,8 +29,13 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
<<<<<<< HEAD
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Makes a layer of grass on top, three layers of dirt below, and smooth stone
|
||||
@ -65,12 +69,12 @@ public class Naturalizer implements LayerFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGround(Vector position) {
|
||||
public boolean isGround(BlockVector3 position) {
|
||||
return mask.test(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||
if (mask.test(position)) {
|
||||
affected++;
|
||||
switch (depth) {
|
||||
|
@ -22,17 +22,23 @@ package com.sk89q.worldedit.function.entity;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.jnbt.FloatTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.EntityFunction;
|
||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Direction.Flag;
|
||||
@ -50,8 +56,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class ExtentEntityCopy implements EntityFunction {
|
||||
|
||||
private final Extent destination;
|
||||
private final Vector from;
|
||||
private final Vector to;
|
||||
private final Vector3 from;
|
||||
private final Vector3 to;
|
||||
private final Transform transform;
|
||||
private boolean removing;
|
||||
|
||||
@ -63,7 +69,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
* @param to the destination position
|
||||
* @param transform the transformation to apply to both position and orientation
|
||||
*/
|
||||
public ExtentEntityCopy(Vector from, Extent destination, Vector to, Transform transform) {
|
||||
public ExtentEntityCopy(Vector3 from, Extent destination, Vector3 to, Transform transform) {
|
||||
checkNotNull(from);
|
||||
checkNotNull(destination);
|
||||
checkNotNull(to);
|
||||
@ -99,6 +105,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
Location newLocation;
|
||||
Location location = entity.getLocation();
|
||||
|
||||
<<<<<<< HEAD
|
||||
Vector pivot = from.round().add(0.5, 0.5, 0.5);
|
||||
Vector newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||
Vector newDirection;
|
||||
@ -110,6 +117,19 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
||||
state = transformNbtData(state);
|
||||
}
|
||||
=======
|
||||
Vector3 pivot = from.round().add(0.5, 0.5, 0.5);
|
||||
Vector3 newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||
Vector3 newDirection;
|
||||
|
||||
newDirection = transform.isIdentity() ?
|
||||
entity.getLocation().getDirection()
|
||||
: transform.apply(location.getDirection()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
||||
|
||||
// Some entities store their position data in NBT
|
||||
state = transformNbtData(state);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
boolean success = destination.createEntity(newLocation, state) != null;
|
||||
|
||||
@ -147,9 +167,14 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
boolean hasFacing = tag.containsKey("Facing");
|
||||
|
||||
if (hasTilePosition) {
|
||||
<<<<<<< HEAD
|
||||
changed = true;
|
||||
Vector tilePosition = new Vector(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ"));
|
||||
Vector newTilePosition = transform.apply(tilePosition.subtract(from)).add(to);
|
||||
=======
|
||||
Vector3 tilePosition = new Vector3(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ"));
|
||||
BlockVector3 newTilePosition = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
values.put("TileX", new IntTag(newTilePosition.getBlockX()));
|
||||
values.put("TileY", new IntTag(newTilePosition.getBlockY()));
|
||||
@ -168,7 +193,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
Direction direction = MCDirections.fromHanging(d);
|
||||
|
||||
if (direction != null) {
|
||||
Vector vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL);
|
||||
|
||||
if (newDirection != null) {
|
||||
|
@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldedit.function.factory;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
@ -29,6 +28,7 @@ import com.sk89q.worldedit.function.EditContext;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.NullRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
@ -43,7 +43,7 @@ public class Deform implements Contextual<Operation> {
|
||||
private Region region;
|
||||
private String expression;
|
||||
private Mode mode = Mode.UNIT_CUBE;
|
||||
private Vector offset = new Vector();
|
||||
private Vector3 offset = Vector3.ZERO;
|
||||
|
||||
public Deform(String expression) {
|
||||
this(new NullExtent(), new NullRegion(), expression);
|
||||
@ -104,11 +104,11 @@ public class Deform implements Contextual<Operation> {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public Vector getOffset() {
|
||||
public Vector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void setOffset(Vector offset) {
|
||||
public void setOffset(Vector3 offset) {
|
||||
checkNotNull(offset, "offset");
|
||||
this.offset = offset;
|
||||
}
|
||||
@ -120,31 +120,31 @@ public class Deform implements Contextual<Operation> {
|
||||
|
||||
@Override
|
||||
public Operation createFromContext(final EditContext context) {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
|
||||
Region region = firstNonNull(context.getRegion(), this.region);
|
||||
|
||||
switch (mode) {
|
||||
case UNIT_CUBE:
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
||||
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||
break;
|
||||
case RAW_COORD:
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
zero = Vector3.ZERO;
|
||||
unit = Vector3.ONE;
|
||||
break;
|
||||
case OFFSET:
|
||||
default:
|
||||
zero = offset;
|
||||
unit = Vector.ONE;
|
||||
unit = Vector3.ONE;
|
||||
}
|
||||
|
||||
return new DeformOperation(context.getDestination(), region, zero, unit, expression);
|
||||
@ -153,11 +153,11 @@ public class Deform implements Contextual<Operation> {
|
||||
private static final class DeformOperation implements Operation {
|
||||
private final Extent destination;
|
||||
private final Region region;
|
||||
private final Vector zero;
|
||||
private final Vector unit;
|
||||
private final Vector3 zero;
|
||||
private final Vector3 unit;
|
||||
private final String expression;
|
||||
|
||||
private DeformOperation(Extent destination, Region region, Vector zero, Vector unit, String expression) {
|
||||
private DeformOperation(Extent destination, Region region, Vector3 zero, Vector3 unit, String expression) {
|
||||
this.destination = destination;
|
||||
this.region = region;
|
||||
this.zero = zero;
|
||||
|
@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldedit.function.generator;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -28,6 +27,12 @@ import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Generates flora (which may include tall grass, flowers, etc.).
|
||||
@ -103,7 +108,7 @@ public class FloraGenerator implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockStateHolder block = editSession.getBlock(position);
|
||||
|
||||
if (block.getBlockType() == BlockTypes.GRASS_BLOCK) {
|
||||
|
@ -20,8 +20,13 @@
|
||||
package com.sk89q.worldedit.function.generator;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -49,7 +54,7 @@ public class ForestGenerator implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockStateHolder block = editSession.getBlock(position);
|
||||
BlockType t = block.getBlockType();
|
||||
|
||||
|
@ -21,11 +21,15 @@ package com.sk89q.worldedit.function.generator;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -84,12 +88,12 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* @param basePos the base position
|
||||
* @param pos the vine position
|
||||
*/
|
||||
private void placeVine(Vector basePos, Vector pos) throws MaxChangedBlocksException {
|
||||
private void placeVine(BlockVector3 basePos, BlockVector3 pos) throws MaxChangedBlocksException {
|
||||
if (pos.distance(basePos) > 4) return;
|
||||
if (!editSession.getBlock(pos).getBlockType().getMaterial().isAir()) return;
|
||||
|
||||
for (int i = -1; i > -3; --i) {
|
||||
Vector testPos = pos.add(0, i, 0);
|
||||
BlockVector3 testPos = pos.add(0, i, 0);
|
||||
if (editSession.getBlock(testPos).getBlockType().getMaterial().isAir()) {
|
||||
pos = testPos;
|
||||
} else {
|
||||
@ -102,7 +106,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
|
||||
int t = random.nextInt(4);
|
||||
int h = random.nextInt(3) - 1;
|
||||
Vector p;
|
||||
BlockVector3 p;
|
||||
|
||||
BlockStateHolder log = BlockTypes.OAK_LOG.getDefaultState();
|
||||
|
||||
@ -158,7 +162,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
if (!editSession.getBlock(position).getBlockType().getMaterial().isAir()) {
|
||||
position = position.add(0, 1, 0);
|
||||
}
|
||||
@ -198,7 +202,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* @return if block was changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
private static boolean setBlockIfAir(EditSession session, Vector position, BlockStateHolder block) throws MaxChangedBlocksException {
|
||||
private static boolean setBlockIfAir(EditSession session, BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException {
|
||||
return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block);
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -90,7 +96,7 @@ public class BiomeMask2D extends AbstractMask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
BaseBiome biome = extent.getBiome(vector);
|
||||
return biomes.contains(biome);
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -41,7 +41,7 @@ public class BlockCategoryMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return category.contains(getExtent().getBlock(vector));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.collection.FastBitSet;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
@ -10,6 +11,12 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -75,6 +82,7 @@ public class BlockMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public Mask optimize() {
|
||||
Map<Object, Integer> states = new HashMap<>();
|
||||
int indexFound = -1;
|
||||
@ -94,6 +102,13 @@ public class BlockMask extends AbstractExtentMask {
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
=======
|
||||
public boolean test(BlockVector3 vector) {
|
||||
BlockStateHolder block = getExtent().getBlock(vector);
|
||||
for (BlockStateHolder testBlock : blocks) {
|
||||
if (testBlock.equalsFuzzy(block)) {
|
||||
return true;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
// Only types, no states
|
||||
if (indexFound == -1) {
|
||||
|
@ -1,7 +1,13 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -75,7 +81,18 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean test(Vector vector) {
|
||||
return types[getExtent().getBlockType(vector).getInternalId()];
|
||||
=======
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return blocks.contains(getExtent().getBlock(vector).getBlockType());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -47,7 +53,7 @@ public class BoundedHeightMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return vector.getY() >= minY && vector.getY() <= maxY;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,11 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -40,8 +44,13 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean test(Vector vector) {
|
||||
return !getExtent().getBlock(vector).getMaterial().isAir();
|
||||
=======
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -19,10 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -61,10 +67,10 @@ public class ExpressionMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
try {
|
||||
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
|
||||
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector);
|
||||
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
|
||||
}
|
||||
return expression.evaluate(vector.getX(), vector.getY(), vector.getZ()) > 0;
|
||||
} catch (EvaluationException e) {
|
||||
|
@ -19,10 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -52,7 +58,7 @@ public class ExpressionMask2D extends AbstractMask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
try {
|
||||
return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0;
|
||||
} catch (EvaluationException e) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user