Continue the great purge

This commit is contained in:
Matthew Miller
2018-06-16 15:29:48 +10:00
parent c537a2e948
commit 20bf6e079b
63 changed files with 313 additions and 2190 deletions

View File

@ -1,124 +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;
/**
* @deprecated Replace all uses of {@link WorldVector}s with {@link Location}s
*/
@SuppressWarnings("deprecation")
@Deprecated
public class BlockWorldVector extends WorldVector {
/**
* Construct an instance from another instance.
*
* @param position the position to copy
*/
public BlockWorldVector(WorldVector position) {
super(position.getWorld(), position);
}
/**
* Construct an instance from another instance.
*
* @param world the world
* @param position the position to copy
*/
public BlockWorldVector(LocalWorld world, Vector position) {
super(world, position);
}
/**
* Construct a new instance.
*
* @param world another instance
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(WorldVector world, int x, int y, int z) {
super(world.getWorld(), x, y, z);
}
/**
* Construct a new instance.
*
* @param world another instance
* @param v the other vector
*/
public BlockWorldVector(WorldVector world, Vector v) {
super(world.getWorld(), v.getX(), v.getY(), v.getZ());
}
/**
* Construct a new instance.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(LocalWorld world, int x, int y, int z) {
super(world, x, y, z);
}
/**
* Construct a new instance.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(LocalWorld world, float x, float y, float z) {
super(world, x, y, z);
}
/**
* Construct a new instance.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(LocalWorld world, double x, double y, double z) {
super(world, x, y, z);
}
@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 int hashCode() {
return (Integer.valueOf((int) x).hashCode() << 19) ^
(Integer.valueOf((int) y).hashCode() << 12) ^
Integer.valueOf((int) z).hashCode();
}
}

View File

@ -1,105 +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;
/**
* @deprecated Replace all uses of {@link WorldVector}s with {@link Location}s
*/
@SuppressWarnings("deprecation")
@Deprecated
public class BlockWorldVector2D extends WorldVector2D {
/**
* Construct a new instance.
*
* @param world the world
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockWorldVector2D(LocalWorld world, double x, double z) {
super(world, x, z);
}
/**
* Construct a new instance.
*
* @param world the world
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockWorldVector2D(LocalWorld world, float x, float z) {
super(world, x, z);
}
/**
* Construct a new instance.
*
* @param world the world
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockWorldVector2D(LocalWorld world, int x, int z) {
super(world, x, z);
}
/**
* Construct a new instance.
*
* @param world the world
* @param position a position
*/
public BlockWorldVector2D(LocalWorld world, Vector2D position) {
super(world, position);
}
/**
* Construct a new instance with X and Z set to (0, 0).
*
* @param world the world
*/
public BlockWorldVector2D(LocalWorld world) {
super(world);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof WorldVector2D)) {
return false;
}
WorldVector2D other = (WorldVector2D) obj;
return other.getWorld().equals(world)
&& (int) other.getX() == (int) this.x
&& (int) other.getZ() == (int) this.z;
}
@Override
public int hashCode() {
int result = super.hashCode();
long temp;
result = 31 * result + world.hashCode();
temp = Double.doubleToLongBits(x);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(z);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
}

View File

@ -23,6 +23,7 @@ import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.command.ClipboardCommands;
import com.sk89q.worldedit.command.SchematicCommands;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
@ -74,7 +75,7 @@ public class CuboidClipboard {
private Vector offset;
private Vector origin;
private Vector size;
private List<CopiedEntity> entities = new ArrayList<CopiedEntity>();
private List<CopiedEntity> entities = new ArrayList<>();
/**
* Constructs the clipboard.
@ -448,11 +449,14 @@ public class CuboidClipboard {
* @param newOrigin the new origin
* @return a list of entities that were pasted
*/
public LocalEntity[] pasteEntities(Vector newOrigin) {
LocalEntity[] entities = new LocalEntity[this.entities.size()];
public Entity[] pasteEntities(Vector newOrigin) {
Entity[] entities = new Entity[this.entities.size()];
for (int i = 0; i < this.entities.size(); ++i) {
CopiedEntity copied = this.entities.get(i);
if (copied.entity.spawn(copied.entity.getPosition().setPosition(copied.relativePosition.add(newOrigin)))) {
if (copied.entity.getExtent().createEntity(
copied.entity.getLocation().setPosition(copied.relativePosition.add(newOrigin)),
copied.entity.getState()
) != null) {
entities[i] = copied.entity;
}
}
@ -464,7 +468,7 @@ public class CuboidClipboard {
*
* @param entity the entity
*/
public void storeEntity(LocalEntity entity) {
public void storeEntity(Entity entity) {
this.entities.add(new CopiedEntity(entity));
}
@ -683,12 +687,12 @@ public class CuboidClipboard {
* Stores a copied entity.
*/
private class CopiedEntity {
private final LocalEntity entity;
private final Entity entity;
private final Vector relativePosition;
private CopiedEntity(LocalEntity entity) {
private CopiedEntity(Entity entity) {
this.entity = entity;
this.relativePosition = entity.getPosition().getPosition().subtract(getOrigin());
this.relativePosition = entity.getLocation().toVector().subtract(getOrigin());
}
}

View File

@ -132,31 +132,6 @@ public class EditSession implements Extent {
private Mask oldMask;
/**
* Create a new instance.
*
* @param world a world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @deprecated use {@link WorldEdit#getEditSessionFactory()} to create {@link EditSession}s
*/
@Deprecated
public EditSession(LocalWorld world, int maxBlocks) {
this(world, maxBlocks, null);
}
/**
* Create a new instance.
*
* @param world a world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @param blockBag the block bag to set, or null to use none
* @deprecated use {@link WorldEdit#getEditSessionFactory()} to create {@link EditSession}s
*/
@Deprecated
public EditSession(LocalWorld world, int maxBlocks, @Nullable BlockBag blockBag) {
this(WorldEdit.getInstance().getEventBus(), world, maxBlocks, blockBag, new EditSessionEvent(world, null, maxBlocks, null));
}
/**
* Construct the object with a maximum number of blocks and a block bag.
*

View File

@ -133,66 +133,6 @@ public class EditSessionFactory {
throw new RuntimeException("Method needs to be implemented");
}
// ------------------------------------------------------------------------
// Methods being deprecated
// ------------------------------------------------------------------------
/**
* Construct an edit session.
*
* @param world the world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @return an instance
* @deprecated We are replacing {@link LocalWorld} with {@link World}, so use {@link #getEditSession(World, int)} instead
*/
@Deprecated
public EditSession getEditSession(LocalWorld world, int maxBlocks) {
return getEditSession((World) world, maxBlocks);
}
/**
* Construct an edit session.
*
* @param world the world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @param player the player that the {@link EditSession} is for
* @return an instance
* @deprecated We are replacing {@link LocalWorld} with {@link World}, so use {@link #getEditSession(World, int, Player)} instead
*/
@Deprecated
public EditSession getEditSession(LocalWorld world, int maxBlocks, LocalPlayer player) {
return getEditSession((World) world, maxBlocks, player);
}
/**
* Construct an edit session.
*
* @param world the world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @param blockBag an optional {@link BlockBag} to use, otherwise null
* @return an instance
* @deprecated We are replacing {@link LocalWorld} with {@link World}, so use {@link #getEditSession(World, int, BlockBag)} instead
*/
@Deprecated
public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag) {
return getEditSession((World) world, maxBlocks, blockBag);
}
/**
* Construct an edit session.
*
* @param world the world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @param blockBag an optional {@link BlockBag} to use, otherwise null
* @param player the player that the {@link EditSession} is for
* @return an instance
* @deprecated We are replacing {@link LocalWorld} with {@link World}, so use {@link #getEditSession(World, int, BlockBag, Player)} instead
*/
@Deprecated
public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
return getEditSession((World) world, maxBlocks, blockBag, player);
}
/**
* Internal factory for {@link EditSession}s.
*/

View File

@ -1,49 +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.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
/**
* Holds an entity.
*
* @deprecated replaced with the new entity API using {@link Entity} and {@link BaseEntity}
*/
@Deprecated
public abstract class LocalEntity {
private final Location position;
protected LocalEntity(Location position) {
this.position = position;
}
public Location getPosition() {
return position;
}
public boolean spawn() {
return spawn(getPosition());
}
public abstract boolean spawn(Location loc);
}

View File

@ -1,34 +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.entity.Player;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
import com.sk89q.worldedit.extension.platform.Actor;
/**
* Represents a player that uses WorldEdit.
*
* @deprecated use {@link Actor} (or {@link Player}, etc.) instead (and {@link AbstractPlayerActor} to extend)
*/
@Deprecated
public abstract class LocalPlayer extends AbstractPlayerActor {
}

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jchronic.Chronic;
import com.sk89q.jchronic.Options;
import com.sk89q.jchronic.utils.Span;
@ -32,7 +34,6 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.internal.cui.CUIRegion;
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
@ -45,7 +46,6 @@ import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.snapshot.Snapshot;
import javax.annotation.Nullable;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedList;
@ -53,7 +53,7 @@ import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
/**
* Stores session information.
@ -70,13 +70,13 @@ public class LocalSession {
// Session related
private transient RegionSelector selector = new CuboidRegionSelector();
private transient boolean placeAtPos1 = false;
private transient LinkedList<EditSession> history = new LinkedList<EditSession>();
private transient LinkedList<EditSession> history = new LinkedList<>();
private transient int historyPointer = 0;
private transient ClipboardHolder clipboard;
private transient boolean toolControl = true;
private transient boolean superPickaxe = false;
private transient BlockTool pickaxeMode = new SinglePickaxe();
private transient Map<Integer, Tool> tools = new HashMap<Integer, Tool>();
private transient Map<Integer, Tool> tools = new HashMap<>();
private transient int maxBlocksChanged = -1;
private transient boolean useInventory;
private transient Snapshot snapshot;
@ -204,17 +204,6 @@ public class LocalSession {
historyPointer = history.size();
}
/**
* Performs an undo.
*
* @param newBlockBag a new block bag
* @param player the player
* @return whether anything was undone
*/
public EditSession undo(@Nullable BlockBag newBlockBag, LocalPlayer player) {
return undo(newBlockBag, (Player) player);
}
/**
* Performs an undo.
*
@ -239,17 +228,6 @@ public class LocalSession {
}
}
/**
* Performs a redo
*
* @param newBlockBag a new block bag
* @param player the player
* @return whether anything was redone
*/
public EditSession redo(@Nullable BlockBag newBlockBag, LocalPlayer player) {
return redo(newBlockBag, (Player) player);
}
/**
* Performs a redo
*
@ -293,14 +271,6 @@ public class LocalSession {
setDirty();
}
/**
* @deprecated Use {@link #getRegionSelector(World)}
*/
@Deprecated
public RegionSelector getRegionSelector(LocalWorld world) {
return getRegionSelector((World) world);
}
/**
* Get the region selector for defining the selection. If the selection
* was defined for a different world, the old selection will be discarded.
@ -317,22 +287,6 @@ public class LocalSession {
return selector;
}
/**
* @deprecated use {@link #getRegionSelector(World)}
*/
@Deprecated
public RegionSelector getRegionSelector() {
return selector;
}
/**
* @deprecated use {@link #setRegionSelector(World, RegionSelector)}
*/
@Deprecated
public void setRegionSelector(LocalWorld world, RegionSelector selector) {
setRegionSelector((World) world, selector);
}
/**
* Set the region selector.
*
@ -346,24 +300,6 @@ public class LocalSession {
this.selector = selector;
}
/**
* Returns true if the region is fully defined.
*
* @return true if a region selection is defined
*/
@Deprecated
public boolean isRegionDefined() {
return selector.isDefined();
}
/**
* @deprecated use {@link #isSelectionDefined(World)}
*/
@Deprecated
public boolean isSelectionDefined(LocalWorld world) {
return isSelectionDefined((World) world);
}
/**
* Returns true if the region is fully defined for the specified world.
*
@ -378,22 +314,6 @@ public class LocalSession {
return selector.isDefined();
}
/**
* @deprecated use {@link #getSelection(World)}
*/
@Deprecated
public Region getRegion() throws IncompleteRegionException {
return selector.getRegion();
}
/**
* @deprecated use {@link #getSelection(World)}
*/
@Deprecated
public Region getSelection(LocalWorld world) throws IncompleteRegionException {
return getSelection((World) world);
}
/**
* Get the selection region. If you change the region, you should
* call learnRegionChanges(). If the selection is defined in
@ -525,7 +445,7 @@ public class LocalSession {
public Vector getPlacementPosition(Player player) throws IncompleteRegionException {
checkNotNull(player);
if (!placeAtPos1) {
return player.getBlockIn();
return player.getBlockIn().toVector();
}
return selector.getPrimaryPosition();
@ -850,21 +770,12 @@ public class LocalSession {
}
}
/**
* @deprecated use {@link #createEditSession(Player)}
*/
@Deprecated
public EditSession createEditSession(LocalPlayer player) {
return createEditSession((Player) player);
}
/**
* Construct a new edit session.
*
* @param player the player
* @return an edit session
*/
@SuppressWarnings("deprecation")
public EditSession createEditSession(Player player) {
checkNotNull(player);

View File

@ -1,83 +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.blocks.BaseBlock;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.World;
/**
* A legacy abstract implementation of {@link World}. New implementations
* should use {@link AbstractWorld} when possible.
*
* @deprecated Replace with {@link World} wherever appropriate
*/
@Deprecated
public abstract class LocalWorld extends AbstractWorld {
@Override
public BaseBlock getLazyBlock(Vector position) {
return getBlock(position);
}
@Override
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) throws MaxChangedBlocksException {
switch (type) {
case BIG_TREE:
return generateBigTree(editSession, pt);
case BIRCH:
return generateBirchTree(editSession, pt);
case REDWOOD:
return generateRedwoodTree(editSession, pt);
case TALL_REDWOOD:
return generateTallRedwoodTree(editSession, pt);
default:
case TREE:
return generateTree(editSession, pt);
}
}
@Override
public boolean generateTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
@Override
public boolean generateBigTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
@Override
public boolean generateBirchTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
@Override
public boolean generateRedwoodTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
@Override
public boolean generateTallRedwoodTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
}

View File

@ -1,129 +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;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class Location {
private final LocalWorld world;
private final Vector position;
private final float yaw;
private final float pitch;
public Location(LocalWorld world, Vector position) {
this(world, position, 0, 0);
}
public Location(LocalWorld world, Vector position, float yaw, float pitch) {
this.world = world;
this.position = position;
this.yaw = yaw;
this.pitch = pitch;
}
public LocalWorld getWorld() {
return world;
}
public Vector getPosition() {
return position;
}
public float getYaw() {
return yaw;
}
public float getPitch() {
return pitch;
}
public Location setAngles(float yaw, float pitch) {
return new Location(world, position, yaw, pitch);
}
public Location setPosition(Vector position) {
return new Location(world, position, yaw, pitch);
}
public Location add(Vector other) {
return setPosition(position.add(other));
}
public Location add(double x, double y, double z) {
return setPosition(position.add(x, y, z));
}
public Vector getDirection() {
final double yawRadians = Math.toRadians(yaw);
final double pitchRadians = Math.toRadians(pitch);
final double y = -Math.sin(pitchRadians);
final double h = Math.cos(pitchRadians);
final double x = -h * Math.sin(yawRadians);
final double z = h * Math.cos(yawRadians);
return new Vector(x, y, z);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Location))
return false;
Location location = (Location) obj;
if (!world.equals(location.world))
return false;
if (!position.equals(location.position))
return false;
return true;
}
@Override
public int hashCode() {
return position.hashCode() + 19 * world.hashCode();
}
@Override
public String toString() {
return "World: " + world.getName() + ", Coordinates: " + position
+ ", Yaw: " + yaw + ", Pitch: " + pitch;
}
public static Location fromLookAt(LocalWorld world, Vector start, Vector lookAt) {
final Vector diff = lookAt.subtract(start);
return fromEye(world, start, diff);
}
public static Location fromEye(LocalWorld world, Vector start, Vector eye) {
final double eyeX = eye.getX();
final double eyeZ = eye.getZ();
final float yaw = (float) Math.toDegrees(Math.atan2(-eyeX, eyeZ));
final double length = Math.sqrt(eyeX * eyeX + eyeZ * eyeZ);
final float pitch = (float) Math.toDegrees(Math.atan2(-eye.getY(), length));
return new Location(world, start, yaw, pitch);
}
}

View File

@ -1,90 +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.util.Direction;
/**
* Represents the adjacency of one vector to another. Works similarly to
* Bukkit's BlockFace class.
*
* @deprecated to be replaced with {@link Direction}
*/
@Deprecated
public enum VectorFace {
NORTH(-1, 0, 0),
EAST(0, 0, -1),
SOUTH(1, 0, 0),
WEST(0, 0, 1),
UP(0, 1, 0),
DOWN(0, -1, 0),
NORTH_EAST(NORTH, EAST),
NORTH_WEST(NORTH, WEST),
SOUTH_EAST(SOUTH, EAST),
SOUTH_WEST(SOUTH, WEST),
ABOVE_NORTH(UP, NORTH),
BELOW_NORTH(DOWN, NORTH),
ABOVE_SOUTH(UP, SOUTH),
BELOW_SOUTH(DOWN, SOUTH),
ABOVE_WEST(UP, WEST),
BELOW_WEST(DOWN, WEST),
ABOVE_EAST(UP, EAST),
BELOW_EAST(DOWN, EAST),
SELF(0, 0, 0);
private final int modX;
private final int modY;
private final int modZ;
private VectorFace(final int modX, final int modY, final int modZ) {
this.modX = modX;
this.modY = modY;
this.modZ = modZ;
}
private VectorFace(VectorFace face1, VectorFace face2) {
this.modX = face1.getModX() + face2.getModX();
this.modY = face1.getModY() + face2.getModY();
this.modZ = face1.getModZ() + face2.getModZ();
}
public int getModX() {
return modX;
}
public int getModZ() {
return modZ;
}
public int getModY() {
return modY;
}
public static VectorFace fromMods(int modX2, int modY2, int modZ2) {
for (VectorFace face : values()) {
if (face.getModX() == modX2
&& face.getModY() == modY2
&& face.getModZ() == modZ2) {
return face;
}
}
return VectorFace.SELF;
}
}

View File

@ -42,6 +42,7 @@ import com.sk89q.worldedit.scripting.CraftScriptEngine;
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
import com.sk89q.worldedit.session.SessionManager;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameException;
@ -655,8 +656,8 @@ public class WorldEdit {
* @param clicked the clicked block
* @return false if you want the action to go through
*/
public boolean handleBlockRightClick(Player player, WorldVector clicked) {
BlockInteractEvent event = new BlockInteractEvent(player, clicked.toLocation(), OPEN);
public boolean handleBlockRightClick(Player player, Location clicked) {
BlockInteractEvent event = new BlockInteractEvent(player, clicked, OPEN);
getEventBus().post(event);
return event.isCancelled();
}
@ -668,8 +669,8 @@ public class WorldEdit {
* @param clicked the clicked block
* @return false if you want the action to go through
*/
public boolean handleBlockLeftClick(Player player, WorldVector clicked) {
BlockInteractEvent event = new BlockInteractEvent(player, clicked.toLocation(), HIT);
public boolean handleBlockLeftClick(Player player, Location clicked) {
BlockInteractEvent event = new BlockInteractEvent(player, clicked, HIT);
getEventBus().post(event);
return event.isCancelled();
}

View File

@ -1,33 +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;
/**
* Represents a WorldEdit operation.
*
* @deprecated This will be removed with no direct replacement. Please use the
* WorldEdit API.
*/
@Deprecated
public abstract class WorldEditOperation {
public abstract void run(LocalSession session, LocalPlayer player, EditSession editSession) throws Throwable;
}

View File

@ -1,146 +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.internal.LocalWorldAdapter;
import com.sk89q.worldedit.world.World;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class WorldVector extends Vector {
private LocalWorld world;
/**
* Construct the Vector object.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public WorldVector(LocalWorld world, double x, double y, double z) {
super(x, y, z);
this.world = world;
}
/**
* Construct the Vector object.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public WorldVector(LocalWorld world, int x, int y, int z) {
super(x, y, z);
this.world = world;
}
/**
* Construct the Vector object.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public WorldVector(LocalWorld world, float x, float y, float z) {
super(x, y, z);
this.world = world;
}
/**
* Construct the Vector object.
*
* @param world a world
* @param other the position to copy
*/
public WorldVector(LocalWorld world, Vector other) {
super(other);
this.world = world;
}
/**
* Construct the Vector object.
*
* @param world a world
*/
public WorldVector(LocalWorld world) {
super();
this.world = world;
}
/**
* Construct the Vector object.
*
* @param location the location
*/
public WorldVector(com.sk89q.worldedit.util.Location location) {
this(LocalWorldAdapter.adapt((World) location.getExtent()), location.getX(), location.getY(), location.getZ());
}
/**
* Get the world.
*
* @return the world
*/
public LocalWorld getWorld() {
return world;
}
/**
* Get a block point from a point.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
* @return point
*/
public static WorldVector toBlockPoint(LocalWorld world, double x, double y,
double z) {
return new WorldVector(world, (int) Math.floor(x),
(int) Math.floor(y),
(int) Math.floor(z));
}
/**
* Gets a BlockVector version.
*
* @return BlockWorldVector
*/
public BlockWorldVector toWorldBlockVector() {
return new BlockWorldVector(this);
}
/**
* Return this object as a new preferred {@code Location}
* object.
*
* @return a new location object
*/
public com.sk89q.worldedit.util.Location toLocation() {
return new com.sk89q.worldedit.util.Location(getWorld(), this);
}
}

View File

@ -1,81 +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;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class WorldVector2D extends Vector2D {
protected LocalWorld world;
public WorldVector2D(LocalWorld world) {
super();
this.world = world;
}
public WorldVector2D(LocalWorld world, double x, double z) {
super(x, z);
this.world = world;
}
public WorldVector2D(LocalWorld world, float x, float z) {
super(x, z);
this.world = world;
}
public WorldVector2D(LocalWorld world, int x, int z) {
super(x, z);
this.world = world;
}
public WorldVector2D(LocalWorld world, Vector2D pt) {
super(pt);
this.world = world;
}
public LocalWorld getWorld() {
return world;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof WorldVector2D)) {
return false;
}
WorldVector2D other = (WorldVector2D) obj;
return other.world.equals(world) && other.x == this.x
&& other.z == this.z;
}
/**
* Gets the hash code.
*
* @return hash code
*/
@Override
public int hashCode() {
return (world.hashCode() >> 7) ^
((int) (Double.doubleToLongBits(x) ^ (Double.doubleToLongBits(x) >>> 32)) >> 13) ^
(int) (Double.doubleToLongBits(z) ^ (Double.doubleToLongBits(z) >>> 32));
}
}

View File

@ -1,107 +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;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class WorldVectorFace extends WorldVector {
private VectorFace face;
public WorldVectorFace(LocalWorld world, double x, double y, double z, VectorFace face) {
super(world, x, y, z);
this.face = face;
}
public WorldVectorFace(LocalWorld world, int x, int y, int z, VectorFace face) {
super(world, x, y, z);
this.face = face;
}
public WorldVectorFace(LocalWorld world, float x, float y, float z, VectorFace face) {
super(world, x, y, z);
this.face = face;
}
public WorldVectorFace(LocalWorld world, Vector pt, VectorFace face) {
super(world, pt);
this.face = face;
}
public WorldVectorFace(LocalWorld world, VectorFace face) {
super(world);
this.face = face;
}
/**
* Get the face.
*
* @return the face
*/
public VectorFace getFace() {
return face;
}
/**
* Get the WorldVector adjacent to this WorldVectorFace.
*
* @return the face vector
*/
public WorldVector getFaceVector() {
return new WorldVector(getWorld(),
getBlockX() - face.getModX(),
getBlockY() - face.getModY(),
getBlockZ() - face.getModZ());
}
/**
* Get a WorldVectorFace by comparing two vectors. Note that they need not be
* adjacent, as only the directions, not distance, will be taken into account.
*
* @param world the world in which the resulting vector should lie
* @param vector the original vector
* @param face the direction in which the face should lie
* @return a face
*/
public static WorldVectorFace getWorldVectorFace(LocalWorld world, Vector vector, Vector face) {
if (vector == null || face == null) return null;
// check which direction the face is from the vector
final int x1 = vector.getBlockX();
final int y1 = vector.getBlockY();
final int z1 = vector.getBlockZ();
int modX = x1 - face.getBlockX();
int modY = y1 - face.getBlockY();
int modZ = z1 - face.getBlockZ();
if (modX > 0) modX = 1;
else if (modX < 0) modX = -1;
else modX = 0;
if (modY > 0) modY = 1;
else if (modY < 0) modY = -1;
else modY = 0;
if (modZ > 0) modZ = 1;
else if (modZ < 0) modZ = -1;
else modZ = 0;
// construct new vector
return new WorldVectorFace(world, x1, y1, z1, VectorFace.fromMods(modX, modY, modZ));
}
}

View File

@ -54,11 +54,6 @@ public class ItemType {
}
}
@Deprecated
public com.sk89q.worldedit.blocks.ItemType getLegacyType() {
return com.sk89q.worldedit.blocks.ItemType.fromID(getLegacyId());
}
@Override
public int hashCode() {
return this.id.hashCode();

View File

@ -41,6 +41,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome;
@ -125,22 +126,22 @@ public class BiomeCommands {
@CommandPermissions("worldedit.biome.info")
public void biomeInfo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
BiomeRegistry biomeRegistry = player.getWorld().getWorldData().getBiomeRegistry();
Set<BaseBiome> biomes = new HashSet<BaseBiome>();
Set<BaseBiome> biomes = new HashSet<>();
String qualifier;
if (args.hasFlag('t')) {
Vector blockPosition = player.getBlockTrace(300);
Location blockPosition = player.getBlockTrace(300);
if (blockPosition == null) {
player.printError("No block in sight!");
return;
}
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector2D());
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toVector2D());
biomes.add(biome);
qualifier = "at line of sight point";
} else if (args.hasFlag('p')) {
BaseBiome biome = player.getWorld().getBiome(player.getPosition().toVector2D());
BaseBiome biome = player.getWorld().getBiome(player.getPosition().toVector().toVector2D());
biomes.add(biome);
qualifier = "at your position";
@ -191,7 +192,7 @@ public class BiomeCommands {
Mask2D mask2d = mask != null ? mask.toMask2D() : null;
if (atPosition) {
region = new CuboidRegion(player.getPosition(), player.getPosition());
region = new CuboidRegion(player.getPosition().toVector(), player.getPosition().toVector());
} else {
region = session.getSelection(world);
}

View File

@ -26,6 +26,7 @@ import com.sk89q.minecraft.util.commands.Logging;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.MathUtils;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.storage.LegacyChunkStore;
import com.sk89q.worldedit.world.storage.McRegionChunkStore;
@ -58,7 +59,7 @@ public class ChunkCommands {
)
@CommandPermissions("worldedit.chunkinfo")
public void chunkInfo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockIn();
Location pos = player.getBlockIn();
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);

View File

@ -28,8 +28,8 @@ import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.parametric.Optional;
import static com.google.common.base.Preconditions.checkNotNull;
@ -161,7 +161,7 @@ public class NavigationCommands {
@CommandPermissions("worldedit.navigation.jumpto.command")
public void jumpTo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
WorldVector pos = player.getSolidBlockTrace(300);
Location pos = player.getSolidBlockTrace(300);
if (pos != null) {
player.findFreePosition(pos);
player.print("Poof!");

View File

@ -49,6 +49,7 @@ import com.sk89q.worldedit.regions.selector.RegionSelectorType;
import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
import com.sk89q.worldedit.util.formatting.Style;
import com.sk89q.worldedit.util.formatting.StyledFragment;
@ -85,12 +86,12 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.pos")
public void pos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos;
Location pos;
if (args.argsLength() == 1) {
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
String[] coords = args.getString(0).split(",");
pos = new Vector(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]));
pos = new Location(player.getWorld(), Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]));
} else {
player.printError("Invalid coordinates " + args.getString(0));
return;
@ -99,13 +100,13 @@ public class SelectionCommands {
pos = player.getBlockIn();
}
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) {
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set.");
return;
}
session.getRegionSelector(player.getWorld())
.explainPrimarySelection(player, session, pos);
.explainPrimarySelection(player, session, pos.toVector());
}
@Command(
@ -119,11 +120,11 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.pos")
public void pos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos;
Location pos;
if (args.argsLength() == 1) {
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
String[] coords = args.getString(0).split(",");
pos = new Vector(Integer.parseInt(coords[0]),
pos = new Location(player.getWorld(), Integer.parseInt(coords[0]),
Integer.parseInt(coords[1]),
Integer.parseInt(coords[2]));
} else {
@ -134,13 +135,13 @@ public class SelectionCommands {
pos = player.getBlockIn();
}
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set.");
return;
}
session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos);
.explainSecondarySelection(player, session, pos.toVector());
}
@Command(
@ -152,17 +153,17 @@ public class SelectionCommands {
)
@CommandPermissions("worldedit.selection.hpos")
public void hpos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockTrace(300);
Location pos = player.getBlockTrace(300);
if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) {
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set.");
return;
}
session.getRegionSelector(player.getWorld())
.explainPrimarySelection(player, session, pos);
.explainPrimarySelection(player, session, pos.toVector());
} else {
player.printError("No block in sight!");
}
@ -177,17 +178,17 @@ public class SelectionCommands {
)
@CommandPermissions("worldedit.selection.hpos")
public void hpos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockTrace(300);
Location pos = player.getBlockTrace(300);
if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set.");
return;
}
session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos);
.explainSecondarySelection(player, session, pos.toVector());
} else {
player.printError("No block in sight!");
}
@ -241,7 +242,7 @@ public class SelectionCommands {
min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toVector());
} else {
// use player loc
min2D = ChunkStore.toChunk(player.getBlockIn());
min2D = ChunkStore.toChunk(player.getBlockIn().toVector());
}
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);

View File

@ -19,11 +19,12 @@
package com.sk89q.worldedit.command.tool;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
import com.sk89q.worldedit.entity.Player;
@ -34,11 +35,10 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Builds a shape at the place being looked at.
*/
@ -162,7 +162,7 @@ public class BrushTool implements TraceTool {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
WorldVector target = null;
Location target = null;
target = player.getBlockTrace(getRange(), true);
if (target == null) {
@ -189,7 +189,7 @@ public class BrushTool implements TraceTool {
}
try {
brush.build(editSession, target, material, size);
brush.build(editSession, target.toVector(), material, size);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {

View File

@ -25,6 +25,7 @@ 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.regions.RegionSelector;
import com.sk89q.worldedit.util.Location;
/**
* A wand that can be used at a distance.
@ -43,12 +44,12 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
WorldVector target = getTarget(player);
Location target = getTarget(player);
if (target == null) return true;
RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectPrimary(target, ActorSelectorLimits.forActor(player))) {
selector.explainPrimarySelection(player, session, target);
if (selector.selectPrimary(target.toVector(), ActorSelectorLimits.forActor(player))) {
selector.explainPrimarySelection(player, session, target.toVector());
}
return true;
@ -60,12 +61,12 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
WorldVector target = getTarget(player);
Location target = getTarget(player);
if (target == null) return true;
RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectSecondary(target, ActorSelectorLimits.forActor(player))) {
selector.explainSecondarySelection(player, session, target);
if (selector.selectSecondary(target.toVector(), ActorSelectorLimits.forActor(player))) {
selector.explainSecondarySelection(player, session, target.toVector());
}
return true;
@ -73,8 +74,8 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
return false;
}
public WorldVector getTarget(Player player) {
WorldVector target = null;
public Location getTarget(Player player) {
Location target;
if (this.range > -1) {
target = player.getBlockTrace(getRange(), true);
} else {

View File

@ -19,20 +19,24 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location;
/**
* A tool that can place (or remove) blocks at a distance.
*/
public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTool {
BaseBlock primary;
BaseBlock secondary;
private BaseBlock primary;
private BaseBlock secondary;
public LongRangeBuildTool(BaseBlock primary, BaseBlock secondary) {
super("worldedit.tool.lrbuild");
@ -47,14 +51,14 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
WorldVectorFace pos = getTargetFace(player);
Location pos = getTargetFace(player);
if (pos == null) return false;
EditSession eS = session.createEditSession(player);
try {
if (secondary.getType().getLegacyId() == BlockID.AIR) {
eS.setBlock(pos, secondary);
if (secondary.getType() == BlockTypes.AIR) {
eS.setBlock(pos.toVector(), secondary);
} else {
eS.setBlock(pos.getFaceVector(), secondary);
eS.setBlock(pos.getDirection(), secondary);
}
return true;
} catch (MaxChangedBlocksException e) {
@ -66,14 +70,14 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
WorldVectorFace pos = getTargetFace(player);
Location pos = getTargetFace(player);
if (pos == null) return false;
EditSession eS = session.createEditSession(player);
try {
if (primary.getType().getLegacyId() == BlockID.AIR) {
eS.setBlock(pos, primary);
if (primary.getType() == BlockTypes.AIR) {
eS.setBlock(pos.toVector(), primary);
} else {
eS.setBlock(pos.getFaceVector(), primary);
eS.setBlock(pos.getDirection(), primary);
}
return true;
} catch (MaxChangedBlocksException e) {
@ -82,9 +86,8 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
return false;
}
public WorldVectorFace getTargetFace(Player player) {
WorldVectorFace target = null;
target = player.getBlockTraceFace(getRange(), true);
public Location getTargetFace(Player player) {
Location target = player.getBlockTraceFace(getRange(), true);
if (target == null) {
player.printError("No block in sight!");

View File

@ -21,15 +21,14 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.math.convolution.HeightMap;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.math.convolution.GaussianKernel;
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
public class SmoothBrush implements Brush {
@ -47,9 +46,9 @@ public class SmoothBrush implements Brush {
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
WorldVector min = new WorldVector(LocalWorldAdapter.adapt(editSession.getWorld()), position.subtract(size, size, size));
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, max);
Region region = new CuboidRegion(editSession.getWorld(), min.toVector(), max);
HeightMap heightMap = new HeightMap(editSession, region, naturalOnly);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
heightMap.applyFilter(filter, iterations);

View File

@ -22,11 +22,10 @@ package com.sk89q.worldedit.entity;
import com.sk89q.worldedit.PlayerDirection;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.WorldVectorFace;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
/**
@ -100,14 +99,14 @@ public interface Player extends Entity, Actor {
*
* @param searchPos search position
*/
void findFreePosition(WorldVector searchPos);
void findFreePosition(Location searchPos);
/**
* Set the actor on the ground.
*
* @param searchPos The location to start searching from
*/
void setOnGround(WorldVector searchPos);
void setOnGround(Location searchPos);
/**
* Find a position for the player to stand that is not inside a block.
@ -179,14 +178,14 @@ public interface Player extends Entity, Actor {
*
* @return point
*/
WorldVector getBlockIn();
Location getBlockIn();
/**
* Get the point of the block that is being stood upon.
*
* @return point
*/
WorldVector getBlockOn();
Location getBlockOn();
/**
* Get the point of the block being looked at. May return null.
@ -196,7 +195,7 @@ public interface Player extends Entity, Actor {
* @param useLastBlock try to return the last valid air block found
* @return point
*/
WorldVector getBlockTrace(int range, boolean useLastBlock);
Location getBlockTrace(int range, boolean useLastBlock);
/**
* Get the face that the player is looking at.
@ -205,7 +204,7 @@ public interface Player extends Entity, Actor {
* @param useLastBlock try to return the last valid air block found
* @return a face
*/
WorldVectorFace getBlockTraceFace(int range, boolean useLastBlock);
Location getBlockTraceFace(int range, boolean useLastBlock);
/**
* Get the point of the block being looked at. May return null.
@ -213,7 +212,7 @@ public interface Player extends Entity, Actor {
* @param range How far to checks for blocks
* @return point
*/
WorldVector getBlockTrace(int range);
Location getBlockTrace(int range);
/**
* Get the point of the block being looked at. May return null.
@ -221,7 +220,7 @@ public interface Player extends Entity, Actor {
* @param range How far to checks for blocks
* @return point
*/
WorldVector getSolidBlockTrace(int range);
Location getSolidBlockTrace(int range);
/**
* Get the player's cardinal direction (N, W, NW, etc.). May return null.
@ -238,8 +237,7 @@ public interface Player extends Entity, Actor {
* @return the actor's position
* @deprecated use {@link #getLocation()}
*/
@Deprecated
WorldVector getPosition();
Location getPosition();
/**
* Get the player's view pitch in degrees.

View File

@ -19,24 +19,21 @@
package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.BlockWorldVector;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.PlayerDirection;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.WorldVectorFace;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ItemID;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TargetBlock;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import java.io.File;
@ -93,8 +90,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
}
@Override
public void findFreePosition(WorldVector searchPos) {
World world = searchPos.getWorld();
public void findFreePosition(Location searchPos) {
Extent world = searchPos.getExtent();
int x = searchPos.getBlockX();
int y = Math.max(0, searchPos.getBlockY());
int origY = y;
@ -102,7 +99,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte free = 0;
while (y <= world.getMaxY() + 2) {
while (y <= world.getMinimumPoint().getBlockY() + 2) {
if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
++free;
} else {
@ -112,8 +109,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (free == 2) {
if (y - 1 != origY) {
final Vector pos = new Vector(x, y - 2, z);
final int id = world.getBlockType(pos);
final int data = world.getBlockData(pos);
final int id = world.getBlock(pos).getId();
final int data = world.getBlock(pos).getData();
setPosition(new Vector(x + 0.5, y - 2 + BlockType.centralTopLimit(id, data), z + 0.5));
}
@ -125,16 +122,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
}
@Override
public void setOnGround(WorldVector searchPos) {
World world = searchPos.getWorld();
public void setOnGround(Location searchPos) {
Extent world = searchPos.getExtent();
int x = searchPos.getBlockX();
int y = Math.max(0, searchPos.getBlockY());
int z = searchPos.getBlockZ();
while (y >= 0) {
final Vector pos = new Vector(x, y, z);
final int id = world.getBlockType(pos);
final int data = world.getBlockData(pos);
final int id = world.getBlock(pos).getId();
final int data = world.getBlock(pos).getData();
if (!BlockType.canPassThrough(id, data)) {
setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id, data), z + 0.5));
return;
@ -151,16 +148,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean ascendLevel() {
final WorldVector pos = getBlockIn();
final Location pos = getBlockIn();
final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ();
final World world = pos.getWorld();
final Extent world = pos.getExtent();
byte free = 0;
byte spots = 0;
while (y <= world.getMaxY() + 2) {
while (y <= world.getMaximumPoint().getY() + 2) {
if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
++free;
} else {
@ -192,11 +189,11 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean descendLevel() {
final WorldVector pos = getBlockIn();
final Location pos = getBlockIn();
final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY() - 1);
final int z = pos.getBlockZ();
final World world = pos.getWorld();
final Extent world = pos.getExtent();
byte free = 0;
@ -242,19 +239,19 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
Vector pos = getBlockIn();
Location pos = getBlockIn();
int x = pos.getBlockX();
int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 2);
int z = pos.getBlockZ();
World world = getPosition().getWorld();
Extent world = getPosition().getExtent();
// No free space above
if (world.getBlockType(new Vector(x, y, z)) != 0) {
if (world.getBlock(new Vector(x, y, z)).getId() != 0) {
return false;
}
while (y <= world.getMaxY()) {
while (y <= world.getMaximumPoint().getY()) {
// Found a ceiling!
if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
int platformY = Math.max(initialY, y - 3 - clearance);
@ -275,15 +272,15 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
final Vector pos = getBlockIn();
final Location pos = getBlockIn();
final int x = pos.getBlockX();
final int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 1);
final int z = pos.getBlockZ();
final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
final World world = getPosition().getWorld();
final Extent world = getPosition().getExtent();
while (y <= world.getMaxY() + 2) {
while (y <= world.getMaximumPoint().getY() + 2) {
if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
break; // Hit something
} else if (y > maxY + 1) {
@ -301,43 +298,43 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
getPosition().getWorld().setBlockType(new Vector(x, y - 1, z), BlockID.GLASS);
try {
getPosition().getExtent().setBlock(new Vector(x, y - 1, z), new BaseBlock(BlockTypes.GLASS));
} catch (WorldEditException e) {
e.printStackTrace();
}
setPosition(new Vector(x + 0.5, y, z + 0.5));
}
@Override
public WorldVector getBlockIn() {
WorldVector pos = getPosition();
return WorldVector.toBlockPoint(pos.getWorld(), pos.getX(),
pos.getY(), pos.getZ());
public Location getBlockIn() {
return getPosition();
}
@Override
public WorldVector getBlockOn() {
WorldVector pos = getPosition();
return WorldVector.toBlockPoint(pos.getWorld(), pos.getX(),
pos.getY() - 1, pos.getZ());
public Location getBlockOn() {
return getPosition().setY(getPosition().getY() - 1);
}
@Override
public WorldVector getBlockTrace(int range, boolean useLastBlock) {
public Location getBlockTrace(int range, boolean useLastBlock) {
TargetBlock tb = new TargetBlock(this, range, 0.2);
return (useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock());
}
@Override
public WorldVectorFace getBlockTraceFace(int range, boolean useLastBlock) {
public Location getBlockTraceFace(int range, boolean useLastBlock) {
TargetBlock tb = new TargetBlock(this, range, 0.2);
return (useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace());
}
@Override
public WorldVector getBlockTrace(int range) {
public Location getBlockTrace(int range) {
return getBlockTrace(range, false);
}
@Override
public WorldVector getSolidBlockTrace(int range) {
public Location getSolidBlockTrace(int range) {
TargetBlock tb = new TargetBlock(this, range, 0.2);
return tb.getSolidTargetBlock();
}
@ -383,14 +380,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
public boolean passThroughForwardWall(int range) {
int searchDist = 0;
TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
World world = getPosition().getWorld();
BlockWorldVector block;
Extent world = getPosition().getExtent();
Location block;
boolean firstBlock = true;
int freeToFind = 2;
boolean inFree = false;
while ((block = hitBlox.getNextBlock()) != null) {
boolean free = BlockType.canPassThrough(world.getBlock(block));
boolean free = BlockType.canPassThrough(world.getBlock(block.toVector()));
if (firstBlock) {
firstBlock = false;
@ -451,10 +448,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean equals(Object other) {
if (!(other instanceof LocalPlayer)) {
if (!(other instanceof Player)) {
return false;
}
LocalPlayer other2 = (LocalPlayer) other;
Player other2 = (Player) other;
return other2.getName().equals(getName());
}

View File

@ -19,12 +19,13 @@
package com.sk89q.worldedit.extension.platform;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.command.tool.BlockTool;
import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
import com.sk89q.worldedit.command.tool.DoubleActionTraceTool;
@ -44,7 +45,6 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Iterator;
@ -55,7 +55,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
/**
* Manages registered {@link Platform}s for WorldEdit. Platforms are
@ -403,7 +403,7 @@ public class PlatformManager {
return;
}
WorldVector pos = player.getSolidBlockTrace(getConfiguration().navigationWandMaxDistance);
Location pos = player.getSolidBlockTrace(getConfiguration().navigationWandMaxDistance);
if (pos != null) {
player.findFreePosition(pos);
} else {
@ -417,7 +417,7 @@ public class PlatformManager {
LocalSession session = worldEdit.getSessionManager().get(player);
Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof DoubleActionTraceTool) {
if (tool instanceof DoubleActionTraceTool) {
if (tool.canUse(player)) {
((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
event.setCancelled(true);

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.inventory.BlockBag;
@ -89,7 +88,7 @@ class PlayerProxy extends AbstractPlayerActor {
}
@Override
public WorldVector getPosition() {
public Location getPosition() {
return basePlayer.getPosition();
}

View File

@ -19,8 +19,8 @@
package com.sk89q.worldedit.extent.inventory;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.blocks.*;
import com.sk89q.worldedit.util.Location;
/**
* Represents a source to get blocks from and store removed ones.
@ -187,12 +187,12 @@ public abstract class BlockBag {
*
* @param pos the position
*/
public abstract void addSourcePosition(WorldVector pos);
public abstract void addSourcePosition(Location pos);
/**
* Adds a position to be used a source.
*
* @param pos the position
*/
public abstract void addSingleSourcePosition(WorldVector pos);
public abstract void addSingleSourcePosition(Location pos);
}

View File

@ -1,264 +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.internal;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.registry.WorldData;
import javax.annotation.Nullable;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Wraps {@link World}s into {@link LocalWorld}.
*/
@SuppressWarnings("deprecation")
public class LocalWorldAdapter extends LocalWorld {
private final World world;
private LocalWorldAdapter(World world) {
checkNotNull(world);
this.world = world;
}
@Override
public String getName() {
return world.getName();
}
@Override
public int getMaxY() {
return world.getMaxY();
}
@Override
public boolean isValidBlockType(int id) {
return world.isValidBlockType(id);
}
@Override
public boolean usesBlockData(int id) {
return world.usesBlockData(id);
}
@Override
public Mask createLiquidMask() {
return world.createLiquidMask();
}
@Override
@Deprecated
public int getBlockType(Vector pt) {
return world.getBlockType(pt);
}
@Override
@Deprecated
public int getBlockData(Vector pt) {
return world.getBlockData(pt);
}
@Override
public boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException {
return world.setBlock(position, block, notifyAndLight);
}
@Override
public int getBlockLightLevel(Vector position) {
return world.getBlockLightLevel(position);
}
@Override
public boolean clearContainerBlockContents(Vector position) {
return world.clearContainerBlockContents(position);
}
@Override
public BaseBiome getBiome(Vector2D position) {
return world.getBiome(position);
}
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
return world.setBiome(position, biome);
}
@Override
public void dropItem(Vector position, BaseItemStack item, int count) {
world.dropItem(position, item, count);
}
@Override
public void dropItem(Vector position, BaseItemStack item) {
world.dropItem(position, item);
}
@Override
public void simulateBlockMine(Vector position) {
world.simulateBlockMine(position);
}
@Override
public boolean regenerate(Region region, EditSession editSession) {
return world.regenerate(region, editSession);
}
@Override
public boolean generateTree(TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateTree(type, editSession, position);
}
@Override
@Deprecated
public boolean generateTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateTree(editSession, position);
}
@Override
@Deprecated
public boolean generateBigTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateBigTree(editSession, position);
}
@Override
@Deprecated
public boolean generateBirchTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateBirchTree(editSession, position);
}
@Override
@Deprecated
public boolean generateRedwoodTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateRedwoodTree(editSession, position);
}
@Override
@Deprecated
public boolean generateTallRedwoodTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateTallRedwoodTree(editSession, position);
}
@Override
public void checkLoadedChunk(Vector position) {
world.checkLoadedChunk(position);
}
@Override
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
world.fixAfterFastMode(chunks);
}
@Override
public void fixLighting(Iterable<BlockVector2D> chunks) {
world.fixLighting(chunks);
}
@Override
public boolean playEffect(Vector position, int type, int data) {
return world.playEffect(position, type, data);
}
@Override
public boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority) {
return world.queueBlockBreakEffect(server, position, blockId, priority);
}
@Override
public WorldData getWorldData() {
return world.getWorldData();
}
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object other) {
return world.equals(other);
}
@Override
public int hashCode() {
return world.hashCode();
}
@Override
public Vector getMinimumPoint() {
return world.getMinimumPoint();
}
@Override
public Vector getMaximumPoint() {
return world.getMaximumPoint();
}
@Override
public List<? extends Entity> getEntities(Region region) {
return world.getEntities(region);
}
@Override
public BaseBlock getBlock(Vector position) {
return world.getBlock(position);
}
@Override
public BaseBlock getLazyBlock(Vector position) {
return world.getLazyBlock(position);
}
@Override
@Nullable
public Operation commit() {
return world.commit();
}
@Override
@Nullable
public Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
return world.createEntity(location, entity);
}
@Override
public List<? extends Entity> getEntities() {
return world.getEntities();
}
public static LocalWorldAdapter adapt(World world) {
return new LocalWorldAdapter(world);
}
}

View File

@ -99,7 +99,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv
}
if (logMode != null && sender.isPlayer()) {
Vector position = player.getPosition();
Vector position = player.getPosition().toVector();
LocalSession session = worldEdit.getSessionManager().get(player);
switch (logMode) {

View File

@ -55,11 +55,6 @@ public abstract class AbstractRegion implements Region {
return world;
}
@Override
public void setWorld(LocalWorld world) {
setWorld((World) world);
}
@Override
public void setWorld(World world) {
this.world = world;
@ -89,7 +84,7 @@ public abstract class AbstractRegion implements Region {
final BlockVector min = getMinimumPoint().toBlockVector();
final BlockVector max = getMaximumPoint().toBlockVector();
final List<BlockVector2D> points = new ArrayList<BlockVector2D>(4);
final List<BlockVector2D> points = new ArrayList<>(4);
points.add(new BlockVector2D(min.getX(), min.getZ()));
points.add(new BlockVector2D(min.getX(), max.getZ()));
@ -160,7 +155,7 @@ public abstract class AbstractRegion implements Region {
*/
@Override
public Set<Vector2D> getChunks() {
final Set<Vector2D> chunks = new HashSet<Vector2D>();
final Set<Vector2D> chunks = new HashSet<>();
final Vector min = getMinimumPoint();
final Vector max = getMaximumPoint();
@ -185,7 +180,7 @@ public abstract class AbstractRegion implements Region {
@Override
public Set<Vector> getChunkCubes() {
final Set<Vector> chunks = new HashSet<Vector>();
final Set<Vector> chunks = new HashSet<>();
final Vector min = getMinimumPoint();
final Vector max = getMaximumPoint();

View File

@ -19,13 +19,13 @@
package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.LocalWorld;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.regions.polyhedron.Edge;
import com.sk89q.worldedit.regions.polyhedron.Triangle;
import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@ -33,24 +33,24 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
public class ConvexPolyhedralRegion extends AbstractRegion {
/**
* Vertices that are contained in the convex hull.
*/
private final Set<Vector> vertices = new LinkedHashSet<Vector>();
private final Set<Vector> vertices = new LinkedHashSet<>();
/**
* Triangles that form the convex hull.
*/
private final List<Triangle> triangles = new ArrayList<Triangle>();
private final List<Triangle> triangles = new ArrayList<>();
/**
* Vertices that are coplanar to the first 3 vertices.
*/
private final Set<Vector> vertexBacklog = new LinkedHashSet<Vector>();
private final Set<Vector> vertexBacklog = new LinkedHashSet<>();
/**
* Minimum point of the axis-aligned bounding box.
@ -81,14 +81,6 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
super(world);
}
/**
* @deprecated cast {@code world} to {@link World}
*/
@Deprecated
public ConvexPolyhedralRegion(LocalWorld world) {
super(world);
}
/**
* Constructs an independent copy of the given region.
*
@ -174,7 +166,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
}
// Look for triangles that face the vertex and remove them
final Set<Edge> borderEdges = new LinkedHashSet<Edge>();
final Set<Edge> borderEdges = new LinkedHashSet<>();
for (Iterator<Triangle> it = triangles.iterator(); it.hasNext(); ) {
final Triangle triangle = it.next();
@ -207,7 +199,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
vertices.remove(vertex);
// Clone, clear and work through the backlog
final List<Vector> vertexBacklog2 = new ArrayList<Vector>(vertexBacklog);
final List<Vector> vertexBacklog2 = new ArrayList<>(vertexBacklog);
vertexBacklog.clear();
for (Vector vertex2 : vertexBacklog2) {
addVertex(vertex2);
@ -269,7 +261,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
}
private static void shiftCollection(Collection<Vector> collection, Vector change) {
final List<Vector> tmp = new ArrayList<Vector>(collection);
final List<Vector> tmp = new ArrayList<>(collection);
collection.clear();
for (Vector vertex : tmp) {
collection.add(change.add(vertex));
@ -323,7 +315,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
return vertices;
}
final List<Vector> ret = new ArrayList<Vector>(vertices);
final List<Vector> ret = new ArrayList<>(vertices);
ret.addAll(vertexBacklog);
return ret;

View File

@ -19,9 +19,10 @@
package com.sk89q.worldedit.regions;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.extent.Extent;
@ -33,8 +34,6 @@ import com.sk89q.worldedit.world.World;
import java.util.Iterator;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Represents a cylindrical region.
*/
@ -53,13 +52,6 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
this((World) null);
}
/**
* @deprecated cast {@code world} to {@link World}
*/
@Deprecated
public CylinderRegion(LocalWorld world) {
this((World) world);
}
/**
* Construct the region.
*
@ -70,11 +62,6 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
hasY = false;
}
@Deprecated
public CylinderRegion(LocalWorld world, Vector center, Vector2D radius, int minY, int maxY) {
this((World) world, center, radius, minY, maxY);
}
/**
* Construct the region.
*

View File

@ -21,13 +21,13 @@ package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.storage.ChunkStore;
import java.util.Set;
import java.util.HashSet;
import java.util.Set;
/**
* Represents an ellipsoid region.
@ -54,11 +54,6 @@ public class EllipsoidRegion extends AbstractRegion {
this(null, pos1, pos2);
}
@Deprecated
public EllipsoidRegion(LocalWorld world, Vector center, Vector radius) {
this((World) world, center, radius);
}
/**
* Construct a new instance of this ellipsoid region.
*

View File

@ -107,11 +107,6 @@ public class NullRegion implements Region {
this.world = world;
}
@Override
public void setWorld(LocalWorld world) {
setWorld((World) world);
}
@Override
public NullRegion clone() {
return new NullRegion();

View File

@ -21,7 +21,6 @@ package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
@ -52,11 +51,6 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
this((World) null);
}
@Deprecated
public Polygonal2DRegion(LocalWorld world) {
this((World) world);
}
/**
* Construct the region.
*
@ -67,11 +61,6 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
hasY = false;
}
@Deprecated
public Polygonal2DRegion(LocalWorld world, List<BlockVector2D> points, int minY, int maxY) {
this((World) world, points, minY, maxY);
}
/**
* Construct the region.
*

View File

@ -21,7 +21,6 @@ package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.world.World;
@ -147,14 +146,6 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
*/
public void setWorld(@Nullable World world);
/**
* Sets the world that the selection is in.
*
* @param world the world, which may be null
*/
@Deprecated
public void setWorld(@Nullable LocalWorld world);
/**
* Make a clone of the region.
*

View File

@ -19,19 +19,19 @@
package com.sk89q.worldedit.regions;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Iterators;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.world.World;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* An intersection of several other regions. Any location that is contained in one
* of the child regions is considered as contained by this region.
@ -69,7 +69,7 @@ public class RegionIntersection extends AbstractRegion {
* @param world the world
* @param regions a list of regions, which is copied
*/
public RegionIntersection(LocalWorld world, List<Region> regions) {
public RegionIntersection(World world, List<Region> regions) {
super(world);
checkNotNull(regions);
checkArgument(!regions.isEmpty(), "empty region list is not supported");
@ -82,7 +82,7 @@ public class RegionIntersection extends AbstractRegion {
* @param world the world
* @param regions an array of regions, which is copied
*/
public RegionIntersection(LocalWorld world, Region... regions) {
public RegionIntersection(World world, Region... regions) {
super(world);
checkNotNull(regions);
checkArgument(regions.length > 0, "empty region list is not supported");

View File

@ -93,14 +93,6 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
}
}
/**
* @deprecated cast {@code world} to {@link World}
*/
@Deprecated
public Polygonal2DRegionSelector(@Nullable LocalWorld world, List<BlockVector2D> points, int minY, int maxY) {
this((World) world, points, minY, maxY);
}
/**
* Create a new selector.
*

View File

@ -31,7 +31,7 @@ import java.util.Set;
/**
* A region that mirrors the current selection according to the current
* {@link LocalSession} and {@link LocalWorld} set on the current
* {@link LocalSession} and {@link World} set on the current
* {@link Request}.
*
* <p>If a selection cannot be taken, then the selection will be assumed to be
@ -128,11 +128,6 @@ public class RequestSelection implements Region {
return getRegion().getWorld();
}
@Override
public void setWorld(LocalWorld world) {
setWorld((World) world);
}
@Override
public void setWorld(World world) {
getRegion().setWorld(world);

View File

@ -217,6 +217,15 @@ public class Location {
xz * Math.cos(yaw));
}
/**
* Get the direction as a {@link Direction}.
*
* @return The direction
*/
public Direction getDirectionEnum() {
return Direction.findClosest(getDirection(), Direction.Flag.ALL);
}
/**
* Create a clone of this object with the given direction.
*
@ -356,6 +365,16 @@ public class Location {
return new Location(extent, position.setZ(z), yaw, pitch);
}
/**
* Return a copy of this object with the position set to the given value.
*
* @param position The new position
* @return a new immutable instance
*/
public Location setPosition(Vector position) {
return new Location(extent, position, yaw, pitch);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

View File

@ -23,7 +23,7 @@ import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.world.World;
/**
* This class uses an inefficient method to figure out what block a player
@ -34,7 +34,7 @@ import com.sk89q.worldedit.internal.LocalWorldAdapter;
*/
public class TargetBlock {
private LocalWorld world;
private World world;
private int maxDistance;
private double checkDistance, curDistance;
private Vector targetPos = new Vector();
@ -47,33 +47,22 @@ public class TargetBlock {
*
* @param player player to work with
*/
public TargetBlock(LocalPlayer player) {
this.world = LocalWorldAdapter.adapt(player.getWorld());
this.setValues(player.getPosition(), player.getYaw(), player.getPitch(),
public TargetBlock(Player player) {
this.world = player.getWorld();
this.setValues(player.getPosition().toVector(), player.getYaw(), player.getPitch(),
300, 1.65, 0.2);
}
/**
* Constructor requiring a player, max distance and a checking distance
*
* @param player LocalPlayer to work with
* @param maxDistance how far it checks for blocks
* @param checkDistance how often to check for blocks, the smaller the more precise
*/
public TargetBlock(LocalPlayer player, int maxDistance, double checkDistance) {
this((Player) player, maxDistance, checkDistance);
}
/**
* Constructor requiring a player, max distance and a checking distance
*
* @param player LocalPlayer to work with
* @param player Player to work with
* @param maxDistance how far it checks for blocks
* @param checkDistance how often to check for blocks, the smaller the more precise
*/
public TargetBlock(Player player, int maxDistance, double checkDistance) {
this.world = LocalWorldAdapter.adapt(player.getWorld());
this.setValues(player.getPosition(), player.getYaw(), player.getPitch(), maxDistance, 1.65, checkDistance);
this.world = player.getWorld();
this.setValues(player.getPosition().toVector(), player.getYaw(), player.getPitch(), maxDistance, 1.65, checkDistance);
}
/**
@ -86,8 +75,7 @@ public class TargetBlock {
* @param viewHeight where the view is positioned in y-axis
* @param checkDistance how often to check for blocks, the smaller the more precise
*/
private void setValues(Vector loc, double xRotation, double yRotation,
int maxDistance, double viewHeight, double checkDistance) {
private void setValues(Vector loc, double xRotation, double yRotation, int maxDistance, double viewHeight, double checkDistance) {
this.maxDistance = maxDistance;
this.checkDistance = checkDistance;
this.curDistance = 0;
@ -111,11 +99,11 @@ public class TargetBlock {
*
* @return Block
*/
public BlockWorldVector getAnyTargetBlock() {
public Location getAnyTargetBlock() {
boolean searchForLastBlock = true;
BlockWorldVector lastBlock = null;
Location lastBlock = null;
while (getNextBlock() != null) {
if (world.getBlockType(getCurrentBlock()) == BlockID.AIR) {
if (world.getBlockType(getCurrentBlock().toVector()) == BlockID.AIR) {
if (searchForLastBlock) {
lastBlock = getCurrentBlock();
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
@ -126,7 +114,7 @@ public class TargetBlock {
break;
}
}
BlockWorldVector currentBlock = getCurrentBlock();
Location currentBlock = getCurrentBlock();
return (currentBlock != null ? currentBlock : lastBlock);
}
@ -136,8 +124,8 @@ public class TargetBlock {
*
* @return Block
*/
public BlockWorldVector getTargetBlock() {
while (getNextBlock() != null && world.getBlockType(getCurrentBlock()) == 0) ;
public Location getTargetBlock() {
while (getNextBlock() != null && world.getBlockType(getCurrentBlock().toVector()) == 0) ;
return getCurrentBlock();
}
@ -147,8 +135,8 @@ public class TargetBlock {
*
* @return Block
*/
public BlockWorldVector getSolidTargetBlock() {
while (getNextBlock() != null && BlockType.canPassThrough(world.getBlock(getCurrentBlock()))) ;
public Location getSolidTargetBlock() {
while (getNextBlock() != null && BlockType.canPassThrough(world.getBlock(getCurrentBlock().toVector()))) ;
return getCurrentBlock();
}
@ -157,7 +145,7 @@ public class TargetBlock {
*
* @return next block position
*/
public BlockWorldVector getNextBlock() {
public Location getNextBlock() {
prevPos = targetPos;
do {
curDistance += checkDistance;
@ -175,7 +163,7 @@ public class TargetBlock {
return null;
}
return new BlockWorldVector(world, targetPos);
return new Location(world, targetPos);
}
/**
@ -183,11 +171,11 @@ public class TargetBlock {
*
* @return block position
*/
public BlockWorldVector getCurrentBlock() {
public Location getCurrentBlock() {
if (curDistance > maxDistance) {
return null;
} else {
return new BlockWorldVector(world, targetPos);
return new Location(world, targetPos);
}
}
@ -196,18 +184,18 @@ public class TargetBlock {
*
* @return block position
*/
public BlockWorldVector getPreviousBlock() {
return new BlockWorldVector(world, prevPos);
public Location getPreviousBlock() {
return new Location(world, prevPos);
}
public WorldVectorFace getAnyTargetBlockFace() {
public Location getAnyTargetBlockFace() {
getAnyTargetBlock();
return WorldVectorFace.getWorldVectorFace(world, getCurrentBlock(), getPreviousBlock());
return getCurrentBlock().setDirection(getCurrentBlock().toVector().subtract(getPreviousBlock().toVector()));
}
public WorldVectorFace getTargetBlockFace() {
public Location getTargetBlockFace() {
getAnyTargetBlock();
return WorldVectorFace.getWorldVectorFace(world, getCurrentBlock(), getPreviousBlock());
return getCurrentBlock().setDirection(getCurrentBlock().toVector().subtract(getPreviousBlock().toVector()));
}
}