Refactor vector system to be cleaner

- Move Vector, etc. into `.math` package
- Drop many methods that will be auto-promoted anyways, eg. with
`divide(int)` and `divide(double)` the first is now gone.
- Take Block vectors into their own class hierarchy
- Make it clear throughout the API what takes blockvectors
- many more improvements
This commit is contained in:
Kenzie Togami 2018-10-14 03:40:53 -07:00
parent d7c528247b
commit 399e0ad5fa
No known key found for this signature in database
GPG Key ID: 5D200B325E157A81
230 changed files with 4216 additions and 3913 deletions

View File

@ -23,13 +23,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Function;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState;
@ -42,6 +43,7 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
@ -159,7 +161,7 @@ public class BukkitAdapter {
*/
public static Location adapt(org.bukkit.Location location) {
checkNotNull(location);
Vector position = asVector(location);
Vector3 position = asVector(location);
return new com.sk89q.worldedit.util.Location(
adapt(location.getWorld()),
position,
@ -175,7 +177,7 @@ public class BukkitAdapter {
*/
public static org.bukkit.Location adapt(Location location) {
checkNotNull(location);
Vector position = location.toVector();
Vector3 position = location.toVector();
return new org.bukkit.Location(
adapt((World) location.getExtent()),
position.getX(), position.getY(), position.getZ(),
@ -190,7 +192,22 @@ public class BukkitAdapter {
* @param position the WorldEdit position
* @return a Bukkit location
*/
public static org.bukkit.Location adapt(org.bukkit.World world, Vector position) {
public static org.bukkit.Location adapt(org.bukkit.World world, Vector3 position) {
checkNotNull(world);
checkNotNull(position);
return new org.bukkit.Location(
world,
position.getX(), position.getY(), position.getZ());
}
/**
* Create a Bukkit location from a WorldEdit position with a Bukkit world.
*
* @param world the Bukkit world
* @param position the WorldEdit position
* @return a Bukkit location
*/
public static org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) {
checkNotNull(world);
checkNotNull(position);
return new org.bukkit.Location(
@ -221,9 +238,20 @@ public class BukkitAdapter {
* @param location The Bukkit location
* @return a WorldEdit vector
*/
public static Vector asVector(org.bukkit.Location location) {
public static Vector3 asVector(org.bukkit.Location location) {
checkNotNull(location);
return new Vector(location.getX(), location.getY(), location.getZ());
return new Vector3(location.getX(), location.getY(), location.getZ());
}
/**
* Create a WorldEdit BlockVector from a Bukkit location.
*
* @param location The Bukkit location
* @return a WorldEdit vector
*/
public static BlockVector3 asBlockVector(org.bukkit.Location location) {
checkNotNull(location);
return new BlockVector3(location.getX(), location.getY(), location.getZ());
}
/**

View File

@ -20,22 +20,24 @@
package com.sk89q.worldedit.bukkit;
import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
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.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -115,7 +117,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
}
@Override
public void setPosition(Vector pos, float pitch, float yaw) {
public void setPosition(Vector3 pos, float pitch, float yaw) {
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),
pos.getZ(), yaw, pitch));
}
@ -173,7 +175,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
return;
}
setPosition(new Vector(x + 0.5, y, z + 0.5));
setPosition(new Vector3(x + 0.5, y, z + 0.5));
player.setFlying(true);
}
@ -185,7 +187,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override
public com.sk89q.worldedit.util.Location getLocation() {
Location nativeLocation = player.getLocation();
Vector position = BukkitAdapter.asVector(nativeLocation);
Vector3 position = BukkitAdapter.asVector(nativeLocation);
return new com.sk89q.worldedit.util.Location(
getWorld(),
position,
@ -243,7 +245,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
}
@Override
public void sendFakeBlock(Vector pos, BlockStateHolder block) {
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
if (block == null) {
player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());

View File

@ -21,16 +21,16 @@ package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.EditSession;
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.BaseItemStack;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.history.change.BlockChange;
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.TreeGenerator;
import com.sk89q.worldedit.world.AbstractWorld;
@ -39,6 +39,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes;
import org.bukkit.Effect;
import org.bukkit.TreeType;
import org.bukkit.World;
@ -90,7 +91,7 @@ public class BukkitWorld extends AbstractWorld {
List<Entity> ents = world.getEntities();
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
for (Entity ent : ents) {
if (region.contains(BukkitAdapter.asVector(ent.getLocation()))) {
if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) {
entities.add(BukkitAdapter.adapt(ent));
}
}
@ -159,7 +160,7 @@ public class BukkitWorld extends AbstractWorld {
}
@Override
public int getBlockLightLevel(Vector pt) {
public int getBlockLightLevel(BlockVector3 pt) {
return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel();
}
@ -167,14 +168,14 @@ public class BukkitWorld extends AbstractWorld {
public boolean regenerate(Region region, EditSession editSession) {
BlockStateHolder[] history = new BlockStateHolder[16 * 16 * (getMaxY() + 1)];
for (Vector2D chunk : region.getChunks()) {
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
for (BlockVector2 chunk : region.getChunks()) {
BlockVector3 min = new BlockVector3(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
// First save all the blocks inside
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < (getMaxY() + 1); ++y) {
for (int z = 0; z < 16; ++z) {
Vector pt = min.add(x, y, z);
BlockVector3 pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
history[index] = editSession.getFullBlock(pt);
}
@ -191,14 +192,14 @@ public class BukkitWorld extends AbstractWorld {
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < (getMaxY() + 1); ++y) {
for (int z = 0; z < 16; ++z) {
Vector pt = min.add(x, y, z);
BlockVector3 pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
// We have to restore the block if it was outside
if (!region.contains(pt)) {
editSession.smartSetBlock(pt, history[index]);
} else { // Otherwise fool with history
editSession.getChangeSet().add(new BlockChange(pt.toBlockVector(), history[index], editSession.getFullBlock(pt)));
editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
}
}
}
@ -237,7 +238,7 @@ public class BukkitWorld extends AbstractWorld {
}
@Override
public boolean clearContainerBlockContents(Vector pt) {
public boolean clearContainerBlockContents(BlockVector3 pt) {
Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (block == null) {
return false;
@ -291,7 +292,7 @@ public class BukkitWorld extends AbstractWorld {
}
@Override
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) {
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 pt) {
World world = getWorld();
TreeType bukkitType = toBukkitTreeType(type);
return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType,
@ -299,13 +300,13 @@ public class BukkitWorld extends AbstractWorld {
}
@Override
public void dropItem(Vector pt, BaseItemStack item) {
public void dropItem(Vector3 pt, BaseItemStack item) {
World world = getWorld();
world.dropItemNaturally(BukkitAdapter.adapt(world, pt), BukkitAdapter.adapt(item));
}
@Override
public void checkLoadedChunk(Vector pt) {
public void checkLoadedChunk(BlockVector3 pt) {
World world = getWorld();
if (!world.isChunkLoaded(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)) {
@ -337,15 +338,15 @@ public class BukkitWorld extends AbstractWorld {
}
@Override
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
World world = getWorld();
for (BlockVector2D chunkPos : chunks) {
for (BlockVector2 chunkPos : chunks) {
world.refreshChunk(chunkPos.getBlockX(), chunkPos.getBlockZ());
}
}
@Override
public boolean playEffect(Vector position, int type, int data) {
public boolean playEffect(Vector3 position, int type, int data) {
World world = getWorld();
final Effect effect = effects.get(type);
@ -404,18 +405,18 @@ public class BukkitWorld extends AbstractWorld {
}
@Override
public void simulateBlockMine(Vector pt) {
public void simulateBlockMine(BlockVector3 pt) {
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally();
}
@Override
public com.sk89q.worldedit.world.block.BlockState getBlock(Vector position) {
public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) {
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
}
@Override
public boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
try {
@ -438,7 +439,7 @@ public class BukkitWorld extends AbstractWorld {
}
@Override
public BaseBlock getFullBlock(Vector position) {
public BaseBlock getFullBlock(BlockVector3 position) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position));
@ -448,7 +449,7 @@ public class BukkitWorld extends AbstractWorld {
}
@Override
public BaseBiome getBiome(Vector2D position) {
public BaseBiome getBiome(BlockVector2 position) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
int id = adapter.getBiomeId(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
@ -459,7 +460,7 @@ public class BukkitWorld extends AbstractWorld {
}
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
Biome bukkitBiome = adapter.getBiome(biome.getId());

View File

@ -21,8 +21,8 @@ package com.sk89q.worldedit.bukkit;
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.math.BlockVector3;
import org.bukkit.BlockChangeDelegate;
import org.bukkit.block.data.BlockData;
@ -40,7 +40,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
@Override
public boolean setBlockData(int x, int y, int z, BlockData blockData) {
try {
editSession.setBlock(new Vector(x, y, z), BukkitAdapter.adapt(blockData));
editSession.setBlock(new BlockVector3(x, y, z), BukkitAdapter.adapt(blockData));
} catch (MaxChangedBlocksException e) {
return false;
}
@ -49,7 +49,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
@Override
public BlockData getBlockData(int x, int y, int z) {
return BukkitAdapter.adapt(editSession.getBlock(new Vector(x, y, z)));
return BukkitAdapter.adapt(editSession.getBlock(new BlockVector3(x, y, z)));
}
@Override
@ -59,7 +59,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
@Override
public boolean isEmpty(int x, int y, int z) {
return editSession.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isAir();
return editSession.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir();
}
}

View File

@ -20,9 +20,9 @@
package com.sk89q.worldedit.bukkit.adapter;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@ -112,7 +112,7 @@ public interface BukkitImplAdapter {
* @param pos The position
* @param nbtData The NBT Data
*/
void sendFakeNBT(Player player, Vector pos, CompoundTag nbtData);
void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData);
/**
* Make the client think it has operator status.

View File

@ -21,7 +21,7 @@ package com.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.storage.InvalidFormatException;
import java.util.Map;
@ -167,9 +167,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));
}
/**

View File

@ -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 java.util.ArrayList;
import java.util.LinkedHashMap;
@ -111,9 +111,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());
@ -201,7 +201,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;
@ -215,7 +215,7 @@ public class YAMLNode {
return null;
}
return new Vector(x, y, z);
return new Vector3(x, y, z);
}
/**
@ -226,7 +226,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;
@ -239,7 +239,7 @@ public class YAMLNode {
return null;
}
return new Vector2D(x, z);
return new Vector2(x, z);
}
/**
@ -251,8 +251,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;
@ -558,9 +558,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");
@ -571,7 +571,7 @@ public class YAMLNode {
continue;
}
list.add(new Vector(x, y, z));
list.add(new Vector3(x, y, z));
}
return list;
@ -588,10 +588,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");
@ -601,7 +601,7 @@ public class YAMLNode {
continue;
}
list.add(new Vector2D(x, z));
list.add(new Vector2(x, z));
}
return list;
@ -618,10 +618,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");
@ -631,7 +631,7 @@ public class YAMLNode {
continue;
}
list.add(new BlockVector2D(x, z));
list.add(new BlockVector2(x, z));
}
return list;

View File

@ -1,97 +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 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) {
super(position);
}
/**
* 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) {
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(double x, double y, double z) {
super(x, y, z);
}
@Override
public int hashCode() {
return ((int) x ^ ((int) z << 12)) ^ ((int) y << 24);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
return false;
}
Vector other = (Vector) obj;
return (int) other.getX() == (int) this.x && (int) other.getY() == (int) this.y
&& (int) other.getZ() == (int) this.z;
}
@Override
public BlockVector toBlockVector() {
return this;
}
}

View File

@ -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) {
super(position);
}
/**
* 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) {
super(x, z);
}
/**
* Construct a new instance.
*
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockVector2D(double x, double z) {
super(x, 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;
}
}

View File

@ -25,8 +25,6 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.sk89q.worldedit.function.block.BlockDistributionCounter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.event.extent.EditSessionEvent;
@ -48,6 +46,7 @@ import com.sk89q.worldedit.extent.world.FastModeExtent;
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
import com.sk89q.worldedit.function.GroundFunction;
import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.block.BlockDistributionCounter;
import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.block.Counter;
import com.sk89q.worldedit.function.block.Naturalizer;
@ -81,7 +80,11 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.RValue;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MathUtils;
import com.sk89q.worldedit.math.Vector2;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.interpolation.Interpolation;
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
import com.sk89q.worldedit.math.interpolation.Node;
@ -113,8 +116,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@ -139,7 +140,7 @@ public class EditSession implements Extent, AutoCloseable {
private static final Logger log = Logger.getLogger(EditSession.class.getCanonicalName());
/**
* Used by {@link #setBlock(Vector, BlockStateHolder, Stage)} to
* Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to
* determine which {@link Extent}s should be bypassed.
*/
public enum Stage {
@ -451,22 +452,22 @@ public class EditSession implements Extent, AutoCloseable {
}
@Override
public BaseBiome getBiome(Vector2D position) {
public BaseBiome getBiome(BlockVector2 position) {
return bypassNone.getBiome(position);
}
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
return bypassNone.setBiome(position, biome);
}
@Override
public BlockState getBlock(Vector position) {
public BlockState getBlock(BlockVector3 position) {
return world.getBlock(position);
}
@Override
public BaseBlock getFullBlock(Vector position) {
public BaseBlock getFullBlock(BlockVector3 position) {
return world.getFullBlock(position);
}
@ -481,7 +482,7 @@ public class EditSession implements Extent, AutoCloseable {
*/
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
for (int y = maxY; y >= minY; --y) {
Vector pt = new Vector(x, y, z);
BlockVector3 pt = new BlockVector3(x, y, z);
BlockState block = getBlock(pt);
if (block.getBlockType().getMaterial().isMovementBlocker()) {
return y;
@ -500,7 +501,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return whether the block changed
* @throws WorldEditException thrown on a set error
*/
public boolean setBlock(Vector position, BlockStateHolder block, Stage stage) throws WorldEditException {
public boolean setBlock(BlockVector3 position, BlockStateHolder block, Stage stage) throws WorldEditException {
switch (stage) {
case BEFORE_HISTORY:
return bypassNone.setBlock(position, block);
@ -520,7 +521,7 @@ public class EditSession implements Extent, AutoCloseable {
* @param block the block
* @return whether the block changed
*/
public boolean rawSetBlock(Vector position, BlockStateHolder block) {
public boolean rawSetBlock(BlockVector3 position, BlockStateHolder block) {
try {
return setBlock(position, block, Stage.BEFORE_CHANGE);
} catch (WorldEditException e) {
@ -535,7 +536,7 @@ public class EditSession implements Extent, AutoCloseable {
* @param block the block
* @return whether the block changed
*/
public boolean smartSetBlock(Vector position, BlockStateHolder block) {
public boolean smartSetBlock(BlockVector3 position, BlockStateHolder block) {
try {
return setBlock(position, block, Stage.BEFORE_REORDER);
} catch (WorldEditException e) {
@ -544,7 +545,7 @@ public class EditSession implements Extent, AutoCloseable {
}
@Override
public boolean setBlock(Vector position, BlockStateHolder block) throws MaxChangedBlocksException {
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException {
try {
return setBlock(position, block, Stage.BEFORE_HISTORY);
} catch (MaxChangedBlocksException e) {
@ -562,7 +563,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return Whether the block changed -- not entirely dependable
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public boolean setBlock(Vector position, Pattern pattern) throws MaxChangedBlocksException {
public boolean setBlock(BlockVector3 position, Pattern pattern) throws MaxChangedBlocksException {
return setBlock(position, pattern.apply(position));
}
@ -575,9 +576,9 @@ public class EditSession implements Extent, AutoCloseable {
* @return the number of changed blocks
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
private int setBlocks(Set<Vector> vset, Pattern pattern) throws MaxChangedBlocksException {
private int setBlocks(Set<BlockVector3> vset, Pattern pattern) throws MaxChangedBlocksException {
int affected = 0;
for (Vector v : vset) {
for (BlockVector3 v : vset) {
affected += setBlock(v, pattern) ? 1 : 0;
}
return affected;
@ -623,12 +624,12 @@ public class EditSession implements Extent, AutoCloseable {
}
@Override
public Vector getMinimumPoint() {
public BlockVector3 getMinimumPoint() {
return getWorld().getMinimumPoint();
}
@Override
public Vector getMaximumPoint() {
public BlockVector3 getMaximumPoint() {
return getWorld().getMaximumPoint();
}
@ -690,7 +691,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int fillXZ(Vector origin, BlockStateHolder block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
public int fillXZ(BlockVector3 origin, BlockStateHolder block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
return fillXZ(origin, new BlockPattern(block), radius, depth, recursive);
}
@ -705,14 +706,14 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int fillXZ(Vector origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
public int fillXZ(BlockVector3 origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
checkNotNull(origin);
checkNotNull(pattern);
checkArgument(radius >= 0, "radius >= 0");
checkArgument(depth >= 1, "depth >= 1");
MaskIntersection mask = new MaskIntersection(
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))),
new BoundedHeightMask(
Math.max(origin.getBlockY() - depth + 1, 0),
Math.min(getWorld().getMaxY(), origin.getBlockY())),
@ -747,7 +748,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int removeAbove(Vector position, int apothem, int height) throws MaxChangedBlocksException {
public int removeAbove(BlockVector3 position, int apothem, int height) throws MaxChangedBlocksException {
checkNotNull(position);
checkArgument(apothem >= 1, "apothem >= 1");
checkArgument(height >= 1, "height >= 1");
@ -769,7 +770,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int removeBelow(Vector position, int apothem, int height) throws MaxChangedBlocksException {
public int removeBelow(BlockVector3 position, int apothem, int height) throws MaxChangedBlocksException {
checkNotNull(position);
checkArgument(apothem >= 1, "apothem >= 1");
checkArgument(height >= 1, "height >= 1");
@ -791,12 +792,12 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int removeNear(Vector position, BlockType blockType, int apothem) throws MaxChangedBlocksException {
public int removeNear(BlockVector3 position, BlockType blockType, int apothem) throws MaxChangedBlocksException {
checkNotNull(position);
checkArgument(apothem >= 1, "apothem >= 1");
Mask mask = new BlockTypeMask(this, blockType);
Vector adjustment = new Vector(1, 1, 1).multiply(apothem - 1);
BlockVector3 adjustment = BlockVector3.ONE.multiply(apothem - 1);
Region region = new CuboidRegion(
getWorld(), // Causes clamping of Y range
position.add(adjustment.multiply(-1)),
@ -900,11 +901,11 @@ public class EditSession implements Extent, AutoCloseable {
checkNotNull(region);
checkNotNull(pattern);
Vector center = region.getCenter();
Vector3 center = region.getCenter();
Region centerRegion = new CuboidRegion(
getWorld(), // Causes clamping of Y range
new Vector(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
new Vector(MathUtils.roundHalfUp(center.getX()),
new BlockVector3(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
new BlockVector3(MathUtils.roundHalfUp(center.getX()),
center.getY(), MathUtils.roundHalfUp(center.getZ())));
return setBlocks(centerRegion, pattern);
}
@ -1054,7 +1055,7 @@ public class EditSession implements Extent, AutoCloseable {
checkNotNull(pattern);
BlockReplace replace = new BlockReplace(this, pattern);
RegionOffset offset = new RegionOffset(new Vector(0, 1, 0), replace);
RegionOffset offset = new RegionOffset(new BlockVector3(0, 1, 0), replace);
GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), offset);
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
Operations.completeLegacy(visitor);
@ -1089,13 +1090,13 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int stackCuboidRegion(Region region, Vector dir, int count, boolean copyAir) throws MaxChangedBlocksException {
public int stackCuboidRegion(Region region, BlockVector3 dir, int count, boolean copyAir) throws MaxChangedBlocksException {
checkNotNull(region);
checkNotNull(dir);
checkArgument(count >= 1, "count >= 1 required");
Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
Vector to = region.getMinimumPoint();
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
BlockVector3 to = region.getMinimumPoint();
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
copy.setRepetitions(count);
copy.setTransform(new AffineTransform().translate(dir.multiply(size)));
@ -1117,12 +1118,12 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks moved
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int moveRegion(Region region, Vector dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
checkNotNull(region);
checkNotNull(dir);
checkArgument(distance >= 1, "distance >= 1 required");
Vector to = region.getMinimumPoint();
BlockVector3 to = region.getMinimumPoint();
// Remove the original blocks
com.sk89q.worldedit.function.pattern.Pattern pattern = replacement != null ?
@ -1161,7 +1162,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks moved
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int moveCuboidRegion(Region region, Vector dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
public int moveCuboidRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
return moveRegion(region, dir, distance, copyAir, replacement);
}
@ -1173,20 +1174,20 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int drainArea(Vector origin, double radius) throws MaxChangedBlocksException {
public int drainArea(BlockVector3 origin, double radius) throws MaxChangedBlocksException {
checkNotNull(origin);
checkArgument(radius >= 0, "radius >= 0 required");
MaskIntersection mask = new MaskIntersection(
new BoundedHeightMask(0, getWorld().getMaxY()),
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))),
getWorld().createLiquidMask());
BlockReplace replace = new BlockReplace(this, new BlockPattern(BlockTypes.AIR.getDefaultState()));
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace);
// Around the origin in a 3x3 block
for (BlockVector position : CuboidRegion.fromCenter(origin, 1)) {
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
if (mask.test(position)) {
visitor.visit(position);
}
@ -1206,7 +1207,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int fixLiquid(Vector origin, double radius, BlockType fluid) throws MaxChangedBlocksException {
public int fixLiquid(BlockVector3 origin, double radius, BlockType fluid) throws MaxChangedBlocksException {
checkNotNull(origin);
checkArgument(radius >= 0, "radius >= 0 required");
@ -1219,7 +1220,7 @@ public class EditSession implements Extent, AutoCloseable {
// There are boundaries that the routine needs to stay in
MaskIntersection mask = new MaskIntersection(
new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))),
blockMask
);
@ -1227,7 +1228,7 @@ public class EditSession implements Extent, AutoCloseable {
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
// Around the origin in a 3x3 block
for (BlockVector position : CuboidRegion.fromCenter(origin, 1)) {
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
if (liquidMask.test(position)) {
visitor.visit(position);
}
@ -1249,7 +1250,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makeCylinder(Vector pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException {
public int makeCylinder(BlockVector3 pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException {
return makeCylinder(pos, block, radius, radius, height, filled);
}
@ -1265,7 +1266,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makeCylinder(Vector pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) throws MaxChangedBlocksException {
public int makeCylinder(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) throws MaxChangedBlocksException {
int affected = 0;
radiusX += 0.5;
@ -1279,7 +1280,7 @@ public class EditSession implements Extent, AutoCloseable {
}
if (pos.getBlockY() < 0) {
pos = pos.setY(0);
pos = pos.withY(0);
} else if (pos.getBlockY() + height - 1 > world.getMaxY()) {
height = world.getMaxY() - pos.getBlockY() + 1;
}
@ -1343,7 +1344,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makeSphere(Vector pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException {
public int makeSphere(BlockVector3 pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException {
return makeSphere(pos, block, radius, radius, radius, filled);
}
@ -1359,7 +1360,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makeSphere(Vector pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
int affected = 0;
radiusX += 0.5;
@ -1445,7 +1446,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makePyramid(Vector position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException {
public int makePyramid(BlockVector3 position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException {
int affected = 0;
int height = size;
@ -1485,7 +1486,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int thaw(Vector position, double radius)
public int thaw(BlockVector3 position, double radius)
throws MaxChangedBlocksException {
int affected = 0;
double radiusSq = radius * radius;
@ -1500,12 +1501,12 @@ public class EditSession implements Extent, AutoCloseable {
int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) {
continue;
}
for (int y = world.getMaxY(); y >= 1; --y) {
Vector pt = new Vector(x, y, z);
BlockVector3 pt = new BlockVector3(x, y, z);
BlockType id = getBlock(pt).getBlockType();
if (id == BlockTypes.ICE) {
@ -1536,7 +1537,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int simulateSnow(Vector position, double radius) throws MaxChangedBlocksException {
public int simulateSnow(BlockVector3 position, double radius) throws MaxChangedBlocksException {
int affected = 0;
double radiusSq = radius * radius;
@ -1550,12 +1551,12 @@ public class EditSession implements Extent, AutoCloseable {
int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) {
continue;
}
for (int y = world.getMaxY(); y >= 1; --y) {
Vector pt = new Vector(x, y, z);
BlockVector3 pt = new BlockVector3(x, y, z);
BlockType id = getBlock(pt).getBlockType();
if (id.getMaterial().isAir()) {
@ -1604,7 +1605,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int green(Vector position, double radius, boolean onlyNormalDirt)
public int green(BlockVector3 position, double radius, boolean onlyNormalDirt)
throws MaxChangedBlocksException {
int affected = 0;
final double radiusSq = radius * radius;
@ -1618,12 +1619,12 @@ public class EditSession implements Extent, AutoCloseable {
final int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) {
continue;
}
for (int y = world.getMaxY(); y >= 1; --y) {
final Vector pt = new Vector(x, y, z);
final BlockVector3 pt = new BlockVector3(x, y, z);
final BlockState block = getBlock(pt);
if (block.getBlockType() == BlockTypes.DIRT ||
@ -1652,7 +1653,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of patches created
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makePumpkinPatches(Vector position, int apothem) throws MaxChangedBlocksException {
public int makePumpkinPatches(BlockVector3 position, int apothem) throws MaxChangedBlocksException {
// We want to generate pumpkins
GardenPatchGenerator generator = new GardenPatchGenerator(this);
generator.setPlant(GardenPatchGenerator.getPumpkinPattern());
@ -1681,7 +1682,7 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of trees created
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makeForest(Vector basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
public int makeForest(BlockVector3 basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
int affected = 0;
for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX()
@ -1689,7 +1690,7 @@ public class EditSession implements Extent, AutoCloseable {
for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ()
+ size; ++z) {
// Don't want to be in the ground
if (!getBlock(new Vector(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) {
if (!getBlock(new BlockVector3(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) {
continue;
}
// The gods don't want a tree here
@ -1699,13 +1700,13 @@ public class EditSession implements Extent, AutoCloseable {
for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) {
// Check if we hit the ground
BlockType t = getBlock(new Vector(x, y, z)).getBlockType();
BlockType t = getBlock(new BlockVector3(x, y, z)).getBlockType();
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
treeType.generate(this, new Vector(x, y + 1, z));
treeType.generate(this, new BlockVector3(x, y + 1, z));
++affected;
break;
} else if (t == BlockTypes.SNOW) {
setBlock(new Vector(x, y, z), BlockTypes.AIR.getDefaultState());
setBlock(new BlockVector3(x, y, z), BlockTypes.AIR.getDefaultState());
} else if (!t.getMaterial().isAir()) { // Trees won't grow on this!
break;
}
@ -1729,7 +1730,7 @@ public class EditSession implements Extent, AutoCloseable {
return count.getDistribution();
}
public int makeShape(final Region region, final Vector zero, final Vector unit, final Pattern pattern, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
public int makeShape(final Region region, final Vector3 zero, final Vector3 unit, final Pattern pattern, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
final Expression expression = Expression.compile(expressionString, "x", "y", "z", "type", "data");
expression.optimize();
@ -1742,9 +1743,9 @@ public class EditSession implements Extent, AutoCloseable {
final ArbitraryShape shape = new ArbitraryShape(region) {
@Override
protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) {
final Vector current = new Vector(x, y, z);
final Vector3 current = new Vector3(x, y, z);
environment.setCurrentBlock(current);
final Vector scaled = current.subtract(zero).divide(unit);
final Vector3 scaled = current.subtract(zero).divide(unit);
try {
if (expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ(), defaultMaterial.getBlockType().getLegacyId(), 0) <= 0) {
@ -1763,7 +1764,7 @@ public class EditSession implements Extent, AutoCloseable {
return shape.generate(this, pattern, hollow);
}
public int deformRegion(final Region region, final Vector zero, final Vector unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException {
public int deformRegion(final Region region, final Vector3 zero, final Vector3 unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException {
final Expression expression = Expression.compile(expressionString, "x", "y", "z");
expression.optimize();
@ -1774,16 +1775,16 @@ public class EditSession implements Extent, AutoCloseable {
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
expression.setEnvironment(environment);
final DoubleArrayList<BlockVector, BaseBlock> queue = new DoubleArrayList<>(false);
final DoubleArrayList<BlockVector3, BaseBlock> queue = new DoubleArrayList<>(false);
for (BlockVector position : region) {
for (BlockVector3 position : region) {
// offset, scale
final Vector scaled = position.subtract(zero).divide(unit);
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
// transform
expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ());
final BlockVector sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue());
final BlockVector3 sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue());
// read block from world
final BaseBlock material = world.getFullBlock(sourcePosition);
@ -1793,8 +1794,8 @@ public class EditSession implements Extent, AutoCloseable {
}
int affected = 0;
for (Map.Entry<BlockVector, BaseBlock> entry : queue) {
BlockVector position = entry.getKey();
for (Map.Entry<BlockVector3, BaseBlock> entry : queue) {
BlockVector3 position = entry.getKey();
BaseBlock material = entry.getValue();
// set at new position
@ -1819,10 +1820,10 @@ public class EditSession implements Extent, AutoCloseable {
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
int affected = 0;
final Set<BlockVector> outside = new HashSet<>();
final Set<BlockVector3> outside = new HashSet<>();
final Vector min = region.getMinimumPoint();
final Vector max = region.getMaximumPoint();
final BlockVector3 min = region.getMinimumPoint();
final BlockVector3 max = region.getMaximumPoint();
final int minX = min.getBlockX();
final int minY = min.getBlockY();
@ -1833,30 +1834,30 @@ public class EditSession implements Extent, AutoCloseable {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
recurseHollow(region, new BlockVector(x, y, minZ), outside);
recurseHollow(region, new BlockVector(x, y, maxZ), outside);
recurseHollow(region, new BlockVector3(x, y, minZ), outside);
recurseHollow(region, new BlockVector3(x, y, maxZ), outside);
}
}
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
recurseHollow(region, new BlockVector(minX, y, z), outside);
recurseHollow(region, new BlockVector(maxX, y, z), outside);
recurseHollow(region, new BlockVector3(minX, y, z), outside);
recurseHollow(region, new BlockVector3(maxX, y, z), outside);
}
}
for (int z = minZ; z <= maxZ; ++z) {
for (int x = minX; x <= maxX; ++x) {
recurseHollow(region, new BlockVector(x, minY, z), outside);
recurseHollow(region, new BlockVector(x, maxY, z), outside);
recurseHollow(region, new BlockVector3(x, minY, z), outside);
recurseHollow(region, new BlockVector3(x, maxY, z), outside);
}
}
for (int i = 1; i < thickness; ++i) {
final Set<BlockVector> newOutside = new HashSet<>();
outer: for (BlockVector position : region) {
for (Vector recurseDirection: recurseDirections) {
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
final Set<BlockVector3> newOutside = new HashSet<>();
outer: for (BlockVector3 position : region) {
for (BlockVector3 recurseDirection : recurseDirections) {
BlockVector3 neighbor = position.add(recurseDirection);
if (outside.contains(neighbor)) {
newOutside.add(position);
@ -1868,9 +1869,9 @@ public class EditSession implements Extent, AutoCloseable {
outside.addAll(newOutside);
}
outer: for (BlockVector position : region) {
for (Vector recurseDirection: recurseDirections) {
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
outer: for (BlockVector3 position : region) {
for (BlockVector3 recurseDirection : recurseDirections) {
BlockVector3 neighbor = position.add(recurseDirection);
if (outside.contains(neighbor)) {
continue outer;
@ -1897,10 +1898,10 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int drawLine(Pattern pattern, Vector pos1, Vector pos2, double radius, boolean filled)
public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled)
throws MaxChangedBlocksException {
Set<Vector> vset = new HashSet<>();
Set<BlockVector3> vset = new HashSet<>();
boolean notdrawn = true;
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
@ -1909,7 +1910,7 @@ public class EditSession implements Extent, AutoCloseable {
int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1);
if (dx + dy + dz == 0) {
vset.add(new Vector(tipx, tipy, tipz));
vset.add(new BlockVector3(tipx, tipy, tipz));
notdrawn = false;
}
@ -1919,7 +1920,7 @@ public class EditSession implements Extent, AutoCloseable {
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1));
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1));
vset.add(new Vector(tipx, tipy, tipz));
vset.add(new BlockVector3(tipx, tipy, tipz));
}
notdrawn = false;
}
@ -1930,7 +1931,7 @@ public class EditSession implements Extent, AutoCloseable {
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1));
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1));
vset.add(new Vector(tipx, tipy, tipz));
vset.add(new BlockVector3(tipx, tipy, tipz));
}
notdrawn = false;
}
@ -1941,7 +1942,7 @@ public class EditSession implements Extent, AutoCloseable {
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1));
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1));
vset.add(new Vector(tipx, tipy, tipz));
vset.add(new BlockVector3(tipx, tipy, tipz));
}
notdrawn = false;
}
@ -1968,16 +1969,16 @@ public class EditSession implements Extent, AutoCloseable {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int drawSpline(Pattern pattern, List<Vector> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled)
public int drawSpline(Pattern pattern, List<BlockVector3> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled)
throws MaxChangedBlocksException {
Set<Vector> vset = new HashSet<>();
Set<BlockVector3> vset = new HashSet<>();
List<Node> nodes = new ArrayList<>(nodevectors.size());
Interpolation interpol = new KochanekBartelsInterpolation();
for (Vector nodevector : nodevectors) {
Node n = new Node(nodevector);
for (BlockVector3 nodevector : nodevectors) {
Node n = new Node(nodevector.toVector3());
n.setTension(tension);
n.setBias(bias);
n.setContinuity(continuity);
@ -1987,12 +1988,9 @@ public class EditSession implements Extent, AutoCloseable {
interpol.setNodes(nodes);
double splinelength = interpol.arcLength(0, 1);
for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) {
Vector tipv = interpol.getPosition(loop);
int tipx = (int) Math.round(tipv.getX());
int tipy = (int) Math.round(tipv.getY());
int tipz = (int) Math.round(tipv.getZ());
Vector3 tipv = interpol.getPosition(loop);
vset.add(new Vector(tipx, tipy, tipz));
vset.add(tipv.toBlockPoint());
}
vset = getBallooned(vset, radius);
@ -2010,18 +2008,18 @@ public class EditSession implements Extent, AutoCloseable {
return Math.sqrt(sum);
}
private static Set<Vector> getBallooned(Set<Vector> vset, double radius) {
Set<Vector> returnset = new HashSet<>();
private static Set<BlockVector3> getBallooned(Set<BlockVector3> vset, double radius) {
Set<BlockVector3> returnset = new HashSet<>();
int ceilrad = (int) Math.ceil(radius);
for (Vector v : vset) {
for (BlockVector3 v : vset) {
int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
for (int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) {
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
if (hypot(loopx - tipx, loopy - tipy, loopz - tipz) <= radius) {
returnset.add(new Vector(loopx, loopy, loopz));
returnset.add(new BlockVector3(loopx, loopy, loopz));
}
}
}
@ -2030,28 +2028,28 @@ public class EditSession implements Extent, AutoCloseable {
return returnset;
}
private static Set<Vector> getHollowed(Set<Vector> vset) {
Set<Vector> returnset = new HashSet<>();
for (Vector v : vset) {
private static Set<BlockVector3> getHollowed(Set<BlockVector3> vset) {
Set<BlockVector3> returnset = new HashSet<>();
for (BlockVector3 v : vset) {
double x = v.getX(), y = v.getY(), z = v.getZ();
if (!(vset.contains(new Vector(x + 1, y, z)) &&
vset.contains(new Vector(x - 1, y, z)) &&
vset.contains(new Vector(x, y + 1, z)) &&
vset.contains(new Vector(x, y - 1, z)) &&
vset.contains(new Vector(x, y, z + 1)) &&
vset.contains(new Vector(x, y, z - 1)))) {
if (!(vset.contains(new BlockVector3(x + 1, y, z)) &&
vset.contains(new BlockVector3(x - 1, y, z)) &&
vset.contains(new BlockVector3(x, y + 1, z)) &&
vset.contains(new BlockVector3(x, y - 1, z)) &&
vset.contains(new BlockVector3(x, y, z + 1)) &&
vset.contains(new BlockVector3(x, y, z - 1)))) {
returnset.add(v);
}
}
return returnset;
}
private void recurseHollow(Region region, BlockVector origin, Set<BlockVector> outside) {
final LinkedList<BlockVector> queue = new LinkedList<>();
private void recurseHollow(Region region, BlockVector3 origin, Set<BlockVector3> outside) {
final LinkedList<BlockVector3> queue = new LinkedList<>();
queue.addLast(origin);
while (!queue.isEmpty()) {
final BlockVector current = queue.removeFirst();
final BlockVector3 current = queue.removeFirst();
final BlockState block = getBlock(current);
if (block.getBlockType().getMaterial().isMovementBlocker()) {
continue;
@ -2065,15 +2063,15 @@ public class EditSession implements Extent, AutoCloseable {
continue;
}
for (Vector recurseDirection: recurseDirections) {
queue.addLast(current.add(recurseDirection).toBlockVector());
for (BlockVector3 recurseDirection : recurseDirections) {
queue.addLast(current.add(recurseDirection));
}
} // while
}
}
public int makeBiomeShape(final Region region, final Vector zero, final Vector unit, final BaseBiome biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
final Vector2D zero2D = zero.toVector2D();
final Vector2D unit2D = unit.toVector2D();
public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BaseBiome biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
final Vector2 zero2D = zero.toVector2();
final Vector2 unit2D = unit.toVector2();
final Expression expression = Expression.compile(expressionString, "x", "z");
expression.optimize();
@ -2085,9 +2083,9 @@ public class EditSession implements Extent, AutoCloseable {
final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) {
@Override
protected BaseBiome getBiome(int x, int z, BaseBiome defaultBiomeType) {
final Vector2D current = new Vector2D(x, z);
environment.setCurrentBlock(current.toVector(0));
final Vector2D scaled = current.subtract(zero2D).divide(unit2D);
final Vector2 current = new Vector2(x, z);
environment.setCurrentBlock(current.toVector3(0));
final Vector2 scaled = current.subtract(zero2D).divide(unit2D);
try {
if (expression.evaluate(scaled.getX(), scaled.getZ()) <= 0) {
@ -2106,13 +2104,13 @@ public class EditSession implements Extent, AutoCloseable {
return shape.generate(this, biomeType, hollow);
}
private static final Vector[] recurseDirections = {
Direction.NORTH.toVector(),
Direction.EAST.toVector(),
Direction.SOUTH.toVector(),
Direction.WEST.toVector(),
Direction.UP.toVector(),
Direction.DOWN.toVector(),
private static final BlockVector3[] recurseDirections = {
Direction.NORTH.toBlockVector(),
Direction.EAST.toBlockVector(),
Direction.SOUTH.toBlockVector(),
Direction.WEST.toBlockVector(),
Direction.UP.toBlockVector(),
Direction.DOWN.toBlockVector(),
};
private static double lengthSq(double x, double y, double z) {

View File

@ -40,6 +40,7 @@ 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;
@ -91,7 +92,7 @@ public class LocalSession {
private transient boolean fastMode = false;
private transient Mask mask;
private transient TimeZone timezone = TimeZone.getDefault();
private transient Vector cuiTemporaryBlock;
private transient BlockVector3 cuiTemporaryBlock;
// Saved properties
private String lastScript;
@ -450,10 +451,10 @@ public class LocalSession {
* @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().toVector();
return player.getBlockIn().toVector().toBlockPoint();
}
return selector.getPrimaryPosition();
@ -661,7 +662,7 @@ public class LocalSession {
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 Vector(
cuiTemporaryBlock = new BlockVector3(
((IntTag) tags.get("x")).getValue(),
((IntTag) tags.get("y")).getValue(),
((IntTag) tags.get("z")).getValue()

View File

@ -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;
}

View File

@ -1,846 +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.sk89q.worldedit.math.transform.AffineTransform;
import javax.annotation.Nullable;
/**
* An immutable 3-dimensional vector.
*/
public class Vector implements Comparable<Vector> {
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);
protected final double x, y, z;
/**
* 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.x = x;
this.y = y;
this.z = 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.x = (double) x;
this.y = (double) y;
this.z = (double) 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.x = (double) x;
this.y = (double) y;
this.z = (double) z;
}
/**
* Copy another vector.
*
* @param other another vector to make a copy of
*/
public Vector(Vector other) {
this.x = other.x;
this.y = other.y;
this.z = other.z;
}
/**
* Construct a new instance with X, Y, and Z coordinates set to 0.
*
* <p>One can also refer to a static {@link #ZERO}.</p>
*/
public Vector() {
this.x = 0;
this.y = 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 (int) Math.round(x);
}
/**
* Set the X coordinate.
*
* @param x the new X
* @return a new vector
*/
public Vector setX(double x) {
return new Vector(x, y, z);
}
/**
* Set the X coordinate.
*
* @param x the X coordinate
* @return new vector
*/
public Vector setX(int x) {
return new Vector(x, y, z);
}
/**
* 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 (int) Math.round(y);
}
/**
* Set the Y coordinate.
*
* @param y the new Y
* @return a new vector
*/
public Vector setY(double y) {
return new Vector(x, y, z);
}
/**
* Set the Y coordinate.
*
* @param y the new Y
* @return a new vector
*/
public Vector setY(int y) {
return new Vector(x, y, z);
}
/**
* 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 (int) Math.round(z);
}
/**
* Set the Z coordinate.
*
* @param z the new Z
* @return a new vector
*/
public Vector setZ(double z) {
return new Vector(x, y, z);
}
/**
* Set the Z coordinate.
*
* @param z the new Z
* @return a new vector
*/
public Vector setZ(int z) {
return new Vector(x, y, 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(x + other.x, y + other.y, z + other.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(double x, double y, double z) {
return new Vector(this.x + x, this.y + y, this.z + 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.x + x, this.y + y, this.z + 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 = x, newY = y, newZ = z;
for (Vector other : others) {
newX += other.x;
newY += other.y;
newZ += other.z;
}
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(x - other.x, y - other.y, z - other.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(double x, double y, double z) {
return new Vector(this.x - x, this.y - y, this.z - 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.x - x, this.y - y, this.z - 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 = x, newY = y, newZ = z;
for (Vector other : others) {
newX -= other.x;
newY -= other.y;
newZ -= other.z;
}
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(x * other.x, y * other.y, z * other.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(double x, double y, double z) {
return new Vector(this.x * x, this.y * y, this.z * 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.x * x, this.y * y, this.z * 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 = x, newY = y, newZ = z;
for (Vector other : others) {
newX *= other.x;
newY *= other.y;
newZ *= other.z;
}
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.x * n, this.y * n, this.z * 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.x * n, this.y * n, this.z * 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.x * n, this.y * n, this.z * 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(x / other.x, y / other.y, z / other.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(double x, double y, double z) {
return new Vector(this.x / x, this.y / y, this.z / 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.x / x, this.y / y, this.z / 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(x / n, y / n, z / 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(x / n, y / n, z / 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(x / n, y / n, z / n);
}
/**
* Get the length of the vector.
*
* @return length
*/
public double length() {
return Math.sqrt(x * x + y * y + z * z);
}
/**
* Get the length, squared, of the vector.
*
* @return length, squared
*/
public double lengthSq() {
return x * x + y * y + z * z;
}
/**
* 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.x - x, 2) +
Math.pow(other.y - y, 2) +
Math.pow(other.z - z, 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.x - x, 2) +
Math.pow(other.y - y, 2) +
Math.pow(other.z - z, 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 x * other.x + y * other.y + z * other.z;
}
/**
* 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(
y * other.z - z * other.y,
z * other.x - x * other.z,
x * other.y - y * other.x
);
}
/**
* 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 x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z;
}
/**
* 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(x, Math.max(min, Math.min(max, y)), z);
}
/**
* Floors the values of all components.
*
* @return a new vector
*/
public Vector floor() {
return new Vector(Math.floor(x), Math.floor(y), Math.floor(z));
}
/**
* Rounds all components up.
*
* @return a new vector
*/
public Vector ceil() {
return new Vector(Math.ceil(x), Math.ceil(y), Math.ceil(z));
}
/**
* Rounds all components to the closest integer.
*
* <p>Components &lt; 0.5 are rounded down, otherwise up.</p>
*
* @return a new vector
*/
public Vector round() {
return new Vector(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 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(x), Math.abs(y), Math.abs(z));
}
/**
* 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.x - aboutX;
double z = this.z - 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,
y,
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 (x == 0 && y == 0 && z == 0) {
// this is a zero vector
return true;
}
final double otherX = other.x;
final double otherY = other.y;
final double otherZ = other.z;
if (otherX == 0 && otherY == 0 && otherZ == 0) {
// other is a zero vector
return true;
}
if ((x == 0) != (otherX == 0)) return false;
if ((y == 0) != (otherY == 0)) return false;
if ((z == 0) != (otherZ == 0)) return false;
final double quotientX = otherX / x;
if (!Double.isNaN(quotientX)) {
return other.equals(multiply(quotientX));
}
final double quotientY = otherY / y;
if (!Double.isNaN(quotientY)) {
return other.equals(multiply(quotientY));
}
final double quotientZ = otherZ / z;
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(x),
Math.floor(y),
Math.floor(z)
);
}
/**
* Create a new {@code BlockVector} from this vector.
*
* @return a new {@code BlockVector}
*/
public BlockVector toBlockVector() {
return toBlockPoint();
// return new BlockVector(this); TODO Look into this further.
}
/**
* Creates a 2D vector by dropping the Y component from this vector.
*
* @return a new {@code Vector2D}
*/
public Vector2D toVector2D() {
return new Vector2D(x, z);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
return false;
}
Vector other = (Vector) obj;
return other.x == this.x && other.y == this.y && other.z == this.z;
}
@Override
public int compareTo(@Nullable Vector other) {
if (other == null) {
throw new IllegalArgumentException("null not supported");
}
if (y != other.y) return Double.compare(y, other.y);
if (z != other.z) return Double.compare(z, other.z);
if (x != other.x) return Double.compare(x, other.x);
return 0;
}
@Override
public int hashCode() {
return ((int) x ^ ((int) z << 12)) ^ ((int) y << 24);
}
@Override
public String toString() {
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.x, v2.x),
Math.min(v1.y, v2.y),
Math.min(v1.z, v2.z)
);
}
/**
* 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.x, v2.x),
Math.max(v1.y, v2.y),
Math.max(v1.z, v2.z)
);
}
/**
* 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.x + v2.x) / 2,
(v1.y + v2.y) / 2,
(v1.z + v2.z) / 2
);
}
}

View File

@ -1,691 +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.google.common.collect.ComparisonChain;
import com.sk89q.worldedit.math.transform.AffineTransform;
import java.util.Comparator;
/**
* An immutable 2-dimensional vector.
*/
public class Vector2D {
/**
* A comparator for Vector2Ds that orders the vectors by rows, with x as the
* column and z as the row.
*
* For example, if x is the horizontal axis and z is the vertical axis, it
* sorts like so:
*
* <pre>
* 0123
* 4567
* 90ab
* cdef
* </pre>
*/
public static final Comparator<Vector2D> COMPARING_GRID_ARRANGEMENT = (a, b) -> {
return ComparisonChain.start()
.compare(a.getBlockZ(), b.getBlockZ())
.compare(a.getBlockX(), b.getBlockX())
.result();
};
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);
protected final 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.x;
this.z = other.z;
}
/**
* Construct a new instance with X and Z coordinates set to 0.
*
* <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 (int) Math.round(x);
}
/**
* Set the X coordinate.
*
* @param x the new X
* @return a new vector
*/
public Vector2D setX(double x) {
return new Vector2D(x, z);
}
/**
* Set the X coordinate.
*
* @param x the new X
* @return a new vector
*/
public Vector2D setX(int x) {
return new Vector2D(x, z);
}
/**
* 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 (int) Math.round(z);
}
/**
* Set the Z coordinate.
*
* @param z the new Z
* @return a new vector
*/
public Vector2D setZ(double z) {
return new Vector2D(x, z);
}
/**
* Set the Z coordinate.
*
* @param z the new Z
* @return a new vector
*/
public Vector2D setZ(int z) {
return new Vector2D(x, 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(x + other.x, z + other.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(double x, double z) {
return new Vector2D(this.x + x, this.z + 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.x + x, this.z + 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 = x, newZ = z;
for (Vector2D other : others) {
newX += other.x;
newZ += other.z;
}
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(x - other.x, z - other.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(double x, double z) {
return new Vector2D(this.x - x, this.z - 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.x - x, this.z - 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 = x, newZ = z;
for (Vector2D other : others) {
newX -= other.x;
newZ -= other.z;
}
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(x * other.x, z * other.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(double x, double z) {
return new Vector2D(this.x * x, this.z * 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.x * x, this.z * 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 = x, newZ = z;
for (Vector2D other : others) {
newX *= other.x;
newZ *= other.z;
}
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.x * n, this.z * 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.x * n, this.z * 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.x * n, this.z * 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(x / other.x, z / other.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(double x, double z) {
return new Vector2D(this.x / x, this.z / 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.x / x, this.z / 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(x / n, z / 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(x / n, z / 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(x / n, z / n);
}
/**
* Get the length of the vector.
*
* @return length
*/
public double length() {
return Math.sqrt(x * x + z * z);
}
/**
* Get the length, squared, of the vector.
*
* @return length, squared
*/
public double lengthSq() {
return x * x + z * z;
}
/**
* 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.x - x, 2) + Math.pow(other.z - z, 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.x - x, 2) +
Math.pow(other.z - z, 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 x * other.x + z * other.z;
}
/**
* 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 x >= min.x && x <= max.x
&& z >= min.z && z <= max.z;
}
/**
* 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(x), Math.floor(z));
}
/**
* Rounds all components up.
*
* @return a new vector
*/
public Vector2D ceil() {
return new Vector2D(Math.ceil(x), Math.ceil(z));
}
/**
* Rounds all components to the closest integer.
*
* <p>Components &lt; 0.5 are rounded down, otherwise up.</p>
*
* @return a new vector
*/
public Vector2D round() {
return new Vector2D(Math.floor(x + 0.5), Math.floor(z + 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(x), Math.abs(z));
}
/**
* 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.x - aboutX;
double z = this.z - 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 (x == 0 && z == 0) {
// this is a zero vector
return true;
}
final double otherX = other.x;
final double otherZ = other.z;
if (otherX == 0 && otherZ == 0) {
// other is a zero vector
return true;
}
if ((x == 0) != (otherX == 0)) return false;
if ((z == 0) != (otherZ == 0)) return false;
final double quotientX = otherX / x;
if (!Double.isNaN(quotientX)) {
return other.equals(multiply(quotientX));
}
final double quotientZ = otherZ / z;
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(x, 0, z);
}
/**
* 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(x, y, z);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector2D)) {
return false;
}
Vector2D other = (Vector2D) obj;
return other.x == this.x && other.z == this.z;
}
@Override
public int hashCode() {
return ((int) x << 16) ^ (int) z;
}
@Override
public String toString() {
return "(" + x + ", " + z + ")";
}
/**
* 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.x, v2.x),
Math.min(v1.z, v2.z)
);
}
/**
* 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.x, v2.x),
Math.max(v1.z, v2.z)
);
}
}

View File

@ -40,6 +40,7 @@ import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask;
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;
@ -370,7 +371,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);
@ -382,7 +383,7 @@ public class WorldEdit {
case NORTH:
case UP:
case DOWN:
return dir.vector();
return dir.vector().toBlockPoint();
default:
throw new UnknownDirectionException(dir.name());

View File

@ -28,8 +28,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;
@ -41,6 +39,8 @@ 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;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region;
@ -139,12 +139,12 @@ public class BiomeCommands {
return;
}
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toVector2D());
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().toVector2D());
BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2());
biomes.add(biome);
qualifier = "at your position";
@ -153,12 +153,12 @@ public class BiomeCommands {
Region region = session.getSelection(world);
if (region instanceof FlatRegion) {
for (Vector2D pt : ((FlatRegion) region).asFlatRegion()) {
for (BlockVector2 pt : ((FlatRegion) region).asFlatRegion()) {
biomes.add(world.getBiome(pt));
}
} else {
for (Vector pt : region) {
biomes.add(world.getBiome(pt.toVector2D()));
for (BlockVector3 pt : region) {
biomes.add(world.getBiome(pt.toBlockVector2()));
}
}
@ -195,7 +195,7 @@ public class BiomeCommands {
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);
}

View File

@ -27,7 +27,6 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.tool.BrushTool;
@ -45,6 +44,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.command.binding.Switch;
@ -143,7 +143,7 @@ public class BrushCommands {
ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard();
Vector size = clipboard.getDimensions();
BlockVector3 size = clipboard.getDimensions();
worldEdit.checkMaxBrushRadius(size.getBlockX());
worldEdit.checkMaxBrushRadius(size.getBlockY());

View File

@ -29,10 +29,10 @@ 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.Vector2D;
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;
@ -76,7 +76,7 @@ public class ChunkCommands {
player.print("Chunk: " + chunkX + ", " + chunkZ);
player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename);
player.print("McRegion: region/" + McRegionChunkStore.getFilename(
new Vector2D(chunkX, chunkZ)));
new BlockVector2(chunkX, chunkZ)));
}
@Command(
@ -88,9 +88,9 @@ public class ChunkCommands {
)
@CommandPermissions("worldedit.listchunks")
public void listChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
for (Vector2D chunk : chunks) {
for (BlockVector2 chunk : chunks) {
player.print(LegacyChunkStore.getFilename(chunk));
}
}
@ -108,7 +108,7 @@ public class ChunkCommands {
player.print("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) {
@ -125,7 +125,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");
@ -156,7 +156,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");

View File

@ -28,7 +28,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.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
@ -42,6 +41,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.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
@ -154,7 +155,7 @@ public class ClipboardCommands {
Clipboard clipboard = holder.getClipboard();
Region region = clipboard.getRegion();
Vector to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
Operation operation = holder
.createPaste(editSession)
.to(to)
@ -163,10 +164,10 @@ public class ClipboardCommands {
Operations.completeLegacy(operation);
if (selectPasted) {
Vector clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
Vector realTo = to.add(holder.getTransform().apply(clipboardOffset));
Vector max = realTo.add(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());
session.setRegionSelector(player.getWorld(), selector);
selector.learnChanges();
selector.explainRegionAdjust(player, session);
@ -211,11 +212,10 @@ public class ClipboardCommands {
)
@CommandPermissions("worldedit.clipboard.flip")
public void flip(Player player, LocalSession session, EditSession editSession,
@Optional(Direction.AIM) @Direction Vector direction) throws WorldEditException {
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard();
AffineTransform transform = new AffineTransform();
transform = transform.scale(direction.positive().multiply(-2).add(1, 1, 1));
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.");
}

View File

@ -21,12 +21,12 @@ package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
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;
@ -66,8 +66,8 @@ 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(
@ -75,39 +75,34 @@ class FlattenedClipboardTransform {
transform,
new AffineTransform().translate(original.getOrigin()));
Vector[] corners = new Vector[] {
Vector3[] corners = new Vector3[] {
minimum,
maximum,
minimum.setX(maximum.getX()),
minimum.setY(maximum.getY()),
minimum.setZ(maximum.getZ()),
maximum.setX(minimum.getX()),
maximum.setY(minimum.getY()),
maximum.setZ(minimum.getZ()) };
minimum.withX(maximum.getX()),
minimum.withY(maximum.getY()),
minimum.withZ(maximum.getZ()),
maximum.withX(minimum.getX()),
maximum.withY(minimum.getY()),
maximum.withZ(minimum.getZ()) };
for (int i = 0; i < corners.length; i++) {
corners[i] = transformAround.apply(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
newMinimum = newMinimum.setX(Math.floor(newMinimum.getX()));
newMinimum = newMinimum.setY(Math.floor(newMinimum.getY()));
newMinimum = newMinimum.setZ(Math.floor(newMinimum.getZ()));
newMinimum = newMinimum.floor();
newMaximum = newMaximum.ceil();
newMaximum = newMaximum.setX(Math.ceil(newMaximum.getX()));
newMaximum = newMaximum.setY(Math.ceil(newMaximum.getY()));
newMaximum = newMaximum.setZ(Math.ceil(newMaximum.getZ()));
return new CuboidRegion(newMinimum, newMaximum);
return new CuboidRegion(newMinimum.toBlockPoint(), newMaximum.toBlockPoint());
}
/**

View File

@ -29,13 +29,14 @@ 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.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.pattern.Pattern;
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.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.util.command.binding.Range;
@ -116,7 +117,7 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(radiusZ);
worldEdit.checkMaxRadius(height);
Vector pos = session.getPlacementPosition(player);
BlockVector3 pos = session.getPlacementPosition(player);
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
player.print(affected + " block(s) have been created.");
}
@ -177,9 +178,9 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(radiusY);
worldEdit.checkMaxRadius(radiusZ);
Vector pos = session.getPlacementPosition(player);
BlockVector3 pos = session.getPlacementPosition(player);
if (raised) {
pos = pos.add(0, radiusY, 0);
pos = pos.add(0, (int) radiusY, 0);
}
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
@ -240,7 +241,7 @@ public class GenerationCommands {
@CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT)
public void pyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow) throws WorldEditException {
Vector pos = session.getPlacementPosition(player);
BlockVector3 pos = session.getPlacementPosition(player);
worldEdit.checkMaxRadius(size);
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
player.findFreePosition();
@ -277,31 +278,31 @@ public class GenerationCommands {
@Switch('o') boolean offset,
@Switch('c') boolean offsetCenter) throws WorldEditException {
final Vector zero;
Vector unit;
final Vector3 zero;
Vector3 unit;
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);
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);
}
try {
@ -342,31 +343,31 @@ public class GenerationCommands {
@Switch('r') boolean useRawCoords,
@Switch('o') boolean offset,
@Switch('c') boolean offsetCenter) throws WorldEditException {
final Vector zero;
Vector unit;
final Vector3 zero;
Vector3 unit;
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);
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);
}
try {

View File

@ -32,7 +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.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
@ -48,6 +47,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;
@ -110,8 +111,8 @@ public class RegionCommands {
}
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);
player.print(blocksChanged + " block(s) have been changed.");
@ -143,7 +144,7 @@ public class RegionCommands {
}
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
List<Vector> vectors = new ArrayList<>(cpregion.getVertices());
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
@ -274,7 +275,7 @@ public class RegionCommands {
public void move(Player player, EditSession editSession, LocalSession session,
@Selection Region region,
@Optional("1") @Range(min = 1) int count,
@Optional(Direction.AIM) @Direction Vector direction,
@Optional(Direction.AIM) @Direction BlockVector3 direction,
@Optional("air") BlockStateHolder replace,
@Switch('s') boolean moveSelection) throws WorldEditException {
@ -312,16 +313,16 @@ public class RegionCommands {
public void stack(Player player, EditSession editSession, LocalSession session,
@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,
@Switch('a') boolean ignoreAirBlocks) throws WorldEditException {
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks);
if (moveSelection) {
try {
final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint());
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
final Vector shiftVector = direction.multiply(count * (Math.abs(direction.dot(size)) + 1));
final BlockVector3 shiftVector = direction.toVector3().multiply(count * (Math.abs(direction.dot(size)) + 1)).toBlockPoint();
region.shift(shiftVector);
session.getRegionSelector(player.getWorld()).learnChanges();
@ -378,25 +379,25 @@ public class RegionCommands {
@Text String expression,
@Switch('r') boolean useRawCoords,
@Switch('o') boolean offset) throws WorldEditException {
final Vector zero;
Vector unit;
final Vector3 zero;
Vector3 unit;
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);
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);
}
try {

View File

@ -29,8 +29,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.BaseItemStack;
@ -38,6 +36,8 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.regions.RegionSelector;
@ -58,7 +58,6 @@ 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;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.storage.ChunkStore;
@ -103,13 +102,13 @@ public class SelectionCommands {
pos = player.getBlockIn();
}
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
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());
.explainPrimarySelection(player, session, pos.toVector().toBlockPoint());
}
@Command(
@ -138,13 +137,13 @@ public class SelectionCommands {
pos = player.getBlockIn();
}
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set.");
return;
}
session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos.toVector());
.explainSecondarySelection(player, session, pos.toVector().toBlockPoint());
}
@Command(
@ -160,13 +159,13 @@ public class SelectionCommands {
Location pos = player.getBlockTrace(300);
if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
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());
.explainPrimarySelection(player, session, pos.toVector().toBlockPoint());
} else {
player.printError("No block in sight!");
}
@ -185,13 +184,13 @@ public class SelectionCommands {
Location pos = player.getBlockTrace(300);
if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set.");
return;
}
session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos.toVector());
.explainSecondarySelection(player, session, pos.toVector().toBlockPoint());
} else {
player.printError("No block in sight!");
}
@ -216,23 +215,23 @@ public class SelectionCommands {
@Logging(POSITION)
@CommandPermissions("worldedit.selection.chunk")
public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
final Vector min;
final Vector max;
final BlockVector3 min;
final BlockVector3 max;
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);
player.print("Chunks selected: ("
+ 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(",");
@ -241,14 +240,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);
player.print("Chunk selected: "
@ -321,8 +320,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);
@ -335,7 +334,7 @@ public class SelectionCommands {
return;
}
List<Vector> dirs = new ArrayList<>();
List<BlockVector3> dirs = new ArrayList<>();
int change = args.getInteger(0);
int reverseChange = 0;
@ -380,11 +379,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));
}
}
@ -408,7 +407,7 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.contract")
public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
List<Vector> dirs = new ArrayList<>();
List<BlockVector3> dirs = new ArrayList<>();
int change = args.getInteger(0);
int reverseChange = 0;
@ -452,11 +451,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,7 +482,7 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.shift")
public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
List<Vector> dirs = new ArrayList<>();
List<BlockVector3> dirs = new ArrayList<>();
int change = args.getInteger(0);
if (args.argsLength() == 2) {
if (args.getString(1).contains(",")) {
@ -500,7 +499,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 +559,23 @@ public class SelectionCommands {
player.print("Region inset.");
}
private Vector[] getChangesForEachDir(CommandContext args) {
List<Vector> changes = new ArrayList<>(6);
private BlockVector3[] getChangesForEachDir(CommandContext args) {
List<BlockVector3> changes = new ArrayList<>(6);
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(
@ -589,34 +588,33 @@ public class SelectionCommands {
)
@CommandPermissions("worldedit.selection.size")
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();
Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint());
Vector origin = clipboard.getOrigin();
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(Vector.ONE));
player.print("Cuboid distance: " + size.distance(BlockVector3.ONE));
player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
return;
}
Region region = session.getSelection(player.getWorld());
Vector size = region.getMaximumPoint()
BlockVector3 size = region.getMaximumPoint()
.subtract(region.getMinimumPoint())
.add(1, 1, 1);
player.print("Type: " + session.getRegionSelector(player.getWorld())
.getTypeName());
for (String line : session.getRegionSelector(player.getWorld())
.getInformationLines()) {
player.print(line);
}
player.print("Size: " + size);
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
player.print("# of blocks: " + region.getArea());

View File

@ -30,7 +30,6 @@ 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.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CreatureButcher;
@ -49,6 +48,7 @@ import com.sk89q.worldedit.function.visitor.EntityVisitor;
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;
@ -103,7 +103,7 @@ public class UtilityCommands {
we.checkMaxRadius(radius);
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;
Vector pos = session.getPlacementPosition(player);
BlockVector3 pos = session.getPlacementPosition(player);
int affected = editSession.fillXZ(pos, pattern, radius, depth, false);
player.print(affected + " block(s) have been created.");
}
@ -129,7 +129,7 @@ public class UtilityCommands {
we.checkMaxRadius(radius);
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE;
Vector pos = session.getPlacementPosition(player);
BlockVector3 pos = session.getPlacementPosition(player);
int affected = 0;
if (pattern instanceof BlockPattern) {
affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true);
@ -290,9 +290,9 @@ public class UtilityCommands {
to = we.getPatternFactory().parseFromInput(args.getString(2), context);
}
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);
Region region = new CuboidRegion(player.getWorld(), min, max);
if (to instanceof BlockPattern) {
@ -432,7 +432,7 @@ public class UtilityCommands {
if (player != null) {
session = we.getSessionManager().get(player);
Vector center = session.getPlacementPosition(player);
BlockVector3 center = session.getPlacementPosition(player);
editSession = session.createEditSession(player);
List<? extends Entity> entities;
if (radius >= 0) {
@ -492,7 +492,7 @@ public class UtilityCommands {
if (player != null) {
session = we.getSessionManager().get(player);
Vector center = session.getPlacementPosition(player);
BlockVector3 center = session.getPlacementPosition(player);
editSession = session.createEditSession(player);
List<? extends Entity> entities;
if (radius >= 0) {

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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.world.World;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -52,7 +52,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;
@ -69,12 +69,12 @@ public class AreaPickaxe implements BlockTool {
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) {
Vector pos = new Vector(x, y, z);
BlockVector3 pos = new BlockVector3(x, y, z);
if (editSession.getBlock(pos).getBlockType() != initialType) {
continue;
}
((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().distanceSq(pos));
((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().toBlockPoint().distanceSq(pos));
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
}

View File

@ -27,6 +27,7 @@ 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.registry.state.Property;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
@ -54,7 +55,8 @@ public class BlockDataCyler implements DoubleActionBlockTool {
World world = (World) clicked.getExtent();
BlockState block = world.getBlock(clicked.toVector());
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
BlockState block = world.getBlock(blockPoint);
if (!config.allowedDataCycleBlocks.isEmpty()
&& !player.hasPermission("worldedit.override.data-cycler")
@ -83,7 +85,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
editSession.disableBuffering();
try {
editSession.setBlock(clicked.toVector(), newBlock);
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.");

View File

@ -23,13 +23,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;
/**
@ -55,7 +55,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
try (EditSession editSession = session.createEditSession(player)) {
try {
editSession.disableBuffering();
Vector position = clicked.toVector();
BlockVector3 position = clicked.toVector().toBlockPoint();
editSession.setBlock(position, pattern.apply(position));
} catch (MaxChangedBlocksException ignored) {
} finally {
@ -73,7 +73,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
BlockStateHolder targetBlock = player.getWorld().getBlock(clicked.toVector());
BlockStateHolder targetBlock = player.getWorld().getBlock(clicked.toVector().toBlockPoint());
if (targetBlock != null) {
pattern = new BlockPattern(targetBlock);

View File

@ -189,7 +189,7 @@ public class BrushTool implements TraceTool {
}
try {
brush.build(editSession, target.toVector(), material, size);
brush.build(editSession, target.toVector().toBlockPoint(), material, size);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {

View File

@ -25,6 +25,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;
@ -49,8 +50,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;
@ -66,8 +68,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;

View File

@ -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,7 +69,7 @@ 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.");
@ -78,13 +78,13 @@ public class FloatingTreeRemover implements BlockTool {
try (EditSession editSession = session.createEditSession(player)) {
try {
final Set<Vector> blockSet = bfs(world, clicked.toVector());
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
if (blockSet == null) {
player.printError("That's not a floating tree.");
return true;
}
for (Vector blockVector : blockSet) {
for (BlockVector3 blockVector : blockSet) {
final BlockState otherState = editSession.getBlock(blockVector);
if (isTreeBlock(otherState.getBlockType())) {
editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState());
@ -100,13 +100,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 +116,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;

View File

@ -19,16 +19,15 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.BlockVector;
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.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;
@ -59,7 +58,8 @@ public class FloodFillTool implements BlockTool {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
World world = (World) clicked.getExtent();
BlockType initialType = world.getBlock(clicked.toVector()).getBlockType();
BlockVector3 origin = clicked.toVector().toBlockPoint();
BlockType initialType = world.getBlock(origin).getBlockType();
if (initialType.getMaterial().isAir()) {
return true;
@ -71,8 +71,7 @@ public class FloodFillTool implements BlockTool {
try (EditSession editSession = session.createEditSession(player)) {
try {
recurse(editSession, clicked.toVector().toBlockVector(),
clicked.toVector(), range, initialType, new HashSet<>());
recurse(editSession, origin, origin, range, initialType, new HashSet<>());
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
@ -83,8 +82,8 @@ public class FloodFillTool implements BlockTool {
return true;
}
private void recurse(EditSession editSession, BlockVector pos, Vector origin, int size, BlockType initialType,
Set<BlockVector> visited) throws MaxChangedBlocksException {
private void recurse(EditSession editSession, BlockVector3 pos, BlockVector3 origin, int size, BlockType initialType,
Set<BlockVector3> visited) throws MaxChangedBlocksException {
if (origin.distance(pos) > size || visited.contains(pos)) {
return;
@ -98,17 +97,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);
}

View File

@ -27,6 +27,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.BlockStateHolder;
@ -55,11 +56,12 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
if (pos == null) return false;
try (EditSession eS = session.createEditSession(player)) {
eS.disableBuffering();
BlockStateHolder applied = secondary.apply(pos.toVector());
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
BlockStateHolder applied = secondary.apply(blockPoint);
if (applied.getBlockType().getMaterial().isAir()) {
eS.setBlock(pos.toVector(), secondary);
eS.setBlock(blockPoint, secondary);
} else {
eS.setBlock(pos.getDirection(), secondary);
eS.setBlock(pos.getDirection().toBlockPoint(), secondary);
}
return true;
} catch (MaxChangedBlocksException e) {
@ -75,11 +77,12 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
if (pos == null) return false;
try (EditSession eS = session.createEditSession(player)) {
eS.disableBuffering();
BlockStateHolder applied = primary.apply(pos.toVector());
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
BlockStateHolder applied = primary.apply(blockPoint);
if (applied.getBlockType().getMaterial().isAir()) {
eS.setBlock(pos.toVector(), primary);
eS.setBlock(blockPoint, primary);
} else {
eS.setBlock(pos.getDirection(), primary);
eS.setBlock(pos.getDirection().toBlockPoint(), primary);
}
return true;
} catch (MaxChangedBlocksException e) {

View File

@ -26,6 +26,7 @@ import com.sk89q.worldedit.blocks.MobSpawnerBlock;
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.BlockStateHolder;
@ -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: "

View File

@ -19,15 +19,14 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.BlockVector;
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.world.World;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -56,7 +55,8 @@ public class RecursivePickaxe implements BlockTool {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
World world = (World) clicked.getExtent();
BlockType initialType = world.getBlock(clicked.toVector()).getBlockType();
BlockVector3 origin = clicked.toVector().toBlockPoint();
BlockType initialType = world.getBlock(origin).getBlockType();
if (initialType.getMaterial().isAir()) {
return true;
@ -70,8 +70,8 @@ public class RecursivePickaxe implements BlockTool {
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
try {
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
clicked.toVector(), range, initialType, new HashSet<>());
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 {
@ -82,8 +82,8 @@ public class RecursivePickaxe implements BlockTool {
return true;
}
private static void recurse(Platform server, EditSession editSession, World world, BlockVector pos,
Vector origin, double size, BlockType initialType, Set<BlockVector> visited) throws MaxChangedBlocksException {
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)) {
@ -100,17 +100,17 @@ public class RecursivePickaxe implements BlockTool {
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(),
recurse(server, editSession, world, pos.add(1, 0, 0),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(),
recurse(server, editSession, world, pos.add(-1, 0, 0),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(),
recurse(server, editSession, world, pos.add(0, 0, 1),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(),
recurse(server, editSession, world, pos.add(0, 0, -1),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(),
recurse(server, editSession, world, pos.add(0, 1, 0),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(),
recurse(server, editSession, world, pos.add(0, -1, 0),
origin, size, initialType, visited);
}

View File

@ -26,6 +26,7 @@ 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;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -43,7 +44,8 @@ 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();
final BlockType blockType = world.getBlock(clicked.toVector()).getBlockType();
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
final BlockType blockType = world.getBlock(blockPoint).getBlockType();
if (blockType == BlockTypes.BEDROCK
&& !player.canDestroyBedrock()) {
return true;
@ -51,7 +53,7 @@ public class SinglePickaxe implements BlockTool {
try (EditSession editSession = session.createEditSession(player)) {
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
editSession.setBlock(clicked.toVector(), BlockTypes.AIR.getDefaultState());
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
}

View File

@ -53,7 +53,7 @@ public class TreePlanter implements BlockTool {
boolean successful = false;
for (int i = 0; i < 10; i++) {
if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0))) {
if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0).toBlockPoint())) {
successful = true;
break;
}

View File

@ -21,8 +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.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
/**
* A brush is a long-range build tool.
@ -38,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 MaxChangedBlocksException;
void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException;
}

View File

@ -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()));

View File

@ -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)

View File

@ -21,9 +21,9 @@ 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.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());
}

View File

@ -21,8 +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.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -39,21 +39,21 @@ public class GravityBrush 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 {
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 Vector pt = new Vector(x, y, z);
final BlockVector3 pt = new BlockVector3(x, y, z);
final BlockStateHolder block = editSession.getBlock(pt);
if (!block.getBlockType().getMaterial().isAir()) {
blockTypes.add(block);
editSession.setBlock(pt, BlockTypes.AIR.getDefaultState());
}
}
Vector pt = new Vector(x, y, z);
BlockVector3 pt = new BlockVector3(x, y, z);
Collections.reverse(blockTypes);
for (int i = 0; i < blockTypes.size();) {
if (editSession.getBlock(pt).getBlockType().getMaterial().isAir()) {

View File

@ -21,9 +21,9 @@ 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.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 {
@ -35,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 = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
}

View File

@ -21,15 +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.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 = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
}

View File

@ -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));

View File

@ -21,8 +21,9 @@ 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.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.HeightMap;
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
@ -39,10 +40,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);

View File

@ -21,15 +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.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(BlockTypes.COBBLESTONE.getDefaultState());
}

View File

@ -20,15 +20,16 @@
package com.sk89q.worldedit.entity;
import com.sk89q.worldedit.PlayerDirection;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.gamemode.GameMode;
@ -256,14 +257,14 @@ 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.
@ -275,5 +276,5 @@ public interface Player extends Entity, Actor {
* @param pos The position of the block
* @param block The block to send, null to reset
*/
void sendFakeBlock(Vector pos, @Nullable BlockStateHolder block);
void sendFakeBlock(BlockVector3 pos, @Nullable BlockStateHolder block);
}

View File

@ -23,10 +23,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.EditSession.Stage;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
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 com.sk89q.worldedit.world.block.BlockStateHolder;
@ -53,7 +53,7 @@ import javax.annotation.Nullable;
* 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
* {@link EditSession#rawSetBlock(Vector, BlockStateHolder)} will skip your
* {@link EditSession#rawSetBlock(BlockVector3, BlockStateHolder)} will skip your
* 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

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.extension.factory;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.WorldEdit;
@ -37,6 +36,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.world.World;
@ -245,7 +245,7 @@ class DefaultBlockParser extends InputParser<BlockStateHolder> {
} else if ("pos1".equalsIgnoreCase(typeString)) {
// Get the block type from the "primary position"
final World world = context.requireWorld();
final BlockVector primaryPosition;
final BlockVector3 primaryPosition;
try {
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
} catch (IncompleteRegionException e) {

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.extension.factory;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
@ -42,6 +41,8 @@ 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;
import com.sk89q.worldedit.session.request.Request;
@ -134,7 +135,7 @@ class DefaultMaskParser extends InputParser<Mask> {
} else {
submask = new ExistingBlockMask(extent);
}
OffsetMask offsetMask = new OffsetMask(submask, new Vector(0, firstChar == '>' ? -1 : 1, 0));
OffsetMask offsetMask = new OffsetMask(submask, new BlockVector3(0, firstChar == '>' ? -1 : 1, 0));
return new MaskIntersection(offsetMask, Masks.negate(submask));
case '$':
@ -161,7 +162,7 @@ class DefaultMaskParser extends InputParser<Mask> {
try {
Expression exp = Expression.compile(component.substring(1), "x", "y", "z");
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(
Request.request().getEditSession(), Vector.ONE, Vector.ZERO);
Request.request().getEditSession(), Vector3.ONE, Vector3.ZERO);
exp.setEnvironment(env);
return new ExpressionMask(exp);
} catch (ExpressionException e) {

View File

@ -21,16 +21,17 @@ 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;
import com.sk89q.worldedit.world.block.BaseBlock;
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;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@ -105,7 +106,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;
@ -113,7 +114,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (free == 2) {
if (y - 1 != origY) {
setPosition(new Vector(x + 0.5, y - 2 + 1, z + 0.5));
setPosition(new Vector3(x + 0.5, y - 2 + 1, z + 0.5));
}
return;
@ -131,10 +132,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
int z = searchPos.getBlockZ();
while (y >= 0) {
final Vector pos = new Vector(x, y, z);
final BlockVector3 pos = new BlockVector3(x, y, z);
final BlockState id = world.getBlock(pos);
if (id.getBlockType().getMaterial().isMovementBlocker()) {
setPosition(new Vector(x + 0.5, y + 1, z + 0.5));
setPosition(new Vector3(x + 0.5, y + 1, z + 0.5));
return;
}
@ -159,7 +160,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte spots = 0;
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()) {
++free;
} else {
free = 0;
@ -168,7 +169,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (free == 2) {
++spots;
if (spots == 2) {
final Vector platform = new Vector(x, y - 2, z);
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();
@ -177,7 +178,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
return false;
}
setPosition(platform.add(0.5, 1, 0.5));
setPosition(platform.toVector3().add(0.5, 1, 0.5));
return true;
}
}
@ -199,7 +200,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte free = 0;
while (y >= 1) {
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;
@ -210,14 +211,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
// lightly and also check to see if there's something to
// stand upon
while (y >= 0) {
final Vector platform = new Vector(x, y, z);
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.add(0.5, 1, 0.5));
setPosition(platform.toVector3().add(0.5, 1, 0.5));
return true;
}
@ -248,13 +249,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;
@ -282,7 +283,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;
@ -300,24 +301,24 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
try {
Vector spot = new Vector(x, y - 1, z);
BlockVector3 spot = new BlockVector3(x, y - 1, z);
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState());
}
} catch (WorldEditException e) {
e.printStackTrace();
}
setPosition(new Vector(x + 0.5, y, z + 0.5));
setPosition(new Vector3(x + 0.5, y, z + 0.5));
}
@Override
public Location getBlockIn() {
return getLocation().setPosition(getLocation().toVector().toBlockVector());
return getLocation().setPosition(getLocation().toVector().floor());
}
@Override
public Location getBlockOn() {
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().toBlockVector());
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
}
@Override
@ -392,7 +393,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;
@ -426,7 +427,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());
}
@ -499,7 +500,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
}
@Override
public void sendFakeBlock(Vector pos, BlockStateHolder block) {
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
}
}

View File

@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.tool.BlockTool;
import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
@ -38,6 +37,8 @@ import com.sk89q.worldedit.event.platform.PlatformInitializeEvent;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.event.platform.PlayerInputEvent;
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.util.HandSide;
import com.sk89q.worldedit.util.Location;
@ -302,7 +303,7 @@ public class PlatformManager {
Actor actor = createProxyActor(event.getCause());
Location location = event.getLocation();
Vector vector = location.toVector();
Vector3 vector = location.toVector();
// At this time, only handle interaction from players
if (actor instanceof Player) {
@ -321,8 +322,9 @@ public class PlatformManager {
RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) {
selector.explainPrimarySelection(actor, session, vector);
BlockVector3 blockPoint = vector.toBlockPoint();
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
selector.explainPrimarySelection(actor, session, blockPoint);
}
event.setCancelled(true);
@ -356,8 +358,9 @@ public class PlatformManager {
}
RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) {
selector.explainSecondarySelection(actor, session, vector);
BlockVector3 blockPoint = vector.toBlockPoint();
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
selector.explainSecondarySelection(actor, session, blockPoint);
}
event.setCancelled(true);

View File

@ -21,12 +21,13 @@ package com.sk89q.worldedit.extension.platform;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
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;
@ -92,7 +93,7 @@ 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);
}
@ -158,7 +159,7 @@ class PlayerProxy extends AbstractPlayerActor {
}
@Override
public void sendFakeBlock(Vector pos, BlockStateHolder block) {
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
basePlayer.sendFakeBlock(pos, block);
}
}

View File

@ -21,17 +21,17 @@ package com.sk89q.worldedit.extent;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.OperationQueue;
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;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -66,17 +66,17 @@ public abstract class AbstractDelegateExtent implements Extent {
}
@Override
public BlockState getBlock(Vector position) {
public BlockState getBlock(BlockVector3 position) {
return extent.getBlock(position);
}
@Override
public BaseBlock getFullBlock(Vector position) {
public BaseBlock getFullBlock(BlockVector3 position) {
return extent.getFullBlock(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);
}
@ -97,22 +97,22 @@ public abstract class AbstractDelegateExtent implements Extent {
}
@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);
}
@Override
public Vector getMinimumPoint() {
public BlockVector3 getMinimumPoint() {
return extent.getMinimumPoint();
}
@Override
public Vector getMaximumPoint() {
public BlockVector3 getMaximumPoint() {
return extent.getMaximumPoint();
}

View File

@ -21,17 +21,17 @@ package com.sk89q.worldedit.extent;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
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;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.ArrayList;
@ -59,9 +59,9 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
}
@Override
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
BaseBlock previous = getFullBlock(location);
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
changeSet.add(new BlockChange(location, previous, block));
return super.setBlock(location, block);
}

View File

@ -19,9 +19,9 @@
package com.sk89q.worldedit.extent;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
@ -46,7 +46,7 @@ public interface Extent extends InputExtent, OutputExtent {
*
* @return the minimum point
*/
Vector getMinimumPoint();
BlockVector3 getMinimumPoint();
/**
* Get the maximum point in the extent.
@ -56,7 +56,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.

View File

@ -19,11 +19,11 @@
package com.sk89q.worldedit.extent;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.world.block.BaseBlock;
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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
/**
@ -45,7 +45,7 @@ public interface InputExtent {
* @param position position of the block
* @return the block
*/
BlockState getBlock(Vector position);
BlockState getBlock(BlockVector3 position);
/**
* Get a immutable snapshot of the block at the given location.
@ -53,7 +53,7 @@ public interface InputExtent {
* @param position position of the block
* @return the block
*/
BaseBlock getFullBlock(Vector position);
BaseBlock getFullBlock(BlockVector3 position);
/**
* Get the biome at the given location.
@ -64,6 +64,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);
}

View File

@ -21,9 +21,9 @@ package com.sk89q.worldedit.extent;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
/**
@ -65,7 +65,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);
}

View File

@ -19,16 +19,16 @@
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.BaseBlock;
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;
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;
@ -44,16 +44,14 @@ import javax.annotation.Nullable;
*/
public class NullExtent implements Extent {
private final Vector nullPoint = new Vector(0, 0, 0);
@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
@ -73,28 +71,28 @@ public class NullExtent implements Extent {
}
@Override
public BlockState getBlock(Vector position) {
public BlockState getBlock(BlockVector3 position) {
return BlockTypes.AIR.getDefaultState();
}
@Override
public BaseBlock getFullBlock(Vector position) {
public BaseBlock getFullBlock(BlockVector3 position) {
return getBlock(position).toBaseBlock();
}
@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;
}

View File

@ -19,10 +19,10 @@
package com.sk89q.worldedit.extent;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
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 com.sk89q.worldedit.world.block.BlockStateHolder;
@ -50,7 +50,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.
@ -59,7 +59,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

View File

@ -21,14 +21,14 @@ 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.extent.AbstractDelegateExtent;
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;
@ -44,19 +44,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());
@ -66,7 +66,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) {
@ -77,22 +77,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;
@ -102,8 +102,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 {
@ -119,32 +119,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();
}
};

View File

@ -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;
}

View File

@ -21,16 +21,16 @@ package com.sk89q.worldedit.extent.clipboard;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
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;
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;
@ -48,7 +48,7 @@ import javax.annotation.Nullable;
public class BlockArrayClipboard implements Clipboard {
private final Region region;
private Vector origin;
private BlockVector3 origin;
private final BlockStateHolder[][][] blocks;
private final List<ClipboardEntity> entities = new ArrayList<>();
@ -64,7 +64,7 @@ public class BlockArrayClipboard implements Clipboard {
this.region = region.clone();
this.origin = region.getMinimumPoint();
Vector dimensions = getDimensions();
BlockVector3 dimensions = getDimensions();
blocks = new BlockStateHolder[dimensions.getBlockX()][dimensions.getBlockY()][dimensions.getBlockZ()];
}
@ -74,27 +74,27 @@ public class BlockArrayClipboard implements Clipboard {
}
@Override
public Vector getOrigin() {
public BlockVector3 getOrigin() {
return origin;
}
@Override
public void setOrigin(Vector origin) {
public void setOrigin(BlockVector3 origin) {
this.origin = origin;
}
@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();
}
@ -102,7 +102,7 @@ public class BlockArrayClipboard implements Clipboard {
public List<? extends Entity> getEntities(Region region) {
List<Entity> filtered = new ArrayList<>();
for (Entity entity : entities) {
if (region.contains(entity.getLocation().toVector())) {
if (region.contains(entity.getLocation().toVector().toBlockPoint())) {
filtered.add(entity);
}
}
@ -123,9 +123,9 @@ public class BlockArrayClipboard implements Clipboard {
}
@Override
public BlockState getBlock(Vector position) {
public BlockState getBlock(BlockVector3 position) {
if (region.contains(position)) {
Vector v = position.subtract(region.getMinimumPoint());
BlockVector3 v = position.subtract(region.getMinimumPoint());
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
if (block != null) {
return block.toImmutableState();
@ -136,9 +136,9 @@ public class BlockArrayClipboard implements Clipboard {
}
@Override
public BaseBlock getFullBlock(Vector position) {
public BaseBlock getFullBlock(BlockVector3 position) {
if (region.contains(position)) {
Vector v = position.subtract(region.getMinimumPoint());
BlockVector3 v = position.subtract(region.getMinimumPoint());
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
if (block != null) {
return block.toBaseBlock();
@ -149,9 +149,9 @@ public class BlockArrayClipboard implements Clipboard {
}
@Override
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
if (region.contains(position)) {
Vector v = position.subtract(region.getMinimumPoint());
BlockVector3 v = position.subtract(region.getMinimumPoint());
blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = block;
return true;
} else {
@ -160,12 +160,12 @@ public class BlockArrayClipboard implements Clipboard {
}
@Override
public BaseBiome getBiome(Vector2D position) {
public BaseBiome getBiome(BlockVector2 position) {
return new BaseBiome(0);
}
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
return false;
}

View File

@ -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);
}

View File

@ -30,14 +30,13 @@ import com.sk89q.jnbt.NamedTag;
import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
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;
@ -105,7 +104,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
// Metadata
// ====================================================================
Vector origin;
BlockVector3 origin;
Region region;
// Get information
@ -117,18 +116,18 @@ public class MCEditSchematicReader extends NBTSchematicReader {
int originX = requireTag(schematic, "WEOriginX", IntTag.class).getValue();
int originY = requireTag(schematic, "WEOriginY", IntTag.class).getValue();
int originZ = requireTag(schematic, "WEOriginZ", IntTag.class).getValue();
Vector min = new Vector(originX, originY, originZ);
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();
Vector offset = new Vector(offsetX, offsetY, offsetZ);
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
origin = min.subtract(offset);
region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
} catch (IOException ignored) {
origin = new Vector(0, 0, 0);
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE));
origin = BlockVector3.ZERO;
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
}
// ====================================================================
@ -162,7 +161,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
// Need to pull out tile entities
List<Tag> tileEntities = requireTag(schematic, "TileEntities", ListTag.class).getValue();
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
for (Tag tag : tileEntities) {
if (!(tag instanceof CompoundTag)) continue;
@ -206,7 +205,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
}
}
BlockVector vec = new BlockVector(x, y, z);
BlockVector3 vec = new BlockVector3(x, y, z);
tileEntitiesMap.put(vec, values);
}
@ -220,7 +219,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
for (int y = 0; y < height; ++y) {
for (int z = 0; z < length; ++z) {
int index = y * width * length + z * width + x;
BlockVector pt = new BlockVector(x, y, z);
BlockVector3 pt = new BlockVector3(x, y, z);
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
try {

View File

@ -31,8 +31,6 @@ import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.NamedTag;
import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.input.InputParseException;
@ -40,6 +38,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;
@ -96,7 +95,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
}
private Clipboard readVersion1(Map<String, Tag> schematic) throws IOException {
Vector origin;
BlockVector3 origin;
Region region;
Map<String, Tag> metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue();
@ -110,19 +109,19 @@ public class SpongeSchematicReader extends NBTSchematicReader {
throw new IOException("Invalid offset specified in schematic.");
}
Vector min = new Vector(offsetParts[0], offsetParts[1], offsetParts[2]);
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();
Vector offset = new Vector(offsetX, offsetY, offsetZ);
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
origin = min.subtract(offset);
region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
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(Vector.ONE));
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
}
int paletteMax = requireTag(schematic, "PaletteMax", IntTag.class).getValue();
@ -151,7 +150,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
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)
@ -160,7 +159,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
for (Map<String, Tag> tileEntity : tileEntityTags) {
int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
tileEntitiesMap.put(new BlockVector(pos[0], pos[1], pos[2]).toBlockVector(), tileEntity);
tileEntitiesMap.put(new BlockVector3(pos[0], pos[1], pos[2]), tileEntity);
}
} catch (Exception e) {
throw new IOException("Failed to load Tile Entities: " + e.getMessage());
@ -193,7 +192,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
int z = (index % (width * length)) / width;
int x = (index % (width * length)) % width;
BlockState state = palette.get(value);
BlockVector pt = new BlockVector(x, y, z);
BlockVector3 pt = new BlockVector3(x, y, z);
try {
if (tileEntitiesMap.containsKey(pt)) {
Map<String, Tag> values = Maps.newHashMap(tileEntitiesMap.get(pt));

View File

@ -30,11 +30,10 @@ import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -76,9 +75,9 @@ public class SpongeSchematicWriter implements ClipboardWriter {
*/
private Map<String, Tag> write1(Clipboard clipboard) throws IOException {
Region region = clipboard.getRegion();
Vector origin = clipboard.getOrigin();
Vector min = region.getMinimumPoint();
Vector offset = min.subtract(origin);
BlockVector3 origin = clipboard.getOrigin();
BlockVector3 min = region.getMinimumPoint();
BlockVector3 offset = min.subtract(origin);
int width = region.getWidth();
int height = region.getHeight();
int length = region.getLength();
@ -127,7 +126,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
int z0 = min.getBlockZ() + z;
for (int x = 0; x < width; x++) {
int x0 = min.getBlockX() + x;
BlockVector point = new BlockVector(x0, y0, z0);
BlockVector3 point = new BlockVector3(x0, y0, z0);
BaseBlock block = clipboard.getFullBlock(point);
if (block.getNbtData() != null) {
Map<String, Tag> values = new HashMap<>();

View File

@ -19,10 +19,10 @@
package com.sk89q.worldedit.extent.inventory;
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.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@ -82,7 +82,7 @@ public class BlockBagExtent extends AbstractDelegateExtent {
}
@Override
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
if (blockBag != null) {
BlockState existing = getExtent().getBlock(position);

View File

@ -19,15 +19,14 @@
package com.sk89q.worldedit.extent.reorder;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
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;
@ -49,11 +48,11 @@ 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<Vector2D> REGION_OPTIMIZED_SORT =
Comparator.<Vector2D, Vector2D>comparing(vec -> vec.divide(32).floor(), Vector2D.COMPARING_GRID_ARRANGEMENT)
.thenComparing(Vector2D.COMPARING_GRID_ARRANGEMENT);
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<BlockVector2D, LocatedBlockList> batches = new TreeMap<>(REGION_OPTIMIZED_SORT);
private final SortedMap<BlockVector2, LocatedBlockList> batches = new TreeMap<>(REGION_OPTIMIZED_SORT);
private boolean enabled;
public ChunkBatchingExtent(Extent extent) {
@ -74,11 +73,11 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent {
}
@Override
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
if (!enabled) {
return getExtent().setBlock(location, block);
}
BlockVector2D chunkPos = new BlockVector2D(location.getBlockX() >> 4, location.getBlockZ() >> 4);
BlockVector2 chunkPos = new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4);
batches.computeIfAbsent(chunkPos, k -> new LocatedBlockList()).add(location, block);
return true;
}

View File

@ -20,8 +20,6 @@
package com.sk89q.worldedit.extent.reorder;
import com.google.common.collect.Iterables;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
@ -30,6 +28,7 @@ import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.OperationQueue;
import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.LocatedBlock;
import com.sk89q.worldedit.util.collection.LocatedBlockList;
@ -95,7 +94,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
}
@Override
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
BlockState existing = getBlock(location);
if (!enabled) {
@ -104,18 +103,18 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
if (Blocks.shouldPlaceLast(block.getBlockType())) {
// Place torches, etc. last
stage2.add(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.toBlockVector(), block);
stage3.add(location, block);
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 {
stage1.add(location.toBlockVector(), block);
stage1.add(location, block);
return !existing.equalsFuzzy(block);
}
}
@ -135,21 +134,21 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
public Operation resume(RunContext run) throws WorldEditException {
Extent extent = getExtent();
final Set<BlockVector> blocks = new HashSet<>();
final Map<BlockVector, BlockStateHolder> blockTypes = new HashMap<>();
final Set<BlockVector3> blocks = new HashSet<>();
final Map<BlockVector3, BlockStateHolder> blockTypes = new HashMap<>();
for (LocatedBlock entry : stage3) {
final BlockVector pt = entry.getLocation().toBlockVector();
final BlockVector3 pt = entry.getLocation();
blocks.add(pt);
blockTypes.put(pt, entry.getBlock());
}
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);
@ -162,13 +161,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);
}
@ -192,7 +191,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);
}

View File

@ -22,16 +22,17 @@ package com.sk89q.worldedit.extent.transform;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Sets;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.registry.state.BooleanProperty;
import com.sk89q.worldedit.world.block.BaseBlock;
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;
import com.sk89q.worldedit.registry.state.DirectionalProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -84,17 +85,17 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
}
@Override
public BlockState getBlock(Vector position) {
public BlockState getBlock(BlockVector3 position) {
return transformBlock(super.getBlock(position), false);
}
@Override
public BaseBlock getFullBlock(Vector position) {
public BaseBlock getFullBlock(BlockVector3 position) {
return transformBlock(super.getFullBlock(position), false);
}
@Override
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
return super.setBlock(location, transformBlock(block, true));
}
@ -132,7 +133,7 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
if (property instanceof DirectionalProperty) {
Direction value = (Direction) block.getState(property);
if (value != null) {
Vector newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector());
Vector3 newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector());
if (newValue != null) {
changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL));
}
@ -171,9 +172,9 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
* @return a new state or null if none could be found
*/
@Nullable
private static Vector getNewStateValue(DirectionalProperty state, Transform transform, Vector oldDirection) {
Vector newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector.ZERO)).normalize();
Vector newValue = null;
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;
boolean found = false;

View File

@ -22,10 +22,10 @@ package com.sk89q.worldedit.extent.validation;
import static com.google.common.base.Preconditions.checkArgument;
import com.sk89q.worldedit.MaxChangedBlocksException;
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.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
/**
@ -77,7 +77,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);

View File

@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.validation;
import static com.google.common.base.Preconditions.checkNotNull;
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.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@ -49,7 +49,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()) {

View File

@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world;
import static com.google.common.base.Preconditions.checkNotNull;
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.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@ -51,7 +51,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()) {

View File

@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world;
import static com.google.common.base.Preconditions.checkNotNull;
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.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -61,7 +61,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);
}

View File

@ -21,12 +21,12 @@ package com.sk89q.worldedit.extent.world;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
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 com.sk89q.worldedit.world.block.BlockStateHolder;
@ -40,7 +40,7 @@ import java.util.Set;
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;
/**
@ -84,9 +84,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);

View File

@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world;
import static com.google.common.base.Preconditions.checkNotNull;
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.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -79,7 +79,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;

View File

@ -21,8 +21,8 @@ package com.sk89q.worldedit.function;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.ArrayList;
import java.util.Arrays;
@ -81,7 +81,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)) {

View File

@ -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;
}

View File

@ -21,12 +21,12 @@ package com.sk89q.worldedit.function;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector2;
/**
* 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 +50,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);
}

View File

@ -21,9 +21,9 @@ package com.sk89q.worldedit.function;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
/**
* Applies a {@link RegionFunction} to the first ground block.
@ -76,12 +76,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++;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -21,12 +21,12 @@ package com.sk89q.worldedit.function;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
/**
* 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 +49,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);
}

View File

@ -21,10 +21,10 @@ package com.sk89q.worldedit.function.biome;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector2D;
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;
/**
@ -49,7 +49,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);
}

View File

@ -19,10 +19,10 @@
package com.sk89q.worldedit.function.block;
import com.sk89q.worldedit.Vector;
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;
@ -47,7 +47,7 @@ public class BlockDistributionCounter implements RegionFunction {
}
@Override
public boolean apply(Vector position) throws WorldEditException {
public boolean apply(BlockVector3 position) throws WorldEditException {
BlockStateHolder blk = extent.getBlock(position);
if (fuzzy) {
blk = ((BlockState) blk).toFuzzy();

View File

@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.block;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
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;
/**
* Replaces blocks with a given pattern.
@ -49,7 +49,7 @@ public class BlockReplace implements RegionFunction {
}
@Override
public boolean apply(Vector position) throws WorldEditException {
public boolean apply(BlockVector3 position) throws WorldEditException {
return extent.setBlock(position, pattern.apply(position));
}

View File

@ -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;
}

View File

@ -23,15 +23,16 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.CompoundTagBuilder;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
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;
import com.sk89q.worldedit.world.block.BaseBlock;
/**
* Copies blocks from one extent to another.
@ -40,8 +41,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;
/**
@ -53,7 +54,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);
@ -67,10 +68,10 @@ public class ExtentBlockCopy implements RegionFunction {
}
@Override
public boolean apply(Vector position) throws WorldEditException {
public boolean apply(BlockVector3 position) throws WorldEditException {
BaseBlock block = source.getFullBlock(position);
Vector orig = position.subtract(from);
Vector transformed = transform.apply(orig);
BlockVector3 orig = position.subtract(from);
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
// Apply transformations to NBT data if necessary
block = transformNbtData(block);
@ -96,7 +97,7 @@ public class ExtentBlockCopy implements RegionFunction {
Direction direction = MCDirections.fromRotation(rot);
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 | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
if (newDirection != null) {

View File

@ -22,11 +22,11 @@ package com.sk89q.worldedit.function.block;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.LayerFunction;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockTypes;
/**
@ -61,12 +61,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) {

View File

@ -23,13 +23,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.CompoundTagBuilder;
import com.sk89q.worldedit.Vector;
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;
@ -42,8 +43,8 @@ import com.sk89q.worldedit.util.Location;
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;
@ -55,7 +56,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);
@ -91,13 +92,13 @@ public class ExtentEntityCopy implements EntityFunction {
Location newLocation;
Location location = entity.getLocation();
Vector pivot = from.round().add(0.5, 0.5, 0.5);
Vector newPosition = transform.apply(location.toVector().subtract(pivot));
Vector newDirection;
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(Vector.ZERO)).normalize();
: 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
@ -134,8 +135,8 @@ public class ExtentEntityCopy implements EntityFunction {
boolean hasFacing = tag.containsKey("Facing");
if (hasTilePosition) {
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();
CompoundTagBuilder builder = tag.createBuilder()
.putInt("TileX", newTilePosition.getBlockX())
@ -155,7 +156,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) {

View File

@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
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;
@ -32,6 +31,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;

View File

@ -20,12 +20,12 @@
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.function.RegionFunction;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -103,7 +103,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) {

View File

@ -20,9 +20,9 @@
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.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@ -49,7 +49,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();

View File

@ -21,11 +21,11 @@ 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;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -84,12 +84,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 +102,7 @@ public class GardenPatchGenerator implements RegionFunction {
int t = random.nextInt(4);
int h = random.nextInt(3) - 1;
Vector p;
BlockVector3 p;
BlockState log = BlockTypes.OAK_LOG.getDefaultState();
@ -158,7 +158,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 +198,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);
}

View File

@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector2D;
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 +90,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);
}

View File

@ -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));
}

View File

@ -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.BlockStateHolder;
import java.util.Arrays;
@ -94,7 +94,7 @@ public class BlockMask extends AbstractExtentMask {
}
@Override
public boolean test(Vector vector) {
public boolean test(BlockVector3 vector) {
BlockStateHolder block = getExtent().getBlock(vector);
for (BlockStateHolder testBlock : blocks) {
if (testBlock.equalsFuzzy(block)) {

Some files were not shown because too many files have changed in this diff Show More