Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-07 20:10:06 +01:00
Refactor vector system to be cleaner
- Move Vector, etc. into `.math` package - Drop many methods that will be auto-promoted anyways, eg. with `divide(int)` and `divide(double)` the first is now gone. - Take Block vectors into their own class hierarchy - Make it clear throughout the API what takes blockvectors - many more improvements
Dieser Commit ist enthalten in:
Ursprung
d7c528247b
Commit
399e0ad5fa
@ -23,13 +23,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.sk89q.worldedit.NotABlockException;
|
import com.sk89q.worldedit.NotABlockException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -42,6 +43,7 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
|
|||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@ -159,7 +161,7 @@ public class BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static Location adapt(org.bukkit.Location location) {
|
public static Location adapt(org.bukkit.Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
Vector position = asVector(location);
|
Vector3 position = asVector(location);
|
||||||
return new com.sk89q.worldedit.util.Location(
|
return new com.sk89q.worldedit.util.Location(
|
||||||
adapt(location.getWorld()),
|
adapt(location.getWorld()),
|
||||||
position,
|
position,
|
||||||
@ -175,7 +177,7 @@ public class BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static org.bukkit.Location adapt(Location location) {
|
public static org.bukkit.Location adapt(Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
Vector position = location.toVector();
|
Vector3 position = location.toVector();
|
||||||
return new org.bukkit.Location(
|
return new org.bukkit.Location(
|
||||||
adapt((World) location.getExtent()),
|
adapt((World) location.getExtent()),
|
||||||
position.getX(), position.getY(), position.getZ(),
|
position.getX(), position.getY(), position.getZ(),
|
||||||
@ -190,7 +192,22 @@ public class BukkitAdapter {
|
|||||||
* @param position the WorldEdit position
|
* @param position the WorldEdit position
|
||||||
* @return a Bukkit location
|
* @return a Bukkit location
|
||||||
*/
|
*/
|
||||||
public static org.bukkit.Location adapt(org.bukkit.World world, Vector position) {
|
public static org.bukkit.Location adapt(org.bukkit.World world, Vector3 position) {
|
||||||
|
checkNotNull(world);
|
||||||
|
checkNotNull(position);
|
||||||
|
return new org.bukkit.Location(
|
||||||
|
world,
|
||||||
|
position.getX(), position.getY(), position.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Bukkit location from a WorldEdit position with a Bukkit world.
|
||||||
|
*
|
||||||
|
* @param world the Bukkit world
|
||||||
|
* @param position the WorldEdit position
|
||||||
|
* @return a Bukkit location
|
||||||
|
*/
|
||||||
|
public static org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) {
|
||||||
checkNotNull(world);
|
checkNotNull(world);
|
||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
return new org.bukkit.Location(
|
return new org.bukkit.Location(
|
||||||
@ -221,9 +238,20 @@ public class BukkitAdapter {
|
|||||||
* @param location The Bukkit location
|
* @param location The Bukkit location
|
||||||
* @return a WorldEdit vector
|
* @return a WorldEdit vector
|
||||||
*/
|
*/
|
||||||
public static Vector asVector(org.bukkit.Location location) {
|
public static Vector3 asVector(org.bukkit.Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
return new Vector(location.getX(), location.getY(), location.getZ());
|
return new Vector3(location.getX(), location.getY(), location.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a WorldEdit BlockVector from a Bukkit location.
|
||||||
|
*
|
||||||
|
* @param location The Bukkit location
|
||||||
|
* @return a WorldEdit vector
|
||||||
|
*/
|
||||||
|
public static BlockVector3 asBlockVector(org.bukkit.Location location) {
|
||||||
|
checkNotNull(location);
|
||||||
|
return new BlockVector3(location.getX(), location.getY(), location.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,22 +20,24 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.session.SessionKey;
|
import com.sk89q.worldedit.session.SessionKey;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -115,7 +117,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||||
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),
|
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),
|
||||||
pos.getZ(), yaw, pitch));
|
pos.getZ(), yaw, pitch));
|
||||||
}
|
}
|
||||||
@ -173,7 +175,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(new Vector(x + 0.5, y, z + 0.5));
|
setPosition(new Vector3(x + 0.5, y, z + 0.5));
|
||||||
player.setFlying(true);
|
player.setFlying(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +187,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
@Override
|
@Override
|
||||||
public com.sk89q.worldedit.util.Location getLocation() {
|
public com.sk89q.worldedit.util.Location getLocation() {
|
||||||
Location nativeLocation = player.getLocation();
|
Location nativeLocation = player.getLocation();
|
||||||
Vector position = BukkitAdapter.asVector(nativeLocation);
|
Vector3 position = BukkitAdapter.asVector(nativeLocation);
|
||||||
return new com.sk89q.worldedit.util.Location(
|
return new com.sk89q.worldedit.util.Location(
|
||||||
getWorld(),
|
getWorld(),
|
||||||
position,
|
position,
|
||||||
@ -243,7 +245,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendFakeBlock(Vector pos, BlockStateHolder block) {
|
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
|
||||||
Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
|
Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());
|
player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());
|
||||||
|
@ -21,16 +21,16 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.history.change.BlockChange;
|
import com.sk89q.worldedit.history.change.BlockChange;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.world.AbstractWorld;
|
import com.sk89q.worldedit.world.AbstractWorld;
|
||||||
@ -39,6 +39,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.TreeType;
|
import org.bukkit.TreeType;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -90,7 +91,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
List<Entity> ents = world.getEntities();
|
List<Entity> ents = world.getEntities();
|
||||||
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
|
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
|
||||||
for (Entity ent : ents) {
|
for (Entity ent : ents) {
|
||||||
if (region.contains(BukkitAdapter.asVector(ent.getLocation()))) {
|
if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) {
|
||||||
entities.add(BukkitAdapter.adapt(ent));
|
entities.add(BukkitAdapter.adapt(ent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,7 +160,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockLightLevel(Vector pt) {
|
public int getBlockLightLevel(BlockVector3 pt) {
|
||||||
return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel();
|
return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,14 +168,14 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
public boolean regenerate(Region region, EditSession editSession) {
|
public boolean regenerate(Region region, EditSession editSession) {
|
||||||
BlockStateHolder[] history = new BlockStateHolder[16 * 16 * (getMaxY() + 1)];
|
BlockStateHolder[] history = new BlockStateHolder[16 * 16 * (getMaxY() + 1)];
|
||||||
|
|
||||||
for (Vector2D chunk : region.getChunks()) {
|
for (BlockVector2 chunk : region.getChunks()) {
|
||||||
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
BlockVector3 min = new BlockVector3(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||||
|
|
||||||
// First save all the blocks inside
|
// First save all the blocks inside
|
||||||
for (int x = 0; x < 16; ++x) {
|
for (int x = 0; x < 16; ++x) {
|
||||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||||
for (int z = 0; z < 16; ++z) {
|
for (int z = 0; z < 16; ++z) {
|
||||||
Vector pt = min.add(x, y, z);
|
BlockVector3 pt = min.add(x, y, z);
|
||||||
int index = y * 16 * 16 + z * 16 + x;
|
int index = y * 16 * 16 + z * 16 + x;
|
||||||
history[index] = editSession.getFullBlock(pt);
|
history[index] = editSession.getFullBlock(pt);
|
||||||
}
|
}
|
||||||
@ -191,14 +192,14 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
for (int x = 0; x < 16; ++x) {
|
for (int x = 0; x < 16; ++x) {
|
||||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||||
for (int z = 0; z < 16; ++z) {
|
for (int z = 0; z < 16; ++z) {
|
||||||
Vector pt = min.add(x, y, z);
|
BlockVector3 pt = min.add(x, y, z);
|
||||||
int index = y * 16 * 16 + z * 16 + x;
|
int index = y * 16 * 16 + z * 16 + x;
|
||||||
|
|
||||||
// We have to restore the block if it was outside
|
// We have to restore the block if it was outside
|
||||||
if (!region.contains(pt)) {
|
if (!region.contains(pt)) {
|
||||||
editSession.smartSetBlock(pt, history[index]);
|
editSession.smartSetBlock(pt, history[index]);
|
||||||
} else { // Otherwise fool with history
|
} else { // Otherwise fool with history
|
||||||
editSession.getChangeSet().add(new BlockChange(pt.toBlockVector(), history[index], editSession.getFullBlock(pt)));
|
editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,7 +238,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean clearContainerBlockContents(Vector pt) {
|
public boolean clearContainerBlockContents(BlockVector3 pt) {
|
||||||
Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -291,7 +292,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) {
|
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 pt) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
TreeType bukkitType = toBukkitTreeType(type);
|
TreeType bukkitType = toBukkitTreeType(type);
|
||||||
return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType,
|
return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType,
|
||||||
@ -299,13 +300,13 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dropItem(Vector pt, BaseItemStack item) {
|
public void dropItem(Vector3 pt, BaseItemStack item) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
world.dropItemNaturally(BukkitAdapter.adapt(world, pt), BukkitAdapter.adapt(item));
|
world.dropItemNaturally(BukkitAdapter.adapt(world, pt), BukkitAdapter.adapt(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkLoadedChunk(Vector pt) {
|
public void checkLoadedChunk(BlockVector3 pt) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
|
|
||||||
if (!world.isChunkLoaded(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)) {
|
if (!world.isChunkLoaded(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)) {
|
||||||
@ -337,15 +338,15 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
|
public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
for (BlockVector2D chunkPos : chunks) {
|
for (BlockVector2 chunkPos : chunks) {
|
||||||
world.refreshChunk(chunkPos.getBlockX(), chunkPos.getBlockZ());
|
world.refreshChunk(chunkPos.getBlockX(), chunkPos.getBlockZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playEffect(Vector position, int type, int data) {
|
public boolean playEffect(Vector3 position, int type, int data) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
|
|
||||||
final Effect effect = effects.get(type);
|
final Effect effect = effects.get(type);
|
||||||
@ -404,18 +405,18 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulateBlockMine(Vector pt) {
|
public void simulateBlockMine(BlockVector3 pt) {
|
||||||
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally();
|
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public com.sk89q.worldedit.world.block.BlockState getBlock(Vector position) {
|
public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) {
|
||||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
|
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
|
public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
try {
|
try {
|
||||||
@ -438,7 +439,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(Vector position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position));
|
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position));
|
||||||
@ -448,7 +449,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(Vector2D position) {
|
public BaseBiome getBiome(BlockVector2 position) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
int id = adapter.getBiomeId(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
|
int id = adapter.getBiomeId(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
|
||||||
@ -459,7 +460,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
Biome bukkitBiome = adapter.getBiome(biome.getId());
|
Biome bukkitBiome = adapter.getBiome(biome.getId());
|
||||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
import org.bukkit.BlockChangeDelegate;
|
import org.bukkit.BlockChangeDelegate;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setBlockData(int x, int y, int z, BlockData blockData) {
|
public boolean setBlockData(int x, int y, int z, BlockData blockData) {
|
||||||
try {
|
try {
|
||||||
editSession.setBlock(new Vector(x, y, z), BukkitAdapter.adapt(blockData));
|
editSession.setBlock(new BlockVector3(x, y, z), BukkitAdapter.adapt(blockData));
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockData getBlockData(int x, int y, int z) {
|
public BlockData getBlockData(int x, int y, int z) {
|
||||||
return BukkitAdapter.adapt(editSession.getBlock(new Vector(x, y, z)));
|
return BukkitAdapter.adapt(editSession.getBlock(new BlockVector3(x, y, z)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,7 +59,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty(int x, int y, int z) {
|
public boolean isEmpty(int x, int y, int z) {
|
||||||
return editSession.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isAir();
|
return editSession.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter;
|
package com.sk89q.worldedit.bukkit.adapter;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -112,7 +112,7 @@ public interface BukkitImplAdapter {
|
|||||||
* @param pos The position
|
* @param pos The position
|
||||||
* @param nbtData The NBT Data
|
* @param nbtData The NBT Data
|
||||||
*/
|
*/
|
||||||
void sendFakeNBT(Player player, Vector pos, CompoundTag nbtData);
|
void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the client think it has operator status.
|
* Make the client think it has operator status.
|
||||||
|
@ -21,7 +21,7 @@ package com.sk89q.jnbt;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -167,9 +167,9 @@ public final class NBTUtils {
|
|||||||
* @param listTag the list tag
|
* @param listTag the list tag
|
||||||
* @return a vector
|
* @return a vector
|
||||||
*/
|
*/
|
||||||
public static Vector toVector(ListTag listTag) {
|
public static Vector3 toVector(ListTag listTag) {
|
||||||
checkNotNull(listTag);
|
checkNotNull(listTag);
|
||||||
return new Vector(listTag.asDouble(0), listTag.asDouble(1), listTag.asDouble(2));
|
return new Vector3(listTag.asDouble(0), listTag.asDouble(1), listTag.asDouble(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.util.yaml;
|
package com.sk89q.util.yaml;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.math.Vector2;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@ -111,9 +111,9 @@ public class YAMLNode {
|
|||||||
* @return the new object
|
* @return the new object
|
||||||
*/
|
*/
|
||||||
private Object prepareSerialization(Object value) {
|
private Object prepareSerialization(Object value) {
|
||||||
if (value instanceof Vector) {
|
if (value instanceof Vector3) {
|
||||||
Map<String, Double> out = new LinkedHashMap<>();
|
Map<String, Double> out = new LinkedHashMap<>();
|
||||||
Vector vec = (Vector) value;
|
Vector3 vec = (Vector3) value;
|
||||||
out.put("x", vec.getX());
|
out.put("x", vec.getX());
|
||||||
out.put("y", vec.getY());
|
out.put("y", vec.getY());
|
||||||
out.put("z", vec.getZ());
|
out.put("z", vec.getZ());
|
||||||
@ -201,7 +201,7 @@ public class YAMLNode {
|
|||||||
* @param path path to node (dot notation)
|
* @param path path to node (dot notation)
|
||||||
* @return string or default
|
* @return string or default
|
||||||
*/
|
*/
|
||||||
public Vector getVector(String path) {
|
public Vector3 getVector(String path) {
|
||||||
YAMLNode o = getNode(path);
|
YAMLNode o = getNode(path);
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -215,7 +215,7 @@ public class YAMLNode {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Vector(x, y, z);
|
return new Vector3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,7 +226,7 @@ public class YAMLNode {
|
|||||||
* @param path path to node (dot notation)
|
* @param path path to node (dot notation)
|
||||||
* @return string or default
|
* @return string or default
|
||||||
*/
|
*/
|
||||||
public Vector2D getVector2d(String path) {
|
public Vector2 getVector2(String path) {
|
||||||
YAMLNode o = getNode(path);
|
YAMLNode o = getNode(path);
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -239,7 +239,7 @@ public class YAMLNode {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Vector2D(x, z);
|
return new Vector2(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -251,8 +251,8 @@ public class YAMLNode {
|
|||||||
* @param def default value
|
* @param def default value
|
||||||
* @return string or default
|
* @return string or default
|
||||||
*/
|
*/
|
||||||
public Vector getVector(String path, Vector def) {
|
public Vector3 getVector(String path, Vector3 def) {
|
||||||
Vector v = getVector(path);
|
Vector3 v = getVector(path);
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
if (writeDefaults) setProperty(path, def);
|
if (writeDefaults) setProperty(path, def);
|
||||||
return def;
|
return def;
|
||||||
@ -558,9 +558,9 @@ public class YAMLNode {
|
|||||||
* @param def default value or null for an empty list as default
|
* @param def default value or null for an empty list as default
|
||||||
* @return list of integers
|
* @return list of integers
|
||||||
*/
|
*/
|
||||||
public List<Vector> getVectorList(String path, List<Vector> def) {
|
public List<Vector3> getVectorList(String path, List<Vector3> def) {
|
||||||
List<YAMLNode> raw = getNodeList(path, null);
|
List<YAMLNode> raw = getNodeList(path, null);
|
||||||
List<Vector> list = new ArrayList<>();
|
List<Vector3> list = new ArrayList<>();
|
||||||
|
|
||||||
for (YAMLNode o : raw) {
|
for (YAMLNode o : raw) {
|
||||||
Double x = o.getDouble("x");
|
Double x = o.getDouble("x");
|
||||||
@ -571,7 +571,7 @@ public class YAMLNode {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(new Vector(x, y, z));
|
list.add(new Vector3(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@ -588,10 +588,10 @@ public class YAMLNode {
|
|||||||
* @param def default value or null for an empty list as default
|
* @param def default value or null for an empty list as default
|
||||||
* @return list of integers
|
* @return list of integers
|
||||||
*/
|
*/
|
||||||
public List<Vector2D> getVector2dList(String path, List<Vector2D> def) {
|
public List<Vector2> getVector2List(String path, List<Vector2> def) {
|
||||||
|
|
||||||
List<YAMLNode> raw = getNodeList(path, null);
|
List<YAMLNode> raw = getNodeList(path, null);
|
||||||
List<Vector2D> list = new ArrayList<>();
|
List<Vector2> list = new ArrayList<>();
|
||||||
|
|
||||||
for (YAMLNode o : raw) {
|
for (YAMLNode o : raw) {
|
||||||
Double x = o.getDouble("x");
|
Double x = o.getDouble("x");
|
||||||
@ -601,7 +601,7 @@ public class YAMLNode {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(new Vector2D(x, z));
|
list.add(new Vector2(x, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@ -618,10 +618,10 @@ public class YAMLNode {
|
|||||||
* @param def default value or null for an empty list as default
|
* @param def default value or null for an empty list as default
|
||||||
* @return list of integers
|
* @return list of integers
|
||||||
*/
|
*/
|
||||||
public List<BlockVector2D> getBlockVector2dList(String path, List<BlockVector2D> def) {
|
public List<BlockVector2> getBlockVector2List(String path, List<BlockVector2> def) {
|
||||||
|
|
||||||
List<YAMLNode> raw = getNodeList(path, null);
|
List<YAMLNode> raw = getNodeList(path, null);
|
||||||
List<BlockVector2D> list = new ArrayList<>();
|
List<BlockVector2> list = new ArrayList<>();
|
||||||
|
|
||||||
for (YAMLNode o : raw) {
|
for (YAMLNode o : raw) {
|
||||||
Double x = o.getDouble("x");
|
Double x = o.getDouble("x");
|
||||||
@ -631,7 +631,7 @@ public class YAMLNode {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(new BlockVector2D(x, z));
|
list.add(new BlockVector2(x, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
||||||
* Copyright (C) WorldEdit team and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sk89q.worldedit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension of {@code Vector} that that compares with other instances
|
|
||||||
* using integer components.
|
|
||||||
*/
|
|
||||||
public class BlockVector extends Vector {
|
|
||||||
|
|
||||||
public static final BlockVector ZERO = new BlockVector(0, 0, 0);
|
|
||||||
public static final BlockVector UNIT_X = new BlockVector(1, 0, 0);
|
|
||||||
public static final BlockVector UNIT_Y = new BlockVector(0, 1, 0);
|
|
||||||
public static final BlockVector UNIT_Z = new BlockVector(0, 0, 1);
|
|
||||||
public static final BlockVector ONE = new BlockVector(1, 1, 1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance as a copy of another instance.
|
|
||||||
*
|
|
||||||
* @param position the other position
|
|
||||||
*/
|
|
||||||
public BlockVector(Vector position) {
|
|
||||||
super(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public BlockVector(int x, int y, int z) {
|
|
||||||
super(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public BlockVector(float x, float y, float z) {
|
|
||||||
super(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public BlockVector(double x, double y, double z) {
|
|
||||||
super(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return ((int) x ^ ((int) z << 12)) ^ ((int) y << 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (!(obj instanceof Vector)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Vector other = (Vector) obj;
|
|
||||||
return (int) other.getX() == (int) this.x && (int) other.getY() == (int) this.y
|
|
||||||
&& (int) other.getZ() == (int) this.z;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockVector toBlockVector() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
||||||
* Copyright (C) WorldEdit team and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sk89q.worldedit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension of {@code Vector2D} that that compares with other instances
|
|
||||||
* using integer components.
|
|
||||||
*/
|
|
||||||
public class BlockVector2D extends Vector2D {
|
|
||||||
|
|
||||||
public static final BlockVector2D ZERO = new BlockVector2D(0, 0);
|
|
||||||
public static final BlockVector2D UNIT_X = new BlockVector2D(1, 0);
|
|
||||||
public static final BlockVector2D UNIT_Z = new BlockVector2D(0, 1);
|
|
||||||
public static final BlockVector2D ONE = new BlockVector2D(1, 1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance from another instance.
|
|
||||||
*
|
|
||||||
* @param position the position to copy
|
|
||||||
*/
|
|
||||||
public BlockVector2D(Vector2D position) {
|
|
||||||
super(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public BlockVector2D(int x, int z) {
|
|
||||||
super(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public BlockVector2D(float x, float z) {
|
|
||||||
super(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public BlockVector2D(double x, double z) {
|
|
||||||
super(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return ((int) x << 16) ^ (int) z;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (!(obj instanceof Vector2D)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D other = (Vector2D) obj;
|
|
||||||
return (int) other.x == (int) this.x && (int) other.z == (int) this.z;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockVector2D toBlockVector2D() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -25,8 +25,6 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
|||||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||||
|
|
||||||
import com.sk89q.worldedit.function.block.BlockDistributionCounter;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
@ -48,6 +46,7 @@ import com.sk89q.worldedit.extent.world.FastModeExtent;
|
|||||||
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
|
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
|
||||||
import com.sk89q.worldedit.function.GroundFunction;
|
import com.sk89q.worldedit.function.GroundFunction;
|
||||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
||||||
|
import com.sk89q.worldedit.function.block.BlockDistributionCounter;
|
||||||
import com.sk89q.worldedit.function.block.BlockReplace;
|
import com.sk89q.worldedit.function.block.BlockReplace;
|
||||||
import com.sk89q.worldedit.function.block.Counter;
|
import com.sk89q.worldedit.function.block.Counter;
|
||||||
import com.sk89q.worldedit.function.block.Naturalizer;
|
import com.sk89q.worldedit.function.block.Naturalizer;
|
||||||
@ -81,7 +80,11 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
|
|||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MathUtils;
|
import com.sk89q.worldedit.math.MathUtils;
|
||||||
|
import com.sk89q.worldedit.math.Vector2;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.interpolation.Interpolation;
|
import com.sk89q.worldedit.math.interpolation.Interpolation;
|
||||||
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
||||||
import com.sk89q.worldedit.math.interpolation.Node;
|
import com.sk89q.worldedit.math.interpolation.Node;
|
||||||
@ -113,8 +116,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -139,7 +140,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
private static final Logger log = Logger.getLogger(EditSession.class.getCanonicalName());
|
private static final Logger log = Logger.getLogger(EditSession.class.getCanonicalName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by {@link #setBlock(Vector, BlockStateHolder, Stage)} to
|
* Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to
|
||||||
* determine which {@link Extent}s should be bypassed.
|
* determine which {@link Extent}s should be bypassed.
|
||||||
*/
|
*/
|
||||||
public enum Stage {
|
public enum Stage {
|
||||||
@ -451,22 +452,22 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(Vector2D position) {
|
public BaseBiome getBiome(BlockVector2 position) {
|
||||||
return bypassNone.getBiome(position);
|
return bypassNone.getBiome(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||||
return bypassNone.setBiome(position, biome);
|
return bypassNone.setBiome(position, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(Vector position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return world.getBlock(position);
|
return world.getBlock(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(Vector position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return world.getFullBlock(position);
|
return world.getFullBlock(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,7 +482,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||||
for (int y = maxY; y >= minY; --y) {
|
for (int y = maxY; y >= minY; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||||
BlockState block = getBlock(pt);
|
BlockState block = getBlock(pt);
|
||||||
if (block.getBlockType().getMaterial().isMovementBlocker()) {
|
if (block.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
return y;
|
return y;
|
||||||
@ -500,7 +501,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return whether the block changed
|
* @return whether the block changed
|
||||||
* @throws WorldEditException thrown on a set error
|
* @throws WorldEditException thrown on a set error
|
||||||
*/
|
*/
|
||||||
public boolean setBlock(Vector position, BlockStateHolder block, Stage stage) throws WorldEditException {
|
public boolean setBlock(BlockVector3 position, BlockStateHolder block, Stage stage) throws WorldEditException {
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
case BEFORE_HISTORY:
|
case BEFORE_HISTORY:
|
||||||
return bypassNone.setBlock(position, block);
|
return bypassNone.setBlock(position, block);
|
||||||
@ -520,7 +521,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @param block the block
|
* @param block the block
|
||||||
* @return whether the block changed
|
* @return whether the block changed
|
||||||
*/
|
*/
|
||||||
public boolean rawSetBlock(Vector position, BlockStateHolder block) {
|
public boolean rawSetBlock(BlockVector3 position, BlockStateHolder block) {
|
||||||
try {
|
try {
|
||||||
return setBlock(position, block, Stage.BEFORE_CHANGE);
|
return setBlock(position, block, Stage.BEFORE_CHANGE);
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
@ -535,7 +536,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @param block the block
|
* @param block the block
|
||||||
* @return whether the block changed
|
* @return whether the block changed
|
||||||
*/
|
*/
|
||||||
public boolean smartSetBlock(Vector position, BlockStateHolder block) {
|
public boolean smartSetBlock(BlockVector3 position, BlockStateHolder block) {
|
||||||
try {
|
try {
|
||||||
return setBlock(position, block, Stage.BEFORE_REORDER);
|
return setBlock(position, block, Stage.BEFORE_REORDER);
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
@ -544,7 +545,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector position, BlockStateHolder block) throws MaxChangedBlocksException {
|
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException {
|
||||||
try {
|
try {
|
||||||
return setBlock(position, block, Stage.BEFORE_HISTORY);
|
return setBlock(position, block, Stage.BEFORE_HISTORY);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
@ -562,7 +563,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return Whether the block changed -- not entirely dependable
|
* @return Whether the block changed -- not entirely dependable
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public boolean setBlock(Vector position, Pattern pattern) throws MaxChangedBlocksException {
|
public boolean setBlock(BlockVector3 position, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
return setBlock(position, pattern.apply(position));
|
return setBlock(position, pattern.apply(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,9 +576,9 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return the number of changed blocks
|
* @return the number of changed blocks
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
private int setBlocks(Set<Vector> vset, Pattern pattern) throws MaxChangedBlocksException {
|
private int setBlocks(Set<BlockVector3> vset, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
for (Vector v : vset) {
|
for (BlockVector3 v : vset) {
|
||||||
affected += setBlock(v, pattern) ? 1 : 0;
|
affected += setBlock(v, pattern) ? 1 : 0;
|
||||||
}
|
}
|
||||||
return affected;
|
return affected;
|
||||||
@ -623,12 +624,12 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
return getWorld().getMinimumPoint();
|
return getWorld().getMinimumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
return getWorld().getMaximumPoint();
|
return getWorld().getMaximumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,7 +691,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int fillXZ(Vector origin, BlockStateHolder block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
public int fillXZ(BlockVector3 origin, BlockStateHolder block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||||
return fillXZ(origin, new BlockPattern(block), radius, depth, recursive);
|
return fillXZ(origin, new BlockPattern(block), radius, depth, recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,14 +706,14 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int fillXZ(Vector origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
public int fillXZ(BlockVector3 origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||||
checkNotNull(origin);
|
checkNotNull(origin);
|
||||||
checkNotNull(pattern);
|
checkNotNull(pattern);
|
||||||
checkArgument(radius >= 0, "radius >= 0");
|
checkArgument(radius >= 0, "radius >= 0");
|
||||||
checkArgument(depth >= 1, "depth >= 1");
|
checkArgument(depth >= 1, "depth >= 1");
|
||||||
|
|
||||||
MaskIntersection mask = new MaskIntersection(
|
MaskIntersection mask = new MaskIntersection(
|
||||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))),
|
||||||
new BoundedHeightMask(
|
new BoundedHeightMask(
|
||||||
Math.max(origin.getBlockY() - depth + 1, 0),
|
Math.max(origin.getBlockY() - depth + 1, 0),
|
||||||
Math.min(getWorld().getMaxY(), origin.getBlockY())),
|
Math.min(getWorld().getMaxY(), origin.getBlockY())),
|
||||||
@ -747,7 +748,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int removeAbove(Vector position, int apothem, int height) throws MaxChangedBlocksException {
|
public int removeAbove(BlockVector3 position, int apothem, int height) throws MaxChangedBlocksException {
|
||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
checkArgument(apothem >= 1, "apothem >= 1");
|
checkArgument(apothem >= 1, "apothem >= 1");
|
||||||
checkArgument(height >= 1, "height >= 1");
|
checkArgument(height >= 1, "height >= 1");
|
||||||
@ -769,7 +770,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int removeBelow(Vector position, int apothem, int height) throws MaxChangedBlocksException {
|
public int removeBelow(BlockVector3 position, int apothem, int height) throws MaxChangedBlocksException {
|
||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
checkArgument(apothem >= 1, "apothem >= 1");
|
checkArgument(apothem >= 1, "apothem >= 1");
|
||||||
checkArgument(height >= 1, "height >= 1");
|
checkArgument(height >= 1, "height >= 1");
|
||||||
@ -791,12 +792,12 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int removeNear(Vector position, BlockType blockType, int apothem) throws MaxChangedBlocksException {
|
public int removeNear(BlockVector3 position, BlockType blockType, int apothem) throws MaxChangedBlocksException {
|
||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
checkArgument(apothem >= 1, "apothem >= 1");
|
checkArgument(apothem >= 1, "apothem >= 1");
|
||||||
|
|
||||||
Mask mask = new BlockTypeMask(this, blockType);
|
Mask mask = new BlockTypeMask(this, blockType);
|
||||||
Vector adjustment = new Vector(1, 1, 1).multiply(apothem - 1);
|
BlockVector3 adjustment = BlockVector3.ONE.multiply(apothem - 1);
|
||||||
Region region = new CuboidRegion(
|
Region region = new CuboidRegion(
|
||||||
getWorld(), // Causes clamping of Y range
|
getWorld(), // Causes clamping of Y range
|
||||||
position.add(adjustment.multiply(-1)),
|
position.add(adjustment.multiply(-1)),
|
||||||
@ -900,11 +901,11 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
checkNotNull(region);
|
checkNotNull(region);
|
||||||
checkNotNull(pattern);
|
checkNotNull(pattern);
|
||||||
|
|
||||||
Vector center = region.getCenter();
|
Vector3 center = region.getCenter();
|
||||||
Region centerRegion = new CuboidRegion(
|
Region centerRegion = new CuboidRegion(
|
||||||
getWorld(), // Causes clamping of Y range
|
getWorld(), // Causes clamping of Y range
|
||||||
new Vector(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
|
new BlockVector3(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
|
||||||
new Vector(MathUtils.roundHalfUp(center.getX()),
|
new BlockVector3(MathUtils.roundHalfUp(center.getX()),
|
||||||
center.getY(), MathUtils.roundHalfUp(center.getZ())));
|
center.getY(), MathUtils.roundHalfUp(center.getZ())));
|
||||||
return setBlocks(centerRegion, pattern);
|
return setBlocks(centerRegion, pattern);
|
||||||
}
|
}
|
||||||
@ -1054,7 +1055,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
checkNotNull(pattern);
|
checkNotNull(pattern);
|
||||||
|
|
||||||
BlockReplace replace = new BlockReplace(this, pattern);
|
BlockReplace replace = new BlockReplace(this, pattern);
|
||||||
RegionOffset offset = new RegionOffset(new Vector(0, 1, 0), replace);
|
RegionOffset offset = new RegionOffset(new BlockVector3(0, 1, 0), replace);
|
||||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), offset);
|
GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), offset);
|
||||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||||
Operations.completeLegacy(visitor);
|
Operations.completeLegacy(visitor);
|
||||||
@ -1089,13 +1090,13 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int stackCuboidRegion(Region region, Vector dir, int count, boolean copyAir) throws MaxChangedBlocksException {
|
public int stackCuboidRegion(Region region, BlockVector3 dir, int count, boolean copyAir) throws MaxChangedBlocksException {
|
||||||
checkNotNull(region);
|
checkNotNull(region);
|
||||||
checkNotNull(dir);
|
checkNotNull(dir);
|
||||||
checkArgument(count >= 1, "count >= 1 required");
|
checkArgument(count >= 1, "count >= 1 required");
|
||||||
|
|
||||||
Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||||
Vector to = region.getMinimumPoint();
|
BlockVector3 to = region.getMinimumPoint();
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
|
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
|
||||||
copy.setRepetitions(count);
|
copy.setRepetitions(count);
|
||||||
copy.setTransform(new AffineTransform().translate(dir.multiply(size)));
|
copy.setTransform(new AffineTransform().translate(dir.multiply(size)));
|
||||||
@ -1117,12 +1118,12 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks moved
|
* @return number of blocks moved
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int moveRegion(Region region, Vector dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
|
public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
|
||||||
checkNotNull(region);
|
checkNotNull(region);
|
||||||
checkNotNull(dir);
|
checkNotNull(dir);
|
||||||
checkArgument(distance >= 1, "distance >= 1 required");
|
checkArgument(distance >= 1, "distance >= 1 required");
|
||||||
|
|
||||||
Vector to = region.getMinimumPoint();
|
BlockVector3 to = region.getMinimumPoint();
|
||||||
|
|
||||||
// Remove the original blocks
|
// Remove the original blocks
|
||||||
com.sk89q.worldedit.function.pattern.Pattern pattern = replacement != null ?
|
com.sk89q.worldedit.function.pattern.Pattern pattern = replacement != null ?
|
||||||
@ -1161,7 +1162,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks moved
|
* @return number of blocks moved
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int moveCuboidRegion(Region region, Vector dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
|
public int moveCuboidRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
|
||||||
return moveRegion(region, dir, distance, copyAir, replacement);
|
return moveRegion(region, dir, distance, copyAir, replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1173,20 +1174,20 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int drainArea(Vector origin, double radius) throws MaxChangedBlocksException {
|
public int drainArea(BlockVector3 origin, double radius) throws MaxChangedBlocksException {
|
||||||
checkNotNull(origin);
|
checkNotNull(origin);
|
||||||
checkArgument(radius >= 0, "radius >= 0 required");
|
checkArgument(radius >= 0, "radius >= 0 required");
|
||||||
|
|
||||||
MaskIntersection mask = new MaskIntersection(
|
MaskIntersection mask = new MaskIntersection(
|
||||||
new BoundedHeightMask(0, getWorld().getMaxY()),
|
new BoundedHeightMask(0, getWorld().getMaxY()),
|
||||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))),
|
||||||
getWorld().createLiquidMask());
|
getWorld().createLiquidMask());
|
||||||
|
|
||||||
BlockReplace replace = new BlockReplace(this, new BlockPattern(BlockTypes.AIR.getDefaultState()));
|
BlockReplace replace = new BlockReplace(this, new BlockPattern(BlockTypes.AIR.getDefaultState()));
|
||||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace);
|
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace);
|
||||||
|
|
||||||
// Around the origin in a 3x3 block
|
// Around the origin in a 3x3 block
|
||||||
for (BlockVector position : CuboidRegion.fromCenter(origin, 1)) {
|
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||||
if (mask.test(position)) {
|
if (mask.test(position)) {
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
}
|
}
|
||||||
@ -1206,7 +1207,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int fixLiquid(Vector origin, double radius, BlockType fluid) throws MaxChangedBlocksException {
|
public int fixLiquid(BlockVector3 origin, double radius, BlockType fluid) throws MaxChangedBlocksException {
|
||||||
checkNotNull(origin);
|
checkNotNull(origin);
|
||||||
checkArgument(radius >= 0, "radius >= 0 required");
|
checkArgument(radius >= 0, "radius >= 0 required");
|
||||||
|
|
||||||
@ -1219,7 +1220,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
// There are boundaries that the routine needs to stay in
|
// There are boundaries that the routine needs to stay in
|
||||||
MaskIntersection mask = new MaskIntersection(
|
MaskIntersection mask = new MaskIntersection(
|
||||||
new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
||||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))),
|
||||||
blockMask
|
blockMask
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1227,7 +1228,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||||
|
|
||||||
// Around the origin in a 3x3 block
|
// Around the origin in a 3x3 block
|
||||||
for (BlockVector position : CuboidRegion.fromCenter(origin, 1)) {
|
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||||
if (liquidMask.test(position)) {
|
if (liquidMask.test(position)) {
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
}
|
}
|
||||||
@ -1249,7 +1250,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks changed
|
* @return number of blocks changed
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makeCylinder(Vector pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException {
|
public int makeCylinder(BlockVector3 pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException {
|
||||||
return makeCylinder(pos, block, radius, radius, height, filled);
|
return makeCylinder(pos, block, radius, radius, height, filled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1265,7 +1266,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks changed
|
* @return number of blocks changed
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makeCylinder(Vector pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) throws MaxChangedBlocksException {
|
public int makeCylinder(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
radiusX += 0.5;
|
radiusX += 0.5;
|
||||||
@ -1279,7 +1280,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pos.getBlockY() < 0) {
|
if (pos.getBlockY() < 0) {
|
||||||
pos = pos.setY(0);
|
pos = pos.withY(0);
|
||||||
} else if (pos.getBlockY() + height - 1 > world.getMaxY()) {
|
} else if (pos.getBlockY() + height - 1 > world.getMaxY()) {
|
||||||
height = world.getMaxY() - pos.getBlockY() + 1;
|
height = world.getMaxY() - pos.getBlockY() + 1;
|
||||||
}
|
}
|
||||||
@ -1343,7 +1344,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks changed
|
* @return number of blocks changed
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makeSphere(Vector pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException {
|
public int makeSphere(BlockVector3 pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException {
|
||||||
return makeSphere(pos, block, radius, radius, radius, filled);
|
return makeSphere(pos, block, radius, radius, radius, filled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1359,7 +1360,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks changed
|
* @return number of blocks changed
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makeSphere(Vector pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
|
public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
radiusX += 0.5;
|
radiusX += 0.5;
|
||||||
@ -1445,7 +1446,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks changed
|
* @return number of blocks changed
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makePyramid(Vector position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException {
|
public int makePyramid(BlockVector3 position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
int height = size;
|
int height = size;
|
||||||
@ -1485,7 +1486,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int thaw(Vector position, double radius)
|
public int thaw(BlockVector3 position, double radius)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
double radiusSq = radius * radius;
|
double radiusSq = radius * radius;
|
||||||
@ -1500,12 +1501,12 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
int ceilRadius = (int) Math.ceil(radius);
|
int ceilRadius = (int) Math.ceil(radius);
|
||||||
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
||||||
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
||||||
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
|
if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = world.getMaxY(); y >= 1; --y) {
|
for (int y = world.getMaxY(); y >= 1; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||||
BlockType id = getBlock(pt).getBlockType();
|
BlockType id = getBlock(pt).getBlockType();
|
||||||
|
|
||||||
if (id == BlockTypes.ICE) {
|
if (id == BlockTypes.ICE) {
|
||||||
@ -1536,7 +1537,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int simulateSnow(Vector position, double radius) throws MaxChangedBlocksException {
|
public int simulateSnow(BlockVector3 position, double radius) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
double radiusSq = radius * radius;
|
double radiusSq = radius * radius;
|
||||||
|
|
||||||
@ -1550,12 +1551,12 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
int ceilRadius = (int) Math.ceil(radius);
|
int ceilRadius = (int) Math.ceil(radius);
|
||||||
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
||||||
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
||||||
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
|
if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = world.getMaxY(); y >= 1; --y) {
|
for (int y = world.getMaxY(); y >= 1; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||||
BlockType id = getBlock(pt).getBlockType();
|
BlockType id = getBlock(pt).getBlockType();
|
||||||
|
|
||||||
if (id.getMaterial().isAir()) {
|
if (id.getMaterial().isAir()) {
|
||||||
@ -1604,7 +1605,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int green(Vector position, double radius, boolean onlyNormalDirt)
|
public int green(BlockVector3 position, double radius, boolean onlyNormalDirt)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
final double radiusSq = radius * radius;
|
final double radiusSq = radius * radius;
|
||||||
@ -1618,12 +1619,12 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
final int ceilRadius = (int) Math.ceil(radius);
|
final int ceilRadius = (int) Math.ceil(radius);
|
||||||
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
||||||
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
||||||
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
|
if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = world.getMaxY(); y >= 1; --y) {
|
for (int y = world.getMaxY(); y >= 1; --y) {
|
||||||
final Vector pt = new Vector(x, y, z);
|
final BlockVector3 pt = new BlockVector3(x, y, z);
|
||||||
final BlockState block = getBlock(pt);
|
final BlockState block = getBlock(pt);
|
||||||
|
|
||||||
if (block.getBlockType() == BlockTypes.DIRT ||
|
if (block.getBlockType() == BlockTypes.DIRT ||
|
||||||
@ -1652,7 +1653,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of patches created
|
* @return number of patches created
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makePumpkinPatches(Vector position, int apothem) throws MaxChangedBlocksException {
|
public int makePumpkinPatches(BlockVector3 position, int apothem) throws MaxChangedBlocksException {
|
||||||
// We want to generate pumpkins
|
// We want to generate pumpkins
|
||||||
GardenPatchGenerator generator = new GardenPatchGenerator(this);
|
GardenPatchGenerator generator = new GardenPatchGenerator(this);
|
||||||
generator.setPlant(GardenPatchGenerator.getPumpkinPattern());
|
generator.setPlant(GardenPatchGenerator.getPumpkinPattern());
|
||||||
@ -1681,7 +1682,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of trees created
|
* @return number of trees created
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makeForest(Vector basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
|
public int makeForest(BlockVector3 basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX()
|
for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX()
|
||||||
@ -1689,7 +1690,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ()
|
for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ()
|
||||||
+ size; ++z) {
|
+ size; ++z) {
|
||||||
// Don't want to be in the ground
|
// Don't want to be in the ground
|
||||||
if (!getBlock(new Vector(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) {
|
if (!getBlock(new BlockVector3(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// The gods don't want a tree here
|
// The gods don't want a tree here
|
||||||
@ -1699,13 +1700,13 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
|
|
||||||
for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) {
|
for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) {
|
||||||
// Check if we hit the ground
|
// Check if we hit the ground
|
||||||
BlockType t = getBlock(new Vector(x, y, z)).getBlockType();
|
BlockType t = getBlock(new BlockVector3(x, y, z)).getBlockType();
|
||||||
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
|
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
|
||||||
treeType.generate(this, new Vector(x, y + 1, z));
|
treeType.generate(this, new BlockVector3(x, y + 1, z));
|
||||||
++affected;
|
++affected;
|
||||||
break;
|
break;
|
||||||
} else if (t == BlockTypes.SNOW) {
|
} else if (t == BlockTypes.SNOW) {
|
||||||
setBlock(new Vector(x, y, z), BlockTypes.AIR.getDefaultState());
|
setBlock(new BlockVector3(x, y, z), BlockTypes.AIR.getDefaultState());
|
||||||
} else if (!t.getMaterial().isAir()) { // Trees won't grow on this!
|
} else if (!t.getMaterial().isAir()) { // Trees won't grow on this!
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1729,7 +1730,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
return count.getDistribution();
|
return count.getDistribution();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int makeShape(final Region region, final Vector zero, final Vector unit, final Pattern pattern, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
public int makeShape(final Region region, final Vector3 zero, final Vector3 unit, final Pattern pattern, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
||||||
final Expression expression = Expression.compile(expressionString, "x", "y", "z", "type", "data");
|
final Expression expression = Expression.compile(expressionString, "x", "y", "z", "type", "data");
|
||||||
expression.optimize();
|
expression.optimize();
|
||||||
|
|
||||||
@ -1742,9 +1743,9 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
final ArbitraryShape shape = new ArbitraryShape(region) {
|
final ArbitraryShape shape = new ArbitraryShape(region) {
|
||||||
@Override
|
@Override
|
||||||
protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) {
|
protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) {
|
||||||
final Vector current = new Vector(x, y, z);
|
final Vector3 current = new Vector3(x, y, z);
|
||||||
environment.setCurrentBlock(current);
|
environment.setCurrentBlock(current);
|
||||||
final Vector scaled = current.subtract(zero).divide(unit);
|
final Vector3 scaled = current.subtract(zero).divide(unit);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ(), defaultMaterial.getBlockType().getLegacyId(), 0) <= 0) {
|
if (expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ(), defaultMaterial.getBlockType().getLegacyId(), 0) <= 0) {
|
||||||
@ -1763,7 +1764,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
return shape.generate(this, pattern, hollow);
|
return shape.generate(this, pattern, hollow);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deformRegion(final Region region, final Vector zero, final Vector unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException {
|
public int deformRegion(final Region region, final Vector3 zero, final Vector3 unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException {
|
||||||
final Expression expression = Expression.compile(expressionString, "x", "y", "z");
|
final Expression expression = Expression.compile(expressionString, "x", "y", "z");
|
||||||
expression.optimize();
|
expression.optimize();
|
||||||
|
|
||||||
@ -1774,16 +1775,16 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
||||||
expression.setEnvironment(environment);
|
expression.setEnvironment(environment);
|
||||||
|
|
||||||
final DoubleArrayList<BlockVector, BaseBlock> queue = new DoubleArrayList<>(false);
|
final DoubleArrayList<BlockVector3, BaseBlock> queue = new DoubleArrayList<>(false);
|
||||||
|
|
||||||
for (BlockVector position : region) {
|
for (BlockVector3 position : region) {
|
||||||
// offset, scale
|
// offset, scale
|
||||||
final Vector scaled = position.subtract(zero).divide(unit);
|
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
|
||||||
|
|
||||||
// transform
|
// transform
|
||||||
expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ());
|
expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ());
|
||||||
|
|
||||||
final BlockVector sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue());
|
final BlockVector3 sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue());
|
||||||
|
|
||||||
// read block from world
|
// read block from world
|
||||||
final BaseBlock material = world.getFullBlock(sourcePosition);
|
final BaseBlock material = world.getFullBlock(sourcePosition);
|
||||||
@ -1793,8 +1794,8 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
for (Map.Entry<BlockVector, BaseBlock> entry : queue) {
|
for (Map.Entry<BlockVector3, BaseBlock> entry : queue) {
|
||||||
BlockVector position = entry.getKey();
|
BlockVector3 position = entry.getKey();
|
||||||
BaseBlock material = entry.getValue();
|
BaseBlock material = entry.getValue();
|
||||||
|
|
||||||
// set at new position
|
// set at new position
|
||||||
@ -1819,10 +1820,10 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
|
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
final Set<BlockVector> outside = new HashSet<>();
|
final Set<BlockVector3> outside = new HashSet<>();
|
||||||
|
|
||||||
final Vector min = region.getMinimumPoint();
|
final BlockVector3 min = region.getMinimumPoint();
|
||||||
final Vector max = region.getMaximumPoint();
|
final BlockVector3 max = region.getMaximumPoint();
|
||||||
|
|
||||||
final int minX = min.getBlockX();
|
final int minX = min.getBlockX();
|
||||||
final int minY = min.getBlockY();
|
final int minY = min.getBlockY();
|
||||||
@ -1833,30 +1834,30 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
|
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
recurseHollow(region, new BlockVector(x, y, minZ), outside);
|
recurseHollow(region, new BlockVector3(x, y, minZ), outside);
|
||||||
recurseHollow(region, new BlockVector(x, y, maxZ), outside);
|
recurseHollow(region, new BlockVector3(x, y, maxZ), outside);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
recurseHollow(region, new BlockVector(minX, y, z), outside);
|
recurseHollow(region, new BlockVector3(minX, y, z), outside);
|
||||||
recurseHollow(region, new BlockVector(maxX, y, z), outside);
|
recurseHollow(region, new BlockVector3(maxX, y, z), outside);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
recurseHollow(region, new BlockVector(x, minY, z), outside);
|
recurseHollow(region, new BlockVector3(x, minY, z), outside);
|
||||||
recurseHollow(region, new BlockVector(x, maxY, z), outside);
|
recurseHollow(region, new BlockVector3(x, maxY, z), outside);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < thickness; ++i) {
|
for (int i = 1; i < thickness; ++i) {
|
||||||
final Set<BlockVector> newOutside = new HashSet<>();
|
final Set<BlockVector3> newOutside = new HashSet<>();
|
||||||
outer: for (BlockVector position : region) {
|
outer: for (BlockVector3 position : region) {
|
||||||
for (Vector recurseDirection: recurseDirections) {
|
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||||
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
BlockVector3 neighbor = position.add(recurseDirection);
|
||||||
|
|
||||||
if (outside.contains(neighbor)) {
|
if (outside.contains(neighbor)) {
|
||||||
newOutside.add(position);
|
newOutside.add(position);
|
||||||
@ -1868,9 +1869,9 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
outside.addAll(newOutside);
|
outside.addAll(newOutside);
|
||||||
}
|
}
|
||||||
|
|
||||||
outer: for (BlockVector position : region) {
|
outer: for (BlockVector3 position : region) {
|
||||||
for (Vector recurseDirection: recurseDirections) {
|
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||||
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
BlockVector3 neighbor = position.add(recurseDirection);
|
||||||
|
|
||||||
if (outside.contains(neighbor)) {
|
if (outside.contains(neighbor)) {
|
||||||
continue outer;
|
continue outer;
|
||||||
@ -1897,10 +1898,10 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int drawLine(Pattern pattern, Vector pos1, Vector pos2, double radius, boolean filled)
|
public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
|
|
||||||
Set<Vector> vset = new HashSet<>();
|
Set<BlockVector3> vset = new HashSet<>();
|
||||||
boolean notdrawn = true;
|
boolean notdrawn = true;
|
||||||
|
|
||||||
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
|
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
|
||||||
@ -1909,7 +1910,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1);
|
int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1);
|
||||||
|
|
||||||
if (dx + dy + dz == 0) {
|
if (dx + dy + dz == 0) {
|
||||||
vset.add(new Vector(tipx, tipy, tipz));
|
vset.add(new BlockVector3(tipx, tipy, tipz));
|
||||||
notdrawn = false;
|
notdrawn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1919,7 +1920,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1));
|
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1));
|
||||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1));
|
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1));
|
||||||
|
|
||||||
vset.add(new Vector(tipx, tipy, tipz));
|
vset.add(new BlockVector3(tipx, tipy, tipz));
|
||||||
}
|
}
|
||||||
notdrawn = false;
|
notdrawn = false;
|
||||||
}
|
}
|
||||||
@ -1930,7 +1931,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1));
|
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1));
|
||||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1));
|
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1));
|
||||||
|
|
||||||
vset.add(new Vector(tipx, tipy, tipz));
|
vset.add(new BlockVector3(tipx, tipy, tipz));
|
||||||
}
|
}
|
||||||
notdrawn = false;
|
notdrawn = false;
|
||||||
}
|
}
|
||||||
@ -1941,7 +1942,7 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1));
|
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1));
|
||||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1));
|
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1));
|
||||||
|
|
||||||
vset.add(new Vector(tipx, tipy, tipz));
|
vset.add(new BlockVector3(tipx, tipy, tipz));
|
||||||
}
|
}
|
||||||
notdrawn = false;
|
notdrawn = false;
|
||||||
}
|
}
|
||||||
@ -1968,16 +1969,16 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int drawSpline(Pattern pattern, List<Vector> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled)
|
public int drawSpline(Pattern pattern, List<BlockVector3> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
|
|
||||||
Set<Vector> vset = new HashSet<>();
|
Set<BlockVector3> vset = new HashSet<>();
|
||||||
List<Node> nodes = new ArrayList<>(nodevectors.size());
|
List<Node> nodes = new ArrayList<>(nodevectors.size());
|
||||||
|
|
||||||
Interpolation interpol = new KochanekBartelsInterpolation();
|
Interpolation interpol = new KochanekBartelsInterpolation();
|
||||||
|
|
||||||
for (Vector nodevector : nodevectors) {
|
for (BlockVector3 nodevector : nodevectors) {
|
||||||
Node n = new Node(nodevector);
|
Node n = new Node(nodevector.toVector3());
|
||||||
n.setTension(tension);
|
n.setTension(tension);
|
||||||
n.setBias(bias);
|
n.setBias(bias);
|
||||||
n.setContinuity(continuity);
|
n.setContinuity(continuity);
|
||||||
@ -1987,12 +1988,9 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
interpol.setNodes(nodes);
|
interpol.setNodes(nodes);
|
||||||
double splinelength = interpol.arcLength(0, 1);
|
double splinelength = interpol.arcLength(0, 1);
|
||||||
for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) {
|
for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) {
|
||||||
Vector tipv = interpol.getPosition(loop);
|
Vector3 tipv = interpol.getPosition(loop);
|
||||||
int tipx = (int) Math.round(tipv.getX());
|
|
||||||
int tipy = (int) Math.round(tipv.getY());
|
|
||||||
int tipz = (int) Math.round(tipv.getZ());
|
|
||||||
|
|
||||||
vset.add(new Vector(tipx, tipy, tipz));
|
vset.add(tipv.toBlockPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
vset = getBallooned(vset, radius);
|
vset = getBallooned(vset, radius);
|
||||||
@ -2010,18 +2008,18 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
return Math.sqrt(sum);
|
return Math.sqrt(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Vector> getBallooned(Set<Vector> vset, double radius) {
|
private static Set<BlockVector3> getBallooned(Set<BlockVector3> vset, double radius) {
|
||||||
Set<Vector> returnset = new HashSet<>();
|
Set<BlockVector3> returnset = new HashSet<>();
|
||||||
int ceilrad = (int) Math.ceil(radius);
|
int ceilrad = (int) Math.ceil(radius);
|
||||||
|
|
||||||
for (Vector v : vset) {
|
for (BlockVector3 v : vset) {
|
||||||
int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
||||||
|
|
||||||
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||||
for (int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) {
|
for (int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) {
|
||||||
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||||
if (hypot(loopx - tipx, loopy - tipy, loopz - tipz) <= radius) {
|
if (hypot(loopx - tipx, loopy - tipy, loopz - tipz) <= radius) {
|
||||||
returnset.add(new Vector(loopx, loopy, loopz));
|
returnset.add(new BlockVector3(loopx, loopy, loopz));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2030,28 +2028,28 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
return returnset;
|
return returnset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Vector> getHollowed(Set<Vector> vset) {
|
private static Set<BlockVector3> getHollowed(Set<BlockVector3> vset) {
|
||||||
Set<Vector> returnset = new HashSet<>();
|
Set<BlockVector3> returnset = new HashSet<>();
|
||||||
for (Vector v : vset) {
|
for (BlockVector3 v : vset) {
|
||||||
double x = v.getX(), y = v.getY(), z = v.getZ();
|
double x = v.getX(), y = v.getY(), z = v.getZ();
|
||||||
if (!(vset.contains(new Vector(x + 1, y, z)) &&
|
if (!(vset.contains(new BlockVector3(x + 1, y, z)) &&
|
||||||
vset.contains(new Vector(x - 1, y, z)) &&
|
vset.contains(new BlockVector3(x - 1, y, z)) &&
|
||||||
vset.contains(new Vector(x, y + 1, z)) &&
|
vset.contains(new BlockVector3(x, y + 1, z)) &&
|
||||||
vset.contains(new Vector(x, y - 1, z)) &&
|
vset.contains(new BlockVector3(x, y - 1, z)) &&
|
||||||
vset.contains(new Vector(x, y, z + 1)) &&
|
vset.contains(new BlockVector3(x, y, z + 1)) &&
|
||||||
vset.contains(new Vector(x, y, z - 1)))) {
|
vset.contains(new BlockVector3(x, y, z - 1)))) {
|
||||||
returnset.add(v);
|
returnset.add(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnset;
|
return returnset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recurseHollow(Region region, BlockVector origin, Set<BlockVector> outside) {
|
private void recurseHollow(Region region, BlockVector3 origin, Set<BlockVector3> outside) {
|
||||||
final LinkedList<BlockVector> queue = new LinkedList<>();
|
final LinkedList<BlockVector3> queue = new LinkedList<>();
|
||||||
queue.addLast(origin);
|
queue.addLast(origin);
|
||||||
|
|
||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
final BlockVector current = queue.removeFirst();
|
final BlockVector3 current = queue.removeFirst();
|
||||||
final BlockState block = getBlock(current);
|
final BlockState block = getBlock(current);
|
||||||
if (block.getBlockType().getMaterial().isMovementBlocker()) {
|
if (block.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
continue;
|
continue;
|
||||||
@ -2065,15 +2063,15 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Vector recurseDirection: recurseDirections) {
|
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||||
queue.addLast(current.add(recurseDirection).toBlockVector());
|
queue.addLast(current.add(recurseDirection));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // while
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int makeBiomeShape(final Region region, final Vector zero, final Vector unit, final BaseBiome biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BaseBiome biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
||||||
final Vector2D zero2D = zero.toVector2D();
|
final Vector2 zero2D = zero.toVector2();
|
||||||
final Vector2D unit2D = unit.toVector2D();
|
final Vector2 unit2D = unit.toVector2();
|
||||||
|
|
||||||
final Expression expression = Expression.compile(expressionString, "x", "z");
|
final Expression expression = Expression.compile(expressionString, "x", "z");
|
||||||
expression.optimize();
|
expression.optimize();
|
||||||
@ -2085,9 +2083,9 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) {
|
final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) {
|
||||||
@Override
|
@Override
|
||||||
protected BaseBiome getBiome(int x, int z, BaseBiome defaultBiomeType) {
|
protected BaseBiome getBiome(int x, int z, BaseBiome defaultBiomeType) {
|
||||||
final Vector2D current = new Vector2D(x, z);
|
final Vector2 current = new Vector2(x, z);
|
||||||
environment.setCurrentBlock(current.toVector(0));
|
environment.setCurrentBlock(current.toVector3(0));
|
||||||
final Vector2D scaled = current.subtract(zero2D).divide(unit2D);
|
final Vector2 scaled = current.subtract(zero2D).divide(unit2D);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (expression.evaluate(scaled.getX(), scaled.getZ()) <= 0) {
|
if (expression.evaluate(scaled.getX(), scaled.getZ()) <= 0) {
|
||||||
@ -2106,13 +2104,13 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
return shape.generate(this, biomeType, hollow);
|
return shape.generate(this, biomeType, hollow);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Vector[] recurseDirections = {
|
private static final BlockVector3[] recurseDirections = {
|
||||||
Direction.NORTH.toVector(),
|
Direction.NORTH.toBlockVector(),
|
||||||
Direction.EAST.toVector(),
|
Direction.EAST.toBlockVector(),
|
||||||
Direction.SOUTH.toVector(),
|
Direction.SOUTH.toBlockVector(),
|
||||||
Direction.WEST.toVector(),
|
Direction.WEST.toBlockVector(),
|
||||||
Direction.UP.toVector(),
|
Direction.UP.toBlockVector(),
|
||||||
Direction.DOWN.toVector(),
|
Direction.DOWN.toBlockVector(),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static double lengthSq(double x, double y, double z) {
|
private static double lengthSq(double x, double y, double z) {
|
||||||
|
@ -40,6 +40,7 @@ import com.sk89q.worldedit.internal.cui.CUIEvent;
|
|||||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||||
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
||||||
import com.sk89q.worldedit.internal.cui.ServerCUIHandler;
|
import com.sk89q.worldedit.internal.cui.ServerCUIHandler;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||||
@ -91,7 +92,7 @@ public class LocalSession {
|
|||||||
private transient boolean fastMode = false;
|
private transient boolean fastMode = false;
|
||||||
private transient Mask mask;
|
private transient Mask mask;
|
||||||
private transient TimeZone timezone = TimeZone.getDefault();
|
private transient TimeZone timezone = TimeZone.getDefault();
|
||||||
private transient Vector cuiTemporaryBlock;
|
private transient BlockVector3 cuiTemporaryBlock;
|
||||||
|
|
||||||
// Saved properties
|
// Saved properties
|
||||||
private String lastScript;
|
private String lastScript;
|
||||||
@ -450,10 +451,10 @@ public class LocalSession {
|
|||||||
* @return the position to use
|
* @return the position to use
|
||||||
* @throws IncompleteRegionException thrown if a region is not fully selected
|
* @throws IncompleteRegionException thrown if a region is not fully selected
|
||||||
*/
|
*/
|
||||||
public Vector getPlacementPosition(Player player) throws IncompleteRegionException {
|
public BlockVector3 getPlacementPosition(Player player) throws IncompleteRegionException {
|
||||||
checkNotNull(player);
|
checkNotNull(player);
|
||||||
if (!placeAtPos1) {
|
if (!placeAtPos1) {
|
||||||
return player.getBlockIn().toVector();
|
return player.getBlockIn().toVector().toBlockPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
return selector.getPrimaryPosition();
|
return selector.getPrimaryPosition();
|
||||||
@ -661,7 +662,7 @@ public class LocalSession {
|
|||||||
if (block != null) {
|
if (block != null) {
|
||||||
// If it's null, we don't need to do anything. The old was already removed.
|
// If it's null, we don't need to do anything. The old was already removed.
|
||||||
Map<String, Tag> tags = block.getNbtData().getValue();
|
Map<String, Tag> tags = block.getNbtData().getValue();
|
||||||
cuiTemporaryBlock = new Vector(
|
cuiTemporaryBlock = new BlockVector3(
|
||||||
((IntTag) tags.get("x")).getValue(),
|
((IntTag) tags.get("x")).getValue(),
|
||||||
((IntTag) tags.get("y")).getValue(),
|
((IntTag) tags.get("y")).getValue(),
|
||||||
((IntTag) tags.get("z")).getValue()
|
((IntTag) tags.get("z")).getValue()
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit;
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,26 +29,26 @@ import com.sk89q.worldedit.util.Direction;
|
|||||||
*/
|
*/
|
||||||
public enum PlayerDirection {
|
public enum PlayerDirection {
|
||||||
|
|
||||||
NORTH(new Vector(0, 0, -1), true),
|
NORTH(new Vector3(0, 0, -1), true),
|
||||||
NORTH_EAST((new Vector(1, 0, -1)).normalize(), false),
|
NORTH_EAST((new Vector3(1, 0, -1)).normalize(), false),
|
||||||
EAST(new Vector(1, 0, 0), true),
|
EAST(new Vector3(1, 0, 0), true),
|
||||||
SOUTH_EAST((new Vector(1, 0, 1)).normalize(), false),
|
SOUTH_EAST((new Vector3(1, 0, 1)).normalize(), false),
|
||||||
SOUTH(new Vector(0, 0, 1), true),
|
SOUTH(new Vector3(0, 0, 1), true),
|
||||||
SOUTH_WEST((new Vector(-1, 0, 1)).normalize(), false),
|
SOUTH_WEST((new Vector3(-1, 0, 1)).normalize(), false),
|
||||||
WEST(new Vector(-1, 0, 0), true),
|
WEST(new Vector3(-1, 0, 0), true),
|
||||||
NORTH_WEST((new Vector(-1, 0, -1)).normalize(), false),
|
NORTH_WEST((new Vector3(-1, 0, -1)).normalize(), false),
|
||||||
UP(new Vector(0, 1, 0), true),
|
UP(new Vector3(0, 1, 0), true),
|
||||||
DOWN(new Vector(0, -1, 0), true);
|
DOWN(new Vector3(0, -1, 0), true);
|
||||||
|
|
||||||
private final Vector dir;
|
private final Vector3 dir;
|
||||||
private final boolean isOrthogonal;
|
private final boolean isOrthogonal;
|
||||||
|
|
||||||
PlayerDirection(Vector vec, boolean isOrthogonal) {
|
PlayerDirection(Vector3 vec, boolean isOrthogonal) {
|
||||||
this.dir = vec;
|
this.dir = vec;
|
||||||
this.isOrthogonal = isOrthogonal;
|
this.isOrthogonal = isOrthogonal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector vector() {
|
public Vector3 vector() {
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,846 +0,0 @@
|
|||||||
/*
|
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
||||||
* Copyright (C) WorldEdit team and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sk89q.worldedit;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An immutable 3-dimensional vector.
|
|
||||||
*/
|
|
||||||
public class Vector implements Comparable<Vector> {
|
|
||||||
|
|
||||||
public static final Vector ZERO = new Vector(0, 0, 0);
|
|
||||||
public static final Vector UNIT_X = new Vector(1, 0, 0);
|
|
||||||
public static final Vector UNIT_Y = new Vector(0, 1, 0);
|
|
||||||
public static final Vector UNIT_Z = new Vector(0, 0, 1);
|
|
||||||
public static final Vector ONE = new Vector(1, 1, 1);
|
|
||||||
|
|
||||||
protected final double x, y, z;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public Vector(double x, double y, double z) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public Vector(int x, int y, int z) {
|
|
||||||
this.x = (double) x;
|
|
||||||
this.y = (double) y;
|
|
||||||
this.z = (double) z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public Vector(float x, float y, float z) {
|
|
||||||
this.x = (double) x;
|
|
||||||
this.y = (double) y;
|
|
||||||
this.z = (double) z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy another vector.
|
|
||||||
*
|
|
||||||
* @param other another vector to make a copy of
|
|
||||||
*/
|
|
||||||
public Vector(Vector other) {
|
|
||||||
this.x = other.x;
|
|
||||||
this.y = other.y;
|
|
||||||
this.z = other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new instance with X, Y, and Z coordinates set to 0.
|
|
||||||
*
|
|
||||||
* <p>One can also refer to a static {@link #ZERO}.</p>
|
|
||||||
*/
|
|
||||||
public Vector() {
|
|
||||||
this.x = 0;
|
|
||||||
this.y = 0;
|
|
||||||
this.z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the X coordinate.
|
|
||||||
*
|
|
||||||
* @return the x coordinate
|
|
||||||
*/
|
|
||||||
public double getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the X coordinate rounded.
|
|
||||||
*
|
|
||||||
* @return the x coordinate
|
|
||||||
*/
|
|
||||||
public int getBlockX() {
|
|
||||||
return (int) Math.round(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the X coordinate.
|
|
||||||
*
|
|
||||||
* @param x the new X
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector setX(double x) {
|
|
||||||
return new Vector(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the X coordinate.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @return new vector
|
|
||||||
*/
|
|
||||||
public Vector setX(int x) {
|
|
||||||
return new Vector(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Y coordinate.
|
|
||||||
*
|
|
||||||
* @return the y coordinate
|
|
||||||
*/
|
|
||||||
public double getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Y coordinate rounded.
|
|
||||||
*
|
|
||||||
* @return the y coordinate
|
|
||||||
*/
|
|
||||||
public int getBlockY() {
|
|
||||||
return (int) Math.round(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the Y coordinate.
|
|
||||||
*
|
|
||||||
* @param y the new Y
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector setY(double y) {
|
|
||||||
return new Vector(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the Y coordinate.
|
|
||||||
*
|
|
||||||
* @param y the new Y
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector setY(int y) {
|
|
||||||
return new Vector(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Z coordinate.
|
|
||||||
*
|
|
||||||
* @return the z coordinate
|
|
||||||
*/
|
|
||||||
public double getZ() {
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Z coordinate rounded.
|
|
||||||
*
|
|
||||||
* @return the z coordinate
|
|
||||||
*/
|
|
||||||
public int getBlockZ() {
|
|
||||||
return (int) Math.round(z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the Z coordinate.
|
|
||||||
*
|
|
||||||
* @param z the new Z
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector setZ(double z) {
|
|
||||||
return new Vector(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the Z coordinate.
|
|
||||||
*
|
|
||||||
* @param z the new Z
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector setZ(int z) {
|
|
||||||
return new Vector(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add another vector to this vector and return the result as a new vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector add(Vector other) {
|
|
||||||
return new Vector(x + other.x, y + other.y, z + other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add another vector to this vector and return the result as a new vector.
|
|
||||||
*
|
|
||||||
* @param x the value to add
|
|
||||||
* @param y the value to add
|
|
||||||
* @param z the value to add
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector add(double x, double y, double z) {
|
|
||||||
return new Vector(this.x + x, this.y + y, this.z + z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add another vector to this vector and return the result as a new vector.
|
|
||||||
*
|
|
||||||
* @param x the value to add
|
|
||||||
* @param y the value to add
|
|
||||||
* @param z the value to add
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector add(int x, int y, int z) {
|
|
||||||
return new Vector(this.x + x, this.y + y, this.z + z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a list of vectors to this vector and return the
|
|
||||||
* result as a new vector.
|
|
||||||
*
|
|
||||||
* @param others an array of vectors
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector add(Vector... others) {
|
|
||||||
double newX = x, newY = y, newZ = z;
|
|
||||||
|
|
||||||
for (Vector other : others) {
|
|
||||||
newX += other.x;
|
|
||||||
newY += other.y;
|
|
||||||
newZ += other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Vector(newX, newY, newZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract another vector from this vector and return the result
|
|
||||||
* as a new vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector subtract(Vector other) {
|
|
||||||
return new Vector(x - other.x, y - other.y, z - other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract another vector from this vector and return the result
|
|
||||||
* as a new vector.
|
|
||||||
*
|
|
||||||
* @param x the value to subtract
|
|
||||||
* @param y the value to subtract
|
|
||||||
* @param z the value to subtract
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector subtract(double x, double y, double z) {
|
|
||||||
return new Vector(this.x - x, this.y - y, this.z - z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract another vector from this vector and return the result
|
|
||||||
* as a new vector.
|
|
||||||
*
|
|
||||||
* @param x the value to subtract
|
|
||||||
* @param y the value to subtract
|
|
||||||
* @param z the value to subtract
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector subtract(int x, int y, int z) {
|
|
||||||
return new Vector(this.x - x, this.y - y, this.z - z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract a list of vectors from this vector and return the result
|
|
||||||
* as a new vector.
|
|
||||||
*
|
|
||||||
* @param others an array of vectors
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector subtract(Vector... others) {
|
|
||||||
double newX = x, newY = y, newZ = z;
|
|
||||||
|
|
||||||
for (Vector other : others) {
|
|
||||||
newX -= other.x;
|
|
||||||
newY -= other.y;
|
|
||||||
newZ -= other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Vector(newX, newY, newZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector multiply(Vector other) {
|
|
||||||
return new Vector(x * other.x, y * other.y, z * other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param x the value to multiply
|
|
||||||
* @param y the value to multiply
|
|
||||||
* @param z the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector multiply(double x, double y, double z) {
|
|
||||||
return new Vector(this.x * x, this.y * y, this.z * z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param x the value to multiply
|
|
||||||
* @param y the value to multiply
|
|
||||||
* @param z the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector multiply(int x, int y, int z) {
|
|
||||||
return new Vector(this.x * x, this.y * y, this.z * z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply this vector by zero or more vectors on each component.
|
|
||||||
*
|
|
||||||
* @param others an array of vectors
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector multiply(Vector... others) {
|
|
||||||
double newX = x, newY = y, newZ = z;
|
|
||||||
|
|
||||||
for (Vector other : others) {
|
|
||||||
newX *= other.x;
|
|
||||||
newY *= other.y;
|
|
||||||
newZ *= other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Vector(newX, newY, newZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar multiplication and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector multiply(double n) {
|
|
||||||
return new Vector(this.x * n, this.y * n, this.z * n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar multiplication and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector multiply(float n) {
|
|
||||||
return new Vector(this.x * n, this.y * n, this.z * n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar multiplication and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector multiply(int n) {
|
|
||||||
return new Vector(this.x * n, this.y * n, this.z * n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector divide(Vector other) {
|
|
||||||
return new Vector(x / other.x, y / other.y, z / other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param x the value to divide by
|
|
||||||
* @param y the value to divide by
|
|
||||||
* @param z the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector divide(double x, double y, double z) {
|
|
||||||
return new Vector(this.x / x, this.y / y, this.z / z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param x the value to divide by
|
|
||||||
* @param y the value to divide by
|
|
||||||
* @param z the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector divide(int x, int y, int z) {
|
|
||||||
return new Vector(this.x / x, this.y / y, this.z / z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar division and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector divide(int n) {
|
|
||||||
return new Vector(x / n, y / n, z / n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar division and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector divide(double n) {
|
|
||||||
return new Vector(x / n, y / n, z / n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar division and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector divide(float n) {
|
|
||||||
return new Vector(x / n, y / n, z / n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the length of the vector.
|
|
||||||
*
|
|
||||||
* @return length
|
|
||||||
*/
|
|
||||||
public double length() {
|
|
||||||
return Math.sqrt(x * x + y * y + z * z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the length, squared, of the vector.
|
|
||||||
*
|
|
||||||
* @return length, squared
|
|
||||||
*/
|
|
||||||
public double lengthSq() {
|
|
||||||
return x * x + y * y + z * z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the distance between this vector and another vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return distance
|
|
||||||
*/
|
|
||||||
public double distance(Vector other) {
|
|
||||||
return Math.sqrt(Math.pow(other.x - x, 2) +
|
|
||||||
Math.pow(other.y - y, 2) +
|
|
||||||
Math.pow(other.z - z, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the distance between this vector and another vector, squared.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return distance
|
|
||||||
*/
|
|
||||||
public double distanceSq(Vector other) {
|
|
||||||
return Math.pow(other.x - x, 2) +
|
|
||||||
Math.pow(other.y - y, 2) +
|
|
||||||
Math.pow(other.z - z, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the normalized vector, which is the vector divided by its
|
|
||||||
* length, as a new vector.
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector normalize() {
|
|
||||||
return divide(length());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the dot product of this and another vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return the dot product of this and the other vector
|
|
||||||
*/
|
|
||||||
public double dot(Vector other) {
|
|
||||||
return x * other.x + y * other.y + z * other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the cross product of this and another vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return the cross product of this and the other vector
|
|
||||||
*/
|
|
||||||
public Vector cross(Vector other) {
|
|
||||||
return new Vector(
|
|
||||||
y * other.z - z * other.y,
|
|
||||||
z * other.x - x * other.z,
|
|
||||||
x * other.y - y * other.x
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if a vector is contained with another.
|
|
||||||
*
|
|
||||||
* @param min the minimum point (X, Y, and Z are the lowest)
|
|
||||||
* @param max the maximum point (X, Y, and Z are the lowest)
|
|
||||||
* @return true if the vector is contained
|
|
||||||
*/
|
|
||||||
public boolean containedWithin(Vector min, Vector max) {
|
|
||||||
return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if a vector is contained with another, comparing
|
|
||||||
* using discrete comparisons, inclusively.
|
|
||||||
*
|
|
||||||
* @param min the minimum point (X, Y, and Z are the lowest)
|
|
||||||
* @param max the maximum point (X, Y, and Z are the lowest)
|
|
||||||
* @return true if the vector is contained
|
|
||||||
*/
|
|
||||||
public boolean containedWithinBlock(Vector min, Vector max) {
|
|
||||||
return getBlockX() >= min.getBlockX() && getBlockX() <= max.getBlockX()
|
|
||||||
&& getBlockY() >= min.getBlockY() && getBlockY() <= max.getBlockY()
|
|
||||||
&& getBlockZ() >= min.getBlockZ() && getBlockZ() <= max.getBlockZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clamp the Y component.
|
|
||||||
*
|
|
||||||
* @param min the minimum value
|
|
||||||
* @param max the maximum value
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector clampY(int min, int max) {
|
|
||||||
return new Vector(x, Math.max(min, Math.min(max, y)), z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Floors the values of all components.
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector floor() {
|
|
||||||
return new Vector(Math.floor(x), Math.floor(y), Math.floor(z));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rounds all components up.
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector ceil() {
|
|
||||||
return new Vector(Math.ceil(x), Math.ceil(y), Math.ceil(z));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rounds all components to the closest integer.
|
|
||||||
*
|
|
||||||
* <p>Components < 0.5 are rounded down, otherwise up.</p>
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector round() {
|
|
||||||
return new Vector(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 0.5));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a vector with the absolute values of the components of
|
|
||||||
* this vector.
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector positive() {
|
|
||||||
return new Vector(Math.abs(x), Math.abs(y), Math.abs(z));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform a 2D transformation on this vector and return a new one.
|
|
||||||
*
|
|
||||||
* @param angle in degrees
|
|
||||||
* @param aboutX about which x coordinate to rotate
|
|
||||||
* @param aboutZ about which z coordinate to rotate
|
|
||||||
* @param translateX what to add after rotation
|
|
||||||
* @param translateZ what to add after rotation
|
|
||||||
* @return a new vector
|
|
||||||
* @see AffineTransform another method to transform vectors
|
|
||||||
*/
|
|
||||||
public Vector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
|
||||||
angle = Math.toRadians(angle);
|
|
||||||
double x = this.x - aboutX;
|
|
||||||
double z = this.z - aboutZ;
|
|
||||||
double x2 = x * Math.cos(angle) - z * Math.sin(angle);
|
|
||||||
double z2 = x * Math.sin(angle) + z * Math.cos(angle);
|
|
||||||
|
|
||||||
return new Vector(
|
|
||||||
x2 + aboutX + translateX,
|
|
||||||
y,
|
|
||||||
z2 + aboutZ + translateZ
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this vector is collinear with another vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return true if collinear
|
|
||||||
*/
|
|
||||||
public boolean isCollinearWith(Vector other) {
|
|
||||||
if (x == 0 && y == 0 && z == 0) {
|
|
||||||
// this is a zero vector
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final double otherX = other.x;
|
|
||||||
final double otherY = other.y;
|
|
||||||
final double otherZ = other.z;
|
|
||||||
|
|
||||||
if (otherX == 0 && otherY == 0 && otherZ == 0) {
|
|
||||||
// other is a zero vector
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((x == 0) != (otherX == 0)) return false;
|
|
||||||
if ((y == 0) != (otherY == 0)) return false;
|
|
||||||
if ((z == 0) != (otherZ == 0)) return false;
|
|
||||||
|
|
||||||
final double quotientX = otherX / x;
|
|
||||||
if (!Double.isNaN(quotientX)) {
|
|
||||||
return other.equals(multiply(quotientX));
|
|
||||||
}
|
|
||||||
|
|
||||||
final double quotientY = otherY / y;
|
|
||||||
if (!Double.isNaN(quotientY)) {
|
|
||||||
return other.equals(multiply(quotientY));
|
|
||||||
}
|
|
||||||
|
|
||||||
final double quotientZ = otherZ / z;
|
|
||||||
if (!Double.isNaN(quotientZ)) {
|
|
||||||
return other.equals(multiply(quotientZ));
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new RuntimeException("This should not happen");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get this vector's pitch as used within the game.
|
|
||||||
*
|
|
||||||
* @return pitch in radians
|
|
||||||
*/
|
|
||||||
public float toPitch() {
|
|
||||||
double x = getX();
|
|
||||||
double z = getZ();
|
|
||||||
|
|
||||||
if (x == 0 && z == 0) {
|
|
||||||
return getY() > 0 ? -90 : 90;
|
|
||||||
} else {
|
|
||||||
double x2 = x * x;
|
|
||||||
double z2 = z * z;
|
|
||||||
double xz = Math.sqrt(x2 + z2);
|
|
||||||
return (float) Math.toDegrees(Math.atan(-getY() / xz));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get this vector's yaw as used within the game.
|
|
||||||
*
|
|
||||||
* @return yaw in radians
|
|
||||||
*/
|
|
||||||
public float toYaw() {
|
|
||||||
double x = getX();
|
|
||||||
double z = getZ();
|
|
||||||
|
|
||||||
double t = Math.atan2(-x, z);
|
|
||||||
double _2pi = 2 * Math.PI;
|
|
||||||
|
|
||||||
return (float) Math.toDegrees(((t + _2pi) % _2pi));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new {@code BlockVector} using the given components.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
* @return a new {@code BlockVector}
|
|
||||||
*/
|
|
||||||
public static BlockVector toBlockPoint(double x, double y, double z) {
|
|
||||||
return new BlockVector(
|
|
||||||
Math.floor(x),
|
|
||||||
Math.floor(y),
|
|
||||||
Math.floor(z)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new {@code BlockVector} from this vector.
|
|
||||||
*
|
|
||||||
* @return a new {@code BlockVector}
|
|
||||||
*/
|
|
||||||
public BlockVector toBlockPoint() {
|
|
||||||
return new BlockVector(
|
|
||||||
Math.floor(x),
|
|
||||||
Math.floor(y),
|
|
||||||
Math.floor(z)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new {@code BlockVector} from this vector.
|
|
||||||
*
|
|
||||||
* @return a new {@code BlockVector}
|
|
||||||
*/
|
|
||||||
public BlockVector toBlockVector() {
|
|
||||||
return toBlockPoint();
|
|
||||||
// return new BlockVector(this); TODO Look into this further.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a 2D vector by dropping the Y component from this vector.
|
|
||||||
*
|
|
||||||
* @return a new {@code Vector2D}
|
|
||||||
*/
|
|
||||||
public Vector2D toVector2D() {
|
|
||||||
return new Vector2D(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (!(obj instanceof Vector)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector other = (Vector) obj;
|
|
||||||
return other.x == this.x && other.y == this.y && other.z == this.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(@Nullable Vector other) {
|
|
||||||
if (other == null) {
|
|
||||||
throw new IllegalArgumentException("null not supported");
|
|
||||||
}
|
|
||||||
if (y != other.y) return Double.compare(y, other.y);
|
|
||||||
if (z != other.z) return Double.compare(z, other.z);
|
|
||||||
if (x != other.x) return Double.compare(x, other.x);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return ((int) x ^ ((int) z << 12)) ^ ((int) y << 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "(" + x + ", " + y + ", " + z + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the minimum components of two vectors.
|
|
||||||
*
|
|
||||||
* @param v1 the first vector
|
|
||||||
* @param v2 the second vector
|
|
||||||
* @return minimum
|
|
||||||
*/
|
|
||||||
public static Vector getMinimum(Vector v1, Vector v2) {
|
|
||||||
return new Vector(
|
|
||||||
Math.min(v1.x, v2.x),
|
|
||||||
Math.min(v1.y, v2.y),
|
|
||||||
Math.min(v1.z, v2.z)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the maximum components of two vectors.
|
|
||||||
*
|
|
||||||
* @param v1 the first vector
|
|
||||||
* @param v2 the second vector
|
|
||||||
* @return maximum
|
|
||||||
*/
|
|
||||||
public static Vector getMaximum(Vector v1, Vector v2) {
|
|
||||||
return new Vector(
|
|
||||||
Math.max(v1.x, v2.x),
|
|
||||||
Math.max(v1.y, v2.y),
|
|
||||||
Math.max(v1.z, v2.z)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the midpoint of two vectors.
|
|
||||||
*
|
|
||||||
* @param v1 the first vector
|
|
||||||
* @param v2 the second vector
|
|
||||||
* @return maximum
|
|
||||||
*/
|
|
||||||
public static Vector getMidpoint(Vector v1, Vector v2) {
|
|
||||||
return new Vector(
|
|
||||||
(v1.x + v2.x) / 2,
|
|
||||||
(v1.y + v2.y) / 2,
|
|
||||||
(v1.z + v2.z) / 2
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,691 +0,0 @@
|
|||||||
/*
|
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
||||||
* Copyright (C) WorldEdit team and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sk89q.worldedit;
|
|
||||||
|
|
||||||
import com.google.common.collect.ComparisonChain;
|
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An immutable 2-dimensional vector.
|
|
||||||
*/
|
|
||||||
public class Vector2D {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A comparator for Vector2Ds that orders the vectors by rows, with x as the
|
|
||||||
* column and z as the row.
|
|
||||||
*
|
|
||||||
* For example, if x is the horizontal axis and z is the vertical axis, it
|
|
||||||
* sorts like so:
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0123
|
|
||||||
* 4567
|
|
||||||
* 90ab
|
|
||||||
* cdef
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public static final Comparator<Vector2D> COMPARING_GRID_ARRANGEMENT = (a, b) -> {
|
|
||||||
return ComparisonChain.start()
|
|
||||||
.compare(a.getBlockZ(), b.getBlockZ())
|
|
||||||
.compare(a.getBlockX(), b.getBlockX())
|
|
||||||
.result();
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final Vector2D ZERO = new Vector2D(0, 0);
|
|
||||||
public static final Vector2D UNIT_X = new Vector2D(1, 0);
|
|
||||||
public static final Vector2D UNIT_Z = new Vector2D(0, 1);
|
|
||||||
public static final Vector2D ONE = new Vector2D(1, 1);
|
|
||||||
|
|
||||||
protected final double x, z;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public Vector2D(double x, double z) {
|
|
||||||
this.x = x;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public Vector2D(int x, int z) {
|
|
||||||
this.x = (double) x;
|
|
||||||
this.z = (double) z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
public Vector2D(float x, float z) {
|
|
||||||
this.x = (double) x;
|
|
||||||
this.z = (double) z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy another vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
*/
|
|
||||||
public Vector2D(Vector2D other) {
|
|
||||||
this.x = other.x;
|
|
||||||
this.z = other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new instance with X and Z coordinates set to 0.
|
|
||||||
*
|
|
||||||
* <p>One can also refer to a static {@link #ZERO}.</p>
|
|
||||||
*/
|
|
||||||
public Vector2D() {
|
|
||||||
this.x = 0;
|
|
||||||
this.z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the X coordinate.
|
|
||||||
*
|
|
||||||
* @return the x coordinate
|
|
||||||
*/
|
|
||||||
public double getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the X coordinate rounded.
|
|
||||||
*
|
|
||||||
* @return the x coordinate
|
|
||||||
*/
|
|
||||||
public int getBlockX() {
|
|
||||||
return (int) Math.round(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the X coordinate.
|
|
||||||
*
|
|
||||||
* @param x the new X
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D setX(double x) {
|
|
||||||
return new Vector2D(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the X coordinate.
|
|
||||||
*
|
|
||||||
* @param x the new X
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D setX(int x) {
|
|
||||||
return new Vector2D(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Z coordinate.
|
|
||||||
*
|
|
||||||
* @return the z coordinate
|
|
||||||
*/
|
|
||||||
public double getZ() {
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Z coordinate rounded.
|
|
||||||
*
|
|
||||||
* @return the z coordinate
|
|
||||||
*/
|
|
||||||
public int getBlockZ() {
|
|
||||||
return (int) Math.round(z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the Z coordinate.
|
|
||||||
*
|
|
||||||
* @param z the new Z
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D setZ(double z) {
|
|
||||||
return new Vector2D(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the Z coordinate.
|
|
||||||
*
|
|
||||||
* @param z the new Z
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D setZ(int z) {
|
|
||||||
return new Vector2D(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add another vector to this vector and return the result as a new vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D add(Vector2D other) {
|
|
||||||
return new Vector2D(x + other.x, z + other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add another vector to this vector and return the result as a new vector.
|
|
||||||
*
|
|
||||||
* @param x the value to add
|
|
||||||
* @param z the value to add
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D add(double x, double z) {
|
|
||||||
return new Vector2D(this.x + x, this.z + z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add another vector to this vector and return the result as a new vector.
|
|
||||||
*
|
|
||||||
* @param x the value to add
|
|
||||||
* @param z the value to add
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D add(int x, int z) {
|
|
||||||
return new Vector2D(this.x + x, this.z + z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a list of vectors to this vector and return the
|
|
||||||
* result as a new vector.
|
|
||||||
*
|
|
||||||
* @param others an array of vectors
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D add(Vector2D... others) {
|
|
||||||
double newX = x, newZ = z;
|
|
||||||
|
|
||||||
for (Vector2D other : others) {
|
|
||||||
newX += other.x;
|
|
||||||
newZ += other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Vector2D(newX, newZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract another vector from this vector and return the result
|
|
||||||
* as a new vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D subtract(Vector2D other) {
|
|
||||||
return new Vector2D(x - other.x, z - other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract another vector from this vector and return the result
|
|
||||||
* as a new vector.
|
|
||||||
*
|
|
||||||
* @param x the value to subtract
|
|
||||||
* @param z the value to subtract
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D subtract(double x, double z) {
|
|
||||||
return new Vector2D(this.x - x, this.z - z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract another vector from this vector and return the result
|
|
||||||
* as a new vector.
|
|
||||||
*
|
|
||||||
* @param x the value to subtract
|
|
||||||
* @param z the value to subtract
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D subtract(int x, int z) {
|
|
||||||
return new Vector2D(this.x - x, this.z - z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract a list of vectors from this vector and return the result
|
|
||||||
* as a new vector.
|
|
||||||
*
|
|
||||||
* @param others an array of vectors
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D subtract(Vector2D... others) {
|
|
||||||
double newX = x, newZ = z;
|
|
||||||
|
|
||||||
for (Vector2D other : others) {
|
|
||||||
newX -= other.x;
|
|
||||||
newZ -= other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Vector2D(newX, newZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D multiply(Vector2D other) {
|
|
||||||
return new Vector2D(x * other.x, z * other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param x the value to multiply
|
|
||||||
* @param z the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D multiply(double x, double z) {
|
|
||||||
return new Vector2D(this.x * x, this.z * z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param x the value to multiply
|
|
||||||
* @param z the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D multiply(int x, int z) {
|
|
||||||
return new Vector2D(this.x * x, this.z * z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply this vector by zero or more vectors on each component.
|
|
||||||
*
|
|
||||||
* @param others an array of vectors
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D multiply(Vector2D... others) {
|
|
||||||
double newX = x, newZ = z;
|
|
||||||
|
|
||||||
for (Vector2D other : others) {
|
|
||||||
newX *= other.x;
|
|
||||||
newZ *= other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Vector2D(newX, newZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar multiplication and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D multiply(double n) {
|
|
||||||
return new Vector2D(this.x * n, this.z * n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar multiplication and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D multiply(float n) {
|
|
||||||
return new Vector2D(this.x * n, this.z * n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar multiplication and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to multiply
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D multiply(int n) {
|
|
||||||
return new Vector2D(this.x * n, this.z * n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D divide(Vector2D other) {
|
|
||||||
return new Vector2D(x / other.x, z / other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param x the value to divide by
|
|
||||||
* @param z the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D divide(double x, double z) {
|
|
||||||
return new Vector2D(this.x / x, this.z / z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide this vector by another vector on each component.
|
|
||||||
*
|
|
||||||
* @param x the value to divide by
|
|
||||||
* @param z the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D divide(int x, int z) {
|
|
||||||
return new Vector2D(this.x / x, this.z / z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar division and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D divide(int n) {
|
|
||||||
return new Vector2D(x / n, z / n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar division and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D divide(double n) {
|
|
||||||
return new Vector2D(x / n, z / n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform scalar division and return a new vector.
|
|
||||||
*
|
|
||||||
* @param n the value to divide by
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D divide(float n) {
|
|
||||||
return new Vector2D(x / n, z / n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the length of the vector.
|
|
||||||
*
|
|
||||||
* @return length
|
|
||||||
*/
|
|
||||||
public double length() {
|
|
||||||
return Math.sqrt(x * x + z * z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the length, squared, of the vector.
|
|
||||||
*
|
|
||||||
* @return length, squared
|
|
||||||
*/
|
|
||||||
public double lengthSq() {
|
|
||||||
return x * x + z * z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the distance between this vector and another vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return distance
|
|
||||||
*/
|
|
||||||
public double distance(Vector2D other) {
|
|
||||||
return Math.sqrt(Math.pow(other.x - x, 2) + Math.pow(other.z - z, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the distance between this vector and another vector, squared.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return distance
|
|
||||||
*/
|
|
||||||
public double distanceSq(Vector2D other) {
|
|
||||||
return Math.pow(other.x - x, 2) +
|
|
||||||
Math.pow(other.z - z, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the normalized vector, which is the vector divided by its
|
|
||||||
* length, as a new vector.
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D normalize() {
|
|
||||||
return divide(length());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the dot product of this and another vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return the dot product of this and the other vector
|
|
||||||
*/
|
|
||||||
public double dot(Vector2D other) {
|
|
||||||
return x * other.x + z * other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if a vector is contained with another.
|
|
||||||
*
|
|
||||||
* @param min the minimum point (X, Y, and Z are the lowest)
|
|
||||||
* @param max the maximum point (X, Y, and Z are the lowest)
|
|
||||||
* @return true if the vector is contained
|
|
||||||
*/
|
|
||||||
public boolean containedWithin(Vector2D min, Vector2D max) {
|
|
||||||
return x >= min.x && x <= max.x
|
|
||||||
&& z >= min.z && z <= max.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if a vector is contained with another.
|
|
||||||
*
|
|
||||||
* @param min the minimum point (X, Y, and Z are the lowest)
|
|
||||||
* @param max the maximum point (X, Y, and Z are the lowest)
|
|
||||||
* @return true if the vector is contained
|
|
||||||
*/
|
|
||||||
public boolean containedWithinBlock(Vector2D min, Vector2D max) {
|
|
||||||
return getBlockX() >= min.getBlockX() && getBlockX() <= max.getBlockX()
|
|
||||||
&& getBlockZ() >= min.getBlockZ() && getBlockZ() <= max.getBlockZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Floors the values of all components.
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D floor() {
|
|
||||||
return new Vector2D(Math.floor(x), Math.floor(z));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rounds all components up.
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D ceil() {
|
|
||||||
return new Vector2D(Math.ceil(x), Math.ceil(z));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rounds all components to the closest integer.
|
|
||||||
*
|
|
||||||
* <p>Components < 0.5 are rounded down, otherwise up.</p>
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D round() {
|
|
||||||
return new Vector2D(Math.floor(x + 0.5), Math.floor(z + 0.5));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a vector with the absolute values of the components of
|
|
||||||
* this vector.
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector2D positive() {
|
|
||||||
return new Vector2D(Math.abs(x), Math.abs(z));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform a 2D transformation on this vector and return a new one.
|
|
||||||
*
|
|
||||||
* @param angle in degrees
|
|
||||||
* @param aboutX about which x coordinate to rotate
|
|
||||||
* @param aboutZ about which z coordinate to rotate
|
|
||||||
* @param translateX what to add after rotation
|
|
||||||
* @param translateZ what to add after rotation
|
|
||||||
* @return a new vector
|
|
||||||
* @see AffineTransform another method to transform vectors
|
|
||||||
*/
|
|
||||||
public Vector2D transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
|
||||||
angle = Math.toRadians(angle);
|
|
||||||
double x = this.x - aboutX;
|
|
||||||
double z = this.z - aboutZ;
|
|
||||||
double x2 = x * Math.cos(angle) - z * Math.sin(angle);
|
|
||||||
double z2 = x * Math.sin(angle) + z * Math.cos(angle);
|
|
||||||
return new Vector2D(
|
|
||||||
x2 + aboutX + translateX,
|
|
||||||
z2 + aboutZ + translateZ
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this vector is collinear with another vector.
|
|
||||||
*
|
|
||||||
* @param other the other vector
|
|
||||||
* @return true if collinear
|
|
||||||
*/
|
|
||||||
public boolean isCollinearWith(Vector2D other) {
|
|
||||||
if (x == 0 && z == 0) {
|
|
||||||
// this is a zero vector
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final double otherX = other.x;
|
|
||||||
final double otherZ = other.z;
|
|
||||||
|
|
||||||
if (otherX == 0 && otherZ == 0) {
|
|
||||||
// other is a zero vector
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((x == 0) != (otherX == 0)) return false;
|
|
||||||
if ((z == 0) != (otherZ == 0)) return false;
|
|
||||||
|
|
||||||
final double quotientX = otherX / x;
|
|
||||||
if (!Double.isNaN(quotientX)) {
|
|
||||||
return other.equals(multiply(quotientX));
|
|
||||||
}
|
|
||||||
|
|
||||||
final double quotientZ = otherZ / z;
|
|
||||||
if (!Double.isNaN(quotientZ)) {
|
|
||||||
return other.equals(multiply(quotientZ));
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new RuntimeException("This should not happen");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new {@code BlockVector2D} from this vector.
|
|
||||||
*
|
|
||||||
* @return a new {@code BlockVector2D}
|
|
||||||
*/
|
|
||||||
public BlockVector2D toBlockVector2D() {
|
|
||||||
return new BlockVector2D(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a 3D vector by adding a zero Y component to this vector.
|
|
||||||
*
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector toVector() {
|
|
||||||
return new Vector(x, 0, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a 3D vector by adding the specified Y component to this vector.
|
|
||||||
*
|
|
||||||
* @param y the Y component
|
|
||||||
* @return a new vector
|
|
||||||
*/
|
|
||||||
public Vector toVector(double y) {
|
|
||||||
return new Vector(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (!(obj instanceof Vector2D)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D other = (Vector2D) obj;
|
|
||||||
return other.x == this.x && other.z == this.z;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return ((int) x << 16) ^ (int) z;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "(" + x + ", " + z + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the minimum components of two vectors.
|
|
||||||
*
|
|
||||||
* @param v1 the first vector
|
|
||||||
* @param v2 the second vector
|
|
||||||
* @return minimum
|
|
||||||
*/
|
|
||||||
public static Vector2D getMinimum(Vector2D v1, Vector2D v2) {
|
|
||||||
return new Vector2D(
|
|
||||||
Math.min(v1.x, v2.x),
|
|
||||||
Math.min(v1.z, v2.z)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the maximum components of two vectors.
|
|
||||||
*
|
|
||||||
* @param v1 the first vector
|
|
||||||
* @param v2 the second vector
|
|
||||||
* @return maximum
|
|
||||||
*/
|
|
||||||
public static Vector2D getMaximum(Vector2D v1, Vector2D v2) {
|
|
||||||
return new Vector2D(
|
|
||||||
Math.max(v1.x, v2.x),
|
|
||||||
Math.max(v1.z, v2.z)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -40,6 +40,7 @@ import com.sk89q.worldedit.extension.platform.PlatformManager;
|
|||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.scripting.CraftScriptContext;
|
import com.sk89q.worldedit.scripting.CraftScriptContext;
|
||||||
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
||||||
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
||||||
@ -370,7 +371,7 @@ public class WorldEdit {
|
|||||||
* @return a direction vector
|
* @return a direction vector
|
||||||
* @throws UnknownDirectionException thrown if the direction is not known
|
* @throws UnknownDirectionException thrown if the direction is not known
|
||||||
*/
|
*/
|
||||||
public Vector getDirection(Player player, String dirStr) throws UnknownDirectionException {
|
public BlockVector3 getDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||||
dirStr = dirStr.toLowerCase();
|
dirStr = dirStr.toLowerCase();
|
||||||
|
|
||||||
final PlayerDirection dir = getPlayerDirection(player, dirStr);
|
final PlayerDirection dir = getPlayerDirection(player, dirStr);
|
||||||
@ -382,7 +383,7 @@ public class WorldEdit {
|
|||||||
case NORTH:
|
case NORTH:
|
||||||
case UP:
|
case UP:
|
||||||
case DOWN:
|
case DOWN:
|
||||||
return dir.vector();
|
return dir.vector().toBlockPoint();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new UnknownDirectionException(dir.name());
|
throw new UnknownDirectionException(dir.name());
|
||||||
|
@ -28,8 +28,6 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
@ -41,6 +39,8 @@ import com.sk89q.worldedit.function.mask.Mask;
|
|||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.FlatRegion;
|
import com.sk89q.worldedit.regions.FlatRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
@ -139,12 +139,12 @@ public class BiomeCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toVector2D());
|
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
|
||||||
biomes.add(biome);
|
biomes.add(biome);
|
||||||
|
|
||||||
qualifier = "at line of sight point";
|
qualifier = "at line of sight point";
|
||||||
} else if (args.hasFlag('p')) {
|
} else if (args.hasFlag('p')) {
|
||||||
BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toVector2D());
|
BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2());
|
||||||
biomes.add(biome);
|
biomes.add(biome);
|
||||||
|
|
||||||
qualifier = "at your position";
|
qualifier = "at your position";
|
||||||
@ -153,12 +153,12 @@ public class BiomeCommands {
|
|||||||
Region region = session.getSelection(world);
|
Region region = session.getSelection(world);
|
||||||
|
|
||||||
if (region instanceof FlatRegion) {
|
if (region instanceof FlatRegion) {
|
||||||
for (Vector2D pt : ((FlatRegion) region).asFlatRegion()) {
|
for (BlockVector2 pt : ((FlatRegion) region).asFlatRegion()) {
|
||||||
biomes.add(world.getBiome(pt));
|
biomes.add(world.getBiome(pt));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Vector pt : region) {
|
for (BlockVector3 pt : region) {
|
||||||
biomes.add(world.getBiome(pt.toVector2D()));
|
biomes.add(world.getBiome(pt.toBlockVector2()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ public class BiomeCommands {
|
|||||||
Mask2D mask2d = mask != null ? mask.toMask2D() : null;
|
Mask2D mask2d = mask != null ? mask.toMask2D() : null;
|
||||||
|
|
||||||
if (atPosition) {
|
if (atPosition) {
|
||||||
region = new CuboidRegion(player.getLocation().toVector(), player.getLocation().toVector());
|
region = new CuboidRegion(player.getLocation().toVector().toBlockPoint(), player.getLocation().toVector().toBlockPoint());
|
||||||
} else {
|
} else {
|
||||||
region = session.getSelection(world);
|
region = session.getSelection(world);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||||
@ -45,6 +44,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||||
@ -143,7 +143,7 @@ public class BrushCommands {
|
|||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
|
|
||||||
Vector size = clipboard.getDimensions();
|
BlockVector3 size = clipboard.getDimensions();
|
||||||
|
|
||||||
worldEdit.checkMaxBrushRadius(size.getBlockX());
|
worldEdit.checkMaxBrushRadius(size.getBlockX());
|
||||||
worldEdit.checkMaxBrushRadius(size.getBlockY());
|
worldEdit.checkMaxBrushRadius(size.getBlockY());
|
||||||
|
@ -29,10 +29,10 @@ import com.sk89q.minecraft.util.commands.Logging;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.MathUtils;
|
import com.sk89q.worldedit.math.MathUtils;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.storage.LegacyChunkStore;
|
import com.sk89q.worldedit.world.storage.LegacyChunkStore;
|
||||||
@ -76,7 +76,7 @@ public class ChunkCommands {
|
|||||||
player.print("Chunk: " + chunkX + ", " + chunkZ);
|
player.print("Chunk: " + chunkX + ", " + chunkZ);
|
||||||
player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename);
|
player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename);
|
||||||
player.print("McRegion: region/" + McRegionChunkStore.getFilename(
|
player.print("McRegion: region/" + McRegionChunkStore.getFilename(
|
||||||
new Vector2D(chunkX, chunkZ)));
|
new BlockVector2(chunkX, chunkZ)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -88,9 +88,9 @@ public class ChunkCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.listchunks")
|
@CommandPermissions("worldedit.listchunks")
|
||||||
public void listChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void listChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||||
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||||
|
|
||||||
for (Vector2D chunk : chunks) {
|
for (BlockVector2 chunk : chunks) {
|
||||||
player.print(LegacyChunkStore.getFilename(chunk));
|
player.print(LegacyChunkStore.getFilename(chunk));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ public class ChunkCommands {
|
|||||||
player.print("Note that this command does not yet support the mcregion format.");
|
player.print("Note that this command does not yet support the mcregion format.");
|
||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
|
|
||||||
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||||
FileOutputStream out = null;
|
FileOutputStream out = null;
|
||||||
|
|
||||||
if (config.shellSaveType == null) {
|
if (config.shellSaveType == null) {
|
||||||
@ -125,7 +125,7 @@ public class ChunkCommands {
|
|||||||
writer.write("ECHO.\r\n");
|
writer.write("ECHO.\r\n");
|
||||||
writer.write("PAUSE\r\n");
|
writer.write("PAUSE\r\n");
|
||||||
|
|
||||||
for (Vector2D chunk : chunks) {
|
for (BlockVector2 chunk : chunks) {
|
||||||
String filename = LegacyChunkStore.getFilename(chunk);
|
String filename = LegacyChunkStore.getFilename(chunk);
|
||||||
writer.write("ECHO " + filename + "\r\n");
|
writer.write("ECHO " + filename + "\r\n");
|
||||||
writer.write("DEL \"world/" + filename + "\"\r\n");
|
writer.write("DEL \"world/" + filename + "\"\r\n");
|
||||||
@ -156,7 +156,7 @@ public class ChunkCommands {
|
|||||||
writer.write("echo\n");
|
writer.write("echo\n");
|
||||||
writer.write("read -p \"Press any key to continue...\"\n");
|
writer.write("read -p \"Press any key to continue...\"\n");
|
||||||
|
|
||||||
for (Vector2D chunk : chunks) {
|
for (BlockVector2 chunk : chunks) {
|
||||||
String filename = LegacyChunkStore.getFilename(chunk);
|
String filename = LegacyChunkStore.getFilename(chunk);
|
||||||
writer.write("echo " + filename + "\n");
|
writer.write("echo " + filename + "\n");
|
||||||
writer.write("rm \"world/" + filename + "\"\n");
|
writer.write("rm \"world/" + filename + "\"\n");
|
||||||
|
@ -28,7 +28,6 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
@ -42,6 +41,8 @@ import com.sk89q.worldedit.function.operation.Operations;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
@ -154,7 +155,7 @@ public class ClipboardCommands {
|
|||||||
Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
Region region = clipboard.getRegion();
|
Region region = clipboard.getRegion();
|
||||||
|
|
||||||
Vector to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
|
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
|
||||||
Operation operation = holder
|
Operation operation = holder
|
||||||
.createPaste(editSession)
|
.createPaste(editSession)
|
||||||
.to(to)
|
.to(to)
|
||||||
@ -163,10 +164,10 @@ public class ClipboardCommands {
|
|||||||
Operations.completeLegacy(operation);
|
Operations.completeLegacy(operation);
|
||||||
|
|
||||||
if (selectPasted) {
|
if (selectPasted) {
|
||||||
Vector clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||||
Vector realTo = to.add(holder.getTransform().apply(clipboardOffset));
|
Vector3 realTo = to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3()));
|
||||||
Vector max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint())));
|
Vector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()));
|
||||||
RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo, max);
|
RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo.toBlockPoint(), max.toBlockPoint());
|
||||||
session.setRegionSelector(player.getWorld(), selector);
|
session.setRegionSelector(player.getWorld(), selector);
|
||||||
selector.learnChanges();
|
selector.learnChanges();
|
||||||
selector.explainRegionAdjust(player, session);
|
selector.explainRegionAdjust(player, session);
|
||||||
@ -211,11 +212,10 @@ public class ClipboardCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.flip")
|
@CommandPermissions("worldedit.clipboard.flip")
|
||||||
public void flip(Player player, LocalSession session, EditSession editSession,
|
public void flip(Player player, LocalSession session, EditSession editSession,
|
||||||
@Optional(Direction.AIM) @Direction Vector direction) throws WorldEditException {
|
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
Clipboard clipboard = holder.getClipboard();
|
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
transform = transform.scale(direction.positive().multiply(-2).add(1, 1, 1));
|
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
|
||||||
holder.setTransform(holder.getTransform().combine(transform));
|
holder.setTransform(holder.getTransform().combine(transform));
|
||||||
player.print("The clipboard copy has been flipped.");
|
player.print("The clipboard copy has been flipped.");
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.command;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.math.transform.CombinedTransform;
|
import com.sk89q.worldedit.math.transform.CombinedTransform;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
@ -66,8 +66,8 @@ class FlattenedClipboardTransform {
|
|||||||
*/
|
*/
|
||||||
public Region getTransformedRegion() {
|
public Region getTransformedRegion() {
|
||||||
Region region = original.getRegion();
|
Region region = original.getRegion();
|
||||||
Vector minimum = region.getMinimumPoint();
|
Vector3 minimum = region.getMinimumPoint().toVector3();
|
||||||
Vector maximum = region.getMaximumPoint();
|
Vector3 maximum = region.getMaximumPoint().toVector3();
|
||||||
|
|
||||||
Transform transformAround =
|
Transform transformAround =
|
||||||
new CombinedTransform(
|
new CombinedTransform(
|
||||||
@ -75,39 +75,34 @@ class FlattenedClipboardTransform {
|
|||||||
transform,
|
transform,
|
||||||
new AffineTransform().translate(original.getOrigin()));
|
new AffineTransform().translate(original.getOrigin()));
|
||||||
|
|
||||||
Vector[] corners = new Vector[] {
|
Vector3[] corners = new Vector3[] {
|
||||||
minimum,
|
minimum,
|
||||||
maximum,
|
maximum,
|
||||||
minimum.setX(maximum.getX()),
|
minimum.withX(maximum.getX()),
|
||||||
minimum.setY(maximum.getY()),
|
minimum.withY(maximum.getY()),
|
||||||
minimum.setZ(maximum.getZ()),
|
minimum.withZ(maximum.getZ()),
|
||||||
maximum.setX(minimum.getX()),
|
maximum.withX(minimum.getX()),
|
||||||
maximum.setY(minimum.getY()),
|
maximum.withY(minimum.getY()),
|
||||||
maximum.setZ(minimum.getZ()) };
|
maximum.withZ(minimum.getZ()) };
|
||||||
|
|
||||||
for (int i = 0; i < corners.length; i++) {
|
for (int i = 0; i < corners.length; i++) {
|
||||||
corners[i] = transformAround.apply(corners[i]);
|
corners[i] = transformAround.apply(corners[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector newMinimum = corners[0];
|
Vector3 newMinimum = corners[0];
|
||||||
Vector newMaximum = corners[0];
|
Vector3 newMaximum = corners[0];
|
||||||
|
|
||||||
for (int i = 1; i < corners.length; i++) {
|
for (int i = 1; i < corners.length; i++) {
|
||||||
newMinimum = Vector.getMinimum(newMinimum, corners[i]);
|
newMinimum = newMinimum.getMinimum(corners[i]);
|
||||||
newMaximum = Vector.getMaximum(newMaximum, corners[i]);
|
newMaximum = newMaximum.getMaximum(corners[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// After transformation, the points may not really sit on a block,
|
// After transformation, the points may not really sit on a block,
|
||||||
// so we should expand the region for edge cases
|
// so we should expand the region for edge cases
|
||||||
newMinimum = newMinimum.setX(Math.floor(newMinimum.getX()));
|
newMinimum = newMinimum.floor();
|
||||||
newMinimum = newMinimum.setY(Math.floor(newMinimum.getY()));
|
newMaximum = newMaximum.ceil();
|
||||||
newMinimum = newMinimum.setZ(Math.floor(newMinimum.getZ()));
|
|
||||||
|
|
||||||
newMaximum = newMaximum.setX(Math.ceil(newMaximum.getX()));
|
return new CuboidRegion(newMinimum.toBlockPoint(), newMaximum.toBlockPoint());
|
||||||
newMaximum = newMaximum.setY(Math.ceil(newMaximum.getY()));
|
|
||||||
newMaximum = newMaximum.setZ(Math.ceil(newMaximum.getZ()));
|
|
||||||
|
|
||||||
return new CuboidRegion(newMinimum, newMaximum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,13 +29,14 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||||
import com.sk89q.worldedit.util.command.binding.Range;
|
import com.sk89q.worldedit.util.command.binding.Range;
|
||||||
@ -116,7 +117,7 @@ public class GenerationCommands {
|
|||||||
worldEdit.checkMaxRadius(radiusZ);
|
worldEdit.checkMaxRadius(radiusZ);
|
||||||
worldEdit.checkMaxRadius(height);
|
worldEdit.checkMaxRadius(height);
|
||||||
|
|
||||||
Vector pos = session.getPlacementPosition(player);
|
BlockVector3 pos = session.getPlacementPosition(player);
|
||||||
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
|
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
|
||||||
player.print(affected + " block(s) have been created.");
|
player.print(affected + " block(s) have been created.");
|
||||||
}
|
}
|
||||||
@ -177,9 +178,9 @@ public class GenerationCommands {
|
|||||||
worldEdit.checkMaxRadius(radiusY);
|
worldEdit.checkMaxRadius(radiusY);
|
||||||
worldEdit.checkMaxRadius(radiusZ);
|
worldEdit.checkMaxRadius(radiusZ);
|
||||||
|
|
||||||
Vector pos = session.getPlacementPosition(player);
|
BlockVector3 pos = session.getPlacementPosition(player);
|
||||||
if (raised) {
|
if (raised) {
|
||||||
pos = pos.add(0, radiusY, 0);
|
pos = pos.add(0, (int) radiusY, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
|
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
|
||||||
@ -240,7 +241,7 @@ public class GenerationCommands {
|
|||||||
@CommandPermissions("worldedit.generation.pyramid")
|
@CommandPermissions("worldedit.generation.pyramid")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void pyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow) throws WorldEditException {
|
public void pyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow) throws WorldEditException {
|
||||||
Vector pos = session.getPlacementPosition(player);
|
BlockVector3 pos = session.getPlacementPosition(player);
|
||||||
worldEdit.checkMaxRadius(size);
|
worldEdit.checkMaxRadius(size);
|
||||||
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
||||||
player.findFreePosition();
|
player.findFreePosition();
|
||||||
@ -277,31 +278,31 @@ public class GenerationCommands {
|
|||||||
@Switch('o') boolean offset,
|
@Switch('o') boolean offset,
|
||||||
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
||||||
|
|
||||||
final Vector zero;
|
final Vector3 zero;
|
||||||
Vector unit;
|
Vector3 unit;
|
||||||
|
|
||||||
if (useRawCoords) {
|
if (useRawCoords) {
|
||||||
zero = Vector.ZERO;
|
zero = Vector3.ZERO;
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
} else if (offset) {
|
} else if (offset) {
|
||||||
zero = session.getPlacementPosition(player);
|
zero = session.getPlacementPosition(player).toVector3();
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
} else if (offsetCenter) {
|
} else if (offsetCenter) {
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||||
final Vector max = region.getMaximumPoint();
|
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||||
|
|
||||||
zero = max.add(min).multiply(0.5);
|
zero = max.add(min).multiply(0.5);
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
} else {
|
} else {
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||||
final Vector max = region.getMaximumPoint();
|
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||||
|
|
||||||
zero = max.add(min).multiply(0.5);
|
zero = max.add(min).multiply(0.5);
|
||||||
unit = max.subtract(zero);
|
unit = max.subtract(zero);
|
||||||
|
|
||||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -342,31 +343,31 @@ public class GenerationCommands {
|
|||||||
@Switch('r') boolean useRawCoords,
|
@Switch('r') boolean useRawCoords,
|
||||||
@Switch('o') boolean offset,
|
@Switch('o') boolean offset,
|
||||||
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
||||||
final Vector zero;
|
final Vector3 zero;
|
||||||
Vector unit;
|
Vector3 unit;
|
||||||
|
|
||||||
if (useRawCoords) {
|
if (useRawCoords) {
|
||||||
zero = Vector.ZERO;
|
zero = Vector3.ZERO;
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
} else if (offset) {
|
} else if (offset) {
|
||||||
zero = session.getPlacementPosition(player);
|
zero = session.getPlacementPosition(player).toVector3();
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
} else if (offsetCenter) {
|
} else if (offsetCenter) {
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||||
final Vector max = region.getMaximumPoint();
|
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||||
|
|
||||||
zero = max.add(min).multiply(0.5);
|
zero = max.add(min).multiply(0.5);
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
} else {
|
} else {
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||||
final Vector max = region.getMaximumPoint();
|
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||||
|
|
||||||
zero = max.add(min).multiply(0.5);
|
zero = max.add(min).multiply(0.5);
|
||||||
unit = max.subtract(zero);
|
unit = max.subtract(zero);
|
||||||
|
|
||||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -32,7 +32,6 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
@ -48,6 +47,8 @@ import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
|||||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||||
@ -110,8 +111,8 @@ public class RegionCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CuboidRegion cuboidregion = (CuboidRegion) region;
|
CuboidRegion cuboidregion = (CuboidRegion) region;
|
||||||
Vector pos1 = cuboidregion.getPos1();
|
BlockVector3 pos1 = cuboidregion.getPos1();
|
||||||
Vector pos2 = cuboidregion.getPos2();
|
BlockVector3 pos2 = cuboidregion.getPos2();
|
||||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
||||||
|
|
||||||
player.print(blocksChanged + " block(s) have been changed.");
|
player.print(blocksChanged + " block(s) have been changed.");
|
||||||
@ -143,7 +144,7 @@ public class RegionCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||||
List<Vector> vectors = new ArrayList<>(cpregion.getVertices());
|
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
|
||||||
|
|
||||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
||||||
|
|
||||||
@ -274,7 +275,7 @@ public class RegionCommands {
|
|||||||
public void move(Player player, EditSession editSession, LocalSession session,
|
public void move(Player player, EditSession editSession, LocalSession session,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Optional("1") @Range(min = 1) int count,
|
@Optional("1") @Range(min = 1) int count,
|
||||||
@Optional(Direction.AIM) @Direction Vector direction,
|
@Optional(Direction.AIM) @Direction BlockVector3 direction,
|
||||||
@Optional("air") BlockStateHolder replace,
|
@Optional("air") BlockStateHolder replace,
|
||||||
@Switch('s') boolean moveSelection) throws WorldEditException {
|
@Switch('s') boolean moveSelection) throws WorldEditException {
|
||||||
|
|
||||||
@ -312,16 +313,16 @@ public class RegionCommands {
|
|||||||
public void stack(Player player, EditSession editSession, LocalSession session,
|
public void stack(Player player, EditSession editSession, LocalSession session,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Optional("1") @Range(min = 1) int count,
|
@Optional("1") @Range(min = 1) int count,
|
||||||
@Optional(Direction.AIM) @Direction Vector direction,
|
@Optional(Direction.AIM) @Direction BlockVector3 direction,
|
||||||
@Switch('s') boolean moveSelection,
|
@Switch('s') boolean moveSelection,
|
||||||
@Switch('a') boolean ignoreAirBlocks) throws WorldEditException {
|
@Switch('a') boolean ignoreAirBlocks) throws WorldEditException {
|
||||||
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks);
|
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks);
|
||||||
|
|
||||||
if (moveSelection) {
|
if (moveSelection) {
|
||||||
try {
|
try {
|
||||||
final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
||||||
|
|
||||||
final Vector shiftVector = direction.multiply(count * (Math.abs(direction.dot(size)) + 1));
|
final BlockVector3 shiftVector = direction.toVector3().multiply(count * (Math.abs(direction.dot(size)) + 1)).toBlockPoint();
|
||||||
region.shift(shiftVector);
|
region.shift(shiftVector);
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||||
@ -378,25 +379,25 @@ public class RegionCommands {
|
|||||||
@Text String expression,
|
@Text String expression,
|
||||||
@Switch('r') boolean useRawCoords,
|
@Switch('r') boolean useRawCoords,
|
||||||
@Switch('o') boolean offset) throws WorldEditException {
|
@Switch('o') boolean offset) throws WorldEditException {
|
||||||
final Vector zero;
|
final Vector3 zero;
|
||||||
Vector unit;
|
Vector3 unit;
|
||||||
|
|
||||||
if (useRawCoords) {
|
if (useRawCoords) {
|
||||||
zero = Vector.ZERO;
|
zero = Vector3.ZERO;
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
} else if (offset) {
|
} else if (offset) {
|
||||||
zero = session.getPlacementPosition(player);
|
zero = session.getPlacementPosition(player).toVector3();
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
} else {
|
} else {
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||||
final Vector max = region.getMaximumPoint();
|
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||||
|
|
||||||
zero = max.add(min).multiply(0.5);
|
zero = max.add(min).divide(2);
|
||||||
unit = max.subtract(zero);
|
unit = max.subtract(zero);
|
||||||
|
|
||||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -29,8 +29,6 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
@ -38,6 +36,8 @@ import com.sk89q.worldedit.entity.Player;
|
|||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
@ -58,7 +58,6 @@ import com.sk89q.worldedit.util.formatting.StyledFragment;
|
|||||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||||
|
|
||||||
@ -103,13 +102,13 @@ public class SelectionCommands {
|
|||||||
pos = player.getBlockIn();
|
pos = player.getBlockIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
|
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||||
player.printError("Position already set.");
|
player.printError("Position already set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld())
|
session.getRegionSelector(player.getWorld())
|
||||||
.explainPrimarySelection(player, session, pos.toVector());
|
.explainPrimarySelection(player, session, pos.toVector().toBlockPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -138,13 +137,13 @@ public class SelectionCommands {
|
|||||||
pos = player.getBlockIn();
|
pos = player.getBlockIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
|
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||||
player.printError("Position already set.");
|
player.printError("Position already set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld())
|
session.getRegionSelector(player.getWorld())
|
||||||
.explainSecondarySelection(player, session, pos.toVector());
|
.explainSecondarySelection(player, session, pos.toVector().toBlockPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -160,13 +159,13 @@ public class SelectionCommands {
|
|||||||
Location pos = player.getBlockTrace(300);
|
Location pos = player.getBlockTrace(300);
|
||||||
|
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
|
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||||
player.printError("Position already set.");
|
player.printError("Position already set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld())
|
session.getRegionSelector(player.getWorld())
|
||||||
.explainPrimarySelection(player, session, pos.toVector());
|
.explainPrimarySelection(player, session, pos.toVector().toBlockPoint());
|
||||||
} else {
|
} else {
|
||||||
player.printError("No block in sight!");
|
player.printError("No block in sight!");
|
||||||
}
|
}
|
||||||
@ -185,13 +184,13 @@ public class SelectionCommands {
|
|||||||
Location pos = player.getBlockTrace(300);
|
Location pos = player.getBlockTrace(300);
|
||||||
|
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
|
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||||
player.printError("Position already set.");
|
player.printError("Position already set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld())
|
session.getRegionSelector(player.getWorld())
|
||||||
.explainSecondarySelection(player, session, pos.toVector());
|
.explainSecondarySelection(player, session, pos.toVector().toBlockPoint());
|
||||||
} else {
|
} else {
|
||||||
player.printError("No block in sight!");
|
player.printError("No block in sight!");
|
||||||
}
|
}
|
||||||
@ -216,23 +215,23 @@ public class SelectionCommands {
|
|||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
@CommandPermissions("worldedit.selection.chunk")
|
@CommandPermissions("worldedit.selection.chunk")
|
||||||
public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||||
final Vector min;
|
final BlockVector3 min;
|
||||||
final Vector max;
|
final BlockVector3 max;
|
||||||
final World world = player.getWorld();
|
final World world = player.getWorld();
|
||||||
if (args.hasFlag('s')) {
|
if (args.hasFlag('s')) {
|
||||||
Region region = session.getSelection(world);
|
Region region = session.getSelection(world);
|
||||||
|
|
||||||
final Vector2D min2D = ChunkStore.toChunk(region.getMinimumPoint());
|
final BlockVector2 min2D = ChunkStore.toChunk(region.getMinimumPoint());
|
||||||
final Vector2D max2D = ChunkStore.toChunk(region.getMaximumPoint());
|
final BlockVector2 max2D = ChunkStore.toChunk(region.getMaximumPoint());
|
||||||
|
|
||||||
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
min = new BlockVector3(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||||
max = new Vector(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15);
|
max = new BlockVector3(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15);
|
||||||
|
|
||||||
player.print("Chunks selected: ("
|
player.print("Chunks selected: ("
|
||||||
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - ("
|
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - ("
|
||||||
+ max2D.getBlockX() + ", " + max2D.getBlockZ() + ")");
|
+ max2D.getBlockX() + ", " + max2D.getBlockZ() + ")");
|
||||||
} else {
|
} else {
|
||||||
final Vector2D min2D;
|
final BlockVector2 min2D;
|
||||||
if (args.argsLength() == 1) {
|
if (args.argsLength() == 1) {
|
||||||
// coords specified
|
// coords specified
|
||||||
String[] coords = args.getString(0).split(",");
|
String[] coords = args.getString(0).split(",");
|
||||||
@ -241,14 +240,14 @@ public class SelectionCommands {
|
|||||||
}
|
}
|
||||||
int x = Integer.parseInt(coords[0]);
|
int x = Integer.parseInt(coords[0]);
|
||||||
int z = Integer.parseInt(coords[1]);
|
int z = Integer.parseInt(coords[1]);
|
||||||
Vector2D pos = new Vector2D(x, z);
|
BlockVector2 pos = new BlockVector2(x, z);
|
||||||
min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toVector());
|
min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toBlockVector3());
|
||||||
} else {
|
} else {
|
||||||
// use player loc
|
// use player loc
|
||||||
min2D = ChunkStore.toChunk(player.getBlockIn().toVector());
|
min2D = ChunkStore.toChunk(player.getBlockIn().toVector().toBlockPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
min = new BlockVector3(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||||
max = min.add(15, world.getMaxY(), 15);
|
max = min.add(15, world.getMaxY(), 15);
|
||||||
|
|
||||||
player.print("Chunk selected: "
|
player.print("Chunk selected: "
|
||||||
@ -321,8 +320,8 @@ public class SelectionCommands {
|
|||||||
try {
|
try {
|
||||||
int oldSize = region.getArea();
|
int oldSize = region.getArea();
|
||||||
region.expand(
|
region.expand(
|
||||||
new Vector(0, (player.getWorld().getMaxY() + 1), 0),
|
new BlockVector3(0, (player.getWorld().getMaxY() + 1), 0),
|
||||||
new Vector(0, -(player.getWorld().getMaxY() + 1), 0));
|
new BlockVector3(0, -(player.getWorld().getMaxY() + 1), 0));
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||||
int newSize = region.getArea();
|
int newSize = region.getArea();
|
||||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||||
@ -335,7 +334,7 @@ public class SelectionCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Vector> dirs = new ArrayList<>();
|
List<BlockVector3> dirs = new ArrayList<>();
|
||||||
int change = args.getInteger(0);
|
int change = args.getInteger(0);
|
||||||
int reverseChange = 0;
|
int reverseChange = 0;
|
||||||
|
|
||||||
@ -380,11 +379,11 @@ public class SelectionCommands {
|
|||||||
int oldSize = region.getArea();
|
int oldSize = region.getArea();
|
||||||
|
|
||||||
if (reverseChange == 0) {
|
if (reverseChange == 0) {
|
||||||
for (Vector dir : dirs) {
|
for (BlockVector3 dir : dirs) {
|
||||||
region.expand(dir.multiply(change));
|
region.expand(dir.multiply(change));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Vector dir : dirs) {
|
for (BlockVector3 dir : dirs) {
|
||||||
region.expand(dir.multiply(change), dir.multiply(-reverseChange));
|
region.expand(dir.multiply(change), dir.multiply(-reverseChange));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -408,7 +407,7 @@ public class SelectionCommands {
|
|||||||
@CommandPermissions("worldedit.selection.contract")
|
@CommandPermissions("worldedit.selection.contract")
|
||||||
public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
List<Vector> dirs = new ArrayList<>();
|
List<BlockVector3> dirs = new ArrayList<>();
|
||||||
int change = args.getInteger(0);
|
int change = args.getInteger(0);
|
||||||
int reverseChange = 0;
|
int reverseChange = 0;
|
||||||
|
|
||||||
@ -452,11 +451,11 @@ public class SelectionCommands {
|
|||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
int oldSize = region.getArea();
|
int oldSize = region.getArea();
|
||||||
if (reverseChange == 0) {
|
if (reverseChange == 0) {
|
||||||
for (Vector dir : dirs) {
|
for (BlockVector3 dir : dirs) {
|
||||||
region.contract(dir.multiply(change));
|
region.contract(dir.multiply(change));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Vector dir : dirs) {
|
for (BlockVector3 dir : dirs) {
|
||||||
region.contract(dir.multiply(change), dir.multiply(-reverseChange));
|
region.contract(dir.multiply(change), dir.multiply(-reverseChange));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -483,7 +482,7 @@ public class SelectionCommands {
|
|||||||
@CommandPermissions("worldedit.selection.shift")
|
@CommandPermissions("worldedit.selection.shift")
|
||||||
public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
List<Vector> dirs = new ArrayList<>();
|
List<BlockVector3> dirs = new ArrayList<>();
|
||||||
int change = args.getInteger(0);
|
int change = args.getInteger(0);
|
||||||
if (args.argsLength() == 2) {
|
if (args.argsLength() == 2) {
|
||||||
if (args.getString(1).contains(",")) {
|
if (args.getString(1).contains(",")) {
|
||||||
@ -500,7 +499,7 @@ public class SelectionCommands {
|
|||||||
try {
|
try {
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
|
|
||||||
for (Vector dir : dirs) {
|
for (BlockVector3 dir : dirs) {
|
||||||
region.shift(dir.multiply(change));
|
region.shift(dir.multiply(change));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,23 +559,23 @@ public class SelectionCommands {
|
|||||||
player.print("Region inset.");
|
player.print("Region inset.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector[] getChangesForEachDir(CommandContext args) {
|
private BlockVector3[] getChangesForEachDir(CommandContext args) {
|
||||||
List<Vector> changes = new ArrayList<>(6);
|
List<BlockVector3> changes = new ArrayList<>(6);
|
||||||
int change = args.getInteger(0);
|
int change = args.getInteger(0);
|
||||||
|
|
||||||
if (!args.hasFlag('h')) {
|
if (!args.hasFlag('h')) {
|
||||||
changes.add((new Vector(0, 1, 0)).multiply(change));
|
changes.add((new BlockVector3(0, 1, 0)).multiply(change));
|
||||||
changes.add((new Vector(0, -1, 0)).multiply(change));
|
changes.add((new BlockVector3(0, -1, 0)).multiply(change));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.hasFlag('v')) {
|
if (!args.hasFlag('v')) {
|
||||||
changes.add((new Vector(1, 0, 0)).multiply(change));
|
changes.add((new BlockVector3(1, 0, 0)).multiply(change));
|
||||||
changes.add((new Vector(-1, 0, 0)).multiply(change));
|
changes.add((new BlockVector3(-1, 0, 0)).multiply(change));
|
||||||
changes.add((new Vector(0, 0, 1)).multiply(change));
|
changes.add((new BlockVector3(0, 0, 1)).multiply(change));
|
||||||
changes.add((new Vector(0, 0, -1)).multiply(change));
|
changes.add((new BlockVector3(0, 0, -1)).multiply(change));
|
||||||
}
|
}
|
||||||
|
|
||||||
return changes.toArray(new Vector[0]);
|
return changes.toArray(new BlockVector3[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -589,23 +588,22 @@ public class SelectionCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.selection.size")
|
@CommandPermissions("worldedit.selection.size")
|
||||||
public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
if (args.hasFlag('c')) {
|
if (args.hasFlag('c')) {
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
Region region = clipboard.getRegion();
|
Region region = clipboard.getRegion();
|
||||||
Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
||||||
Vector origin = clipboard.getOrigin();
|
BlockVector3 origin = clipboard.getOrigin();
|
||||||
|
|
||||||
player.print("Cuboid dimensions (max - min): " + size);
|
player.print("Cuboid dimensions (max - min): " + size);
|
||||||
player.print("Offset: " + origin);
|
player.print("Offset: " + origin);
|
||||||
player.print("Cuboid distance: " + size.distance(Vector.ONE));
|
player.print("Cuboid distance: " + size.distance(BlockVector3.ONE));
|
||||||
player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
|
player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
Vector size = region.getMaximumPoint()
|
BlockVector3 size = region.getMaximumPoint()
|
||||||
.subtract(region.getMinimumPoint())
|
.subtract(region.getMinimumPoint())
|
||||||
.add(1, 1, 1);
|
.add(1, 1, 1);
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ import com.sk89q.minecraft.util.commands.Logging;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||||
@ -49,6 +48,7 @@ import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
|||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
@ -103,7 +103,7 @@ public class UtilityCommands {
|
|||||||
we.checkMaxRadius(radius);
|
we.checkMaxRadius(radius);
|
||||||
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;
|
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;
|
||||||
|
|
||||||
Vector pos = session.getPlacementPosition(player);
|
BlockVector3 pos = session.getPlacementPosition(player);
|
||||||
int affected = editSession.fillXZ(pos, pattern, radius, depth, false);
|
int affected = editSession.fillXZ(pos, pattern, radius, depth, false);
|
||||||
player.print(affected + " block(s) have been created.");
|
player.print(affected + " block(s) have been created.");
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ public class UtilityCommands {
|
|||||||
we.checkMaxRadius(radius);
|
we.checkMaxRadius(radius);
|
||||||
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE;
|
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE;
|
||||||
|
|
||||||
Vector pos = session.getPlacementPosition(player);
|
BlockVector3 pos = session.getPlacementPosition(player);
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
if (pattern instanceof BlockPattern) {
|
if (pattern instanceof BlockPattern) {
|
||||||
affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true);
|
affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true);
|
||||||
@ -290,9 +290,9 @@ public class UtilityCommands {
|
|||||||
to = we.getPatternFactory().parseFromInput(args.getString(2), context);
|
to = we.getPatternFactory().parseFromInput(args.getString(2), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector base = session.getPlacementPosition(player);
|
BlockVector3 base = session.getPlacementPosition(player);
|
||||||
Vector min = base.subtract(size, size, size);
|
BlockVector3 min = base.subtract(size, size, size);
|
||||||
Vector max = base.add(size, size, size);
|
BlockVector3 max = base.add(size, size, size);
|
||||||
Region region = new CuboidRegion(player.getWorld(), min, max);
|
Region region = new CuboidRegion(player.getWorld(), min, max);
|
||||||
|
|
||||||
if (to instanceof BlockPattern) {
|
if (to instanceof BlockPattern) {
|
||||||
@ -432,7 +432,7 @@ public class UtilityCommands {
|
|||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
session = we.getSessionManager().get(player);
|
session = we.getSessionManager().get(player);
|
||||||
Vector center = session.getPlacementPosition(player);
|
BlockVector3 center = session.getPlacementPosition(player);
|
||||||
editSession = session.createEditSession(player);
|
editSession = session.createEditSession(player);
|
||||||
List<? extends Entity> entities;
|
List<? extends Entity> entities;
|
||||||
if (radius >= 0) {
|
if (radius >= 0) {
|
||||||
@ -492,7 +492,7 @@ public class UtilityCommands {
|
|||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
session = we.getSessionManager().get(player);
|
session = we.getSessionManager().get(player);
|
||||||
Vector center = session.getPlacementPosition(player);
|
BlockVector3 center = session.getPlacementPosition(player);
|
||||||
editSession = session.createEditSession(player);
|
editSession = session.createEditSession(player);
|
||||||
List<? extends Entity> entities;
|
List<? extends Entity> entities;
|
||||||
if (radius >= 0) {
|
if (radius >= 0) {
|
||||||
|
@ -22,12 +22,12 @@ package com.sk89q.worldedit.command.argument;
|
|||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.function.Contextual;
|
import com.sk89q.worldedit.function.Contextual;
|
||||||
import com.sk89q.worldedit.function.EditContext;
|
import com.sk89q.worldedit.function.EditContext;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.command.argument.CommandArgs;
|
import com.sk89q.worldedit.util.command.argument.CommandArgs;
|
||||||
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
||||||
@ -82,7 +82,7 @@ public class ItemUseParser extends SimpleCommand<Contextual<RegionFunction>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
return world.useItem(position, item, Direction.UP);
|
return world.useItem(position, item, Direction.UP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class DeformCommand extends SimpleCommand<Contextual<? extends Operation>
|
|||||||
Player player = (Player) locals.get(Actor.class);
|
Player player = (Player) locals.get(Actor.class);
|
||||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(locals.get(Actor.class));
|
LocalSession session = WorldEdit.getInstance().getSessionManager().get(locals.get(Actor.class));
|
||||||
try {
|
try {
|
||||||
deform.setOffset(session.getPlacementPosition(player));
|
deform.setOffset(session.getPlacementPosition(player).toVector3());
|
||||||
} catch (IncompleteRegionException e) {
|
} catch (IncompleteRegionException e) {
|
||||||
throw new WrappedCommandException(e);
|
throw new WrappedCommandException(e);
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,10 @@ import com.sk89q.worldedit.EditSession;
|
|||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -52,7 +52,7 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
int ox = clicked.getBlockX();
|
int ox = clicked.getBlockX();
|
||||||
int oy = clicked.getBlockY();
|
int oy = clicked.getBlockY();
|
||||||
int oz = clicked.getBlockZ();
|
int oz = clicked.getBlockZ();
|
||||||
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector()).getBlockType();
|
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector().toBlockPoint()).getBlockType();
|
||||||
|
|
||||||
if (initialType.getMaterial().isAir()) {
|
if (initialType.getMaterial().isAir()) {
|
||||||
return true;
|
return true;
|
||||||
@ -69,12 +69,12 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
for (int x = ox - range; x <= ox + range; ++x) {
|
for (int x = ox - range; x <= ox + range; ++x) {
|
||||||
for (int y = oy - range; y <= oy + range; ++y) {
|
for (int y = oy - range; y <= oy + range; ++y) {
|
||||||
for (int z = oz - range; z <= oz + range; ++z) {
|
for (int z = oz - range; z <= oz + range; ++z) {
|
||||||
Vector pos = new Vector(x, y, z);
|
BlockVector3 pos = new BlockVector3(x, y, z);
|
||||||
if (editSession.getBlock(pos).getBlockType() != initialType) {
|
if (editSession.getBlock(pos).getBlockType() != initialType) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().distanceSq(pos));
|
((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().toBlockPoint().distanceSq(pos));
|
||||||
|
|
||||||
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
|||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -54,7 +55,8 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
|
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
|
|
||||||
BlockState block = world.getBlock(clicked.toVector());
|
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||||
|
BlockState block = world.getBlock(blockPoint);
|
||||||
|
|
||||||
if (!config.allowedDataCycleBlocks.isEmpty()
|
if (!config.allowedDataCycleBlocks.isEmpty()
|
||||||
&& !player.hasPermission("worldedit.override.data-cycler")
|
&& !player.hasPermission("worldedit.override.data-cycler")
|
||||||
@ -83,7 +85,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
editSession.disableBuffering();
|
editSession.disableBuffering();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
editSession.setBlock(clicked.toVector(), newBlock);
|
editSession.setBlock(blockPoint, newBlock);
|
||||||
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString());
|
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString());
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
|
@ -23,13 +23,13 @@ import com.sk89q.worldedit.EditSession;
|
|||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +55,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
|||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
try {
|
try {
|
||||||
editSession.disableBuffering();
|
editSession.disableBuffering();
|
||||||
Vector position = clicked.toVector();
|
BlockVector3 position = clicked.toVector().toBlockPoint();
|
||||||
editSession.setBlock(position, pattern.apply(position));
|
editSession.setBlock(position, pattern.apply(position));
|
||||||
} catch (MaxChangedBlocksException ignored) {
|
} catch (MaxChangedBlocksException ignored) {
|
||||||
} finally {
|
} finally {
|
||||||
@ -73,7 +73,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
BlockStateHolder targetBlock = player.getWorld().getBlock(clicked.toVector());
|
BlockStateHolder targetBlock = player.getWorld().getBlock(clicked.toVector().toBlockPoint());
|
||||||
|
|
||||||
if (targetBlock != null) {
|
if (targetBlock != null) {
|
||||||
pattern = new BlockPattern(targetBlock);
|
pattern = new BlockPattern(targetBlock);
|
||||||
|
@ -189,7 +189,7 @@ public class BrushTool implements TraceTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
brush.build(editSession, target.toVector(), material, size);
|
brush.build(editSession, target.toVector().toBlockPoint(), material, size);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.entity.Player;
|
|||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
@ -49,8 +50,9 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
|||||||
if (target == null) return true;
|
if (target == null) return true;
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
if (selector.selectPrimary(target.toVector(), ActorSelectorLimits.forActor(player))) {
|
BlockVector3 blockPoint = target.toVector().toBlockPoint();
|
||||||
selector.explainPrimarySelection(player, session, target.toVector());
|
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
|
selector.explainPrimarySelection(player, session, blockPoint);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -66,8 +68,9 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
|||||||
if (target == null) return true;
|
if (target == null) return true;
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
if (selector.selectSecondary(target.toVector(), ActorSelectorLimits.forActor(player))) {
|
BlockVector3 blockPoint = target.toVector().toBlockPoint();
|
||||||
selector.explainSecondarySelection(player, session, target.toVector());
|
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
|
selector.explainSecondarySelection(player, session, blockPoint);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ import com.sk89q.worldedit.EditSession;
|
|||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -69,7 +69,7 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
Player player, LocalSession session, Location clicked) {
|
Player player, LocalSession session, Location clicked) {
|
||||||
|
|
||||||
final World world = (World) clicked.getExtent();
|
final World world = (World) clicked.getExtent();
|
||||||
final BlockState state = world.getBlock(clicked.toVector());
|
final BlockState state = world.getBlock(clicked.toVector().toBlockPoint());
|
||||||
|
|
||||||
if (!isTreeBlock(state.getBlockType())) {
|
if (!isTreeBlock(state.getBlockType())) {
|
||||||
player.printError("That's not a tree.");
|
player.printError("That's not a tree.");
|
||||||
@ -78,13 +78,13 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
try {
|
try {
|
||||||
final Set<Vector> blockSet = bfs(world, clicked.toVector());
|
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
|
||||||
if (blockSet == null) {
|
if (blockSet == null) {
|
||||||
player.printError("That's not a floating tree.");
|
player.printError("That's not a floating tree.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Vector blockVector : blockSet) {
|
for (BlockVector3 blockVector : blockSet) {
|
||||||
final BlockState otherState = editSession.getBlock(blockVector);
|
final BlockState otherState = editSession.getBlock(blockVector);
|
||||||
if (isTreeBlock(otherState.getBlockType())) {
|
if (isTreeBlock(otherState.getBlockType())) {
|
||||||
editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState());
|
||||||
@ -100,13 +100,13 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector[] recurseDirections = {
|
private BlockVector3[] recurseDirections = {
|
||||||
Direction.NORTH.toVector(),
|
Direction.NORTH.toBlockVector(),
|
||||||
Direction.EAST.toVector(),
|
Direction.EAST.toBlockVector(),
|
||||||
Direction.SOUTH.toVector(),
|
Direction.SOUTH.toBlockVector(),
|
||||||
Direction.WEST.toVector(),
|
Direction.WEST.toBlockVector(),
|
||||||
Direction.UP.toVector(),
|
Direction.UP.toBlockVector(),
|
||||||
Direction.DOWN.toVector(),
|
Direction.DOWN.toBlockVector(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,17 +116,17 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
* @param origin any point contained in the floating tree
|
* @param origin any point contained in the floating tree
|
||||||
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
|
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
|
||||||
*/
|
*/
|
||||||
private Set<Vector> bfs(World world, Vector origin) throws MaxChangedBlocksException {
|
private Set<BlockVector3> bfs(World world, BlockVector3 origin) throws MaxChangedBlocksException {
|
||||||
final Set<Vector> visited = new HashSet<>();
|
final Set<BlockVector3> visited = new HashSet<>();
|
||||||
final LinkedList<Vector> queue = new LinkedList<>();
|
final LinkedList<BlockVector3> queue = new LinkedList<>();
|
||||||
|
|
||||||
queue.addLast(origin);
|
queue.addLast(origin);
|
||||||
visited.add(origin);
|
visited.add(origin);
|
||||||
|
|
||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
final Vector current = queue.removeFirst();
|
final BlockVector3 current = queue.removeFirst();
|
||||||
for (Vector recurseDirection : recurseDirections) {
|
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||||
final Vector next = current.add(recurseDirection);
|
final BlockVector3 next = current.add(recurseDirection);
|
||||||
if (origin.distanceSq(next) > rangeSq) {
|
if (origin.distanceSq(next) > rangeSq) {
|
||||||
// Maximum range exceeded => stop walking
|
// Maximum range exceeded => stop walking
|
||||||
continue;
|
continue;
|
||||||
|
@ -19,16 +19,15 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -59,7 +58,8 @@ public class FloodFillTool implements BlockTool {
|
|||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
|
|
||||||
BlockType initialType = world.getBlock(clicked.toVector()).getBlockType();
|
BlockVector3 origin = clicked.toVector().toBlockPoint();
|
||||||
|
BlockType initialType = world.getBlock(origin).getBlockType();
|
||||||
|
|
||||||
if (initialType.getMaterial().isAir()) {
|
if (initialType.getMaterial().isAir()) {
|
||||||
return true;
|
return true;
|
||||||
@ -71,8 +71,7 @@ public class FloodFillTool implements BlockTool {
|
|||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
try {
|
try {
|
||||||
recurse(editSession, clicked.toVector().toBlockVector(),
|
recurse(editSession, origin, origin, range, initialType, new HashSet<>());
|
||||||
clicked.toVector(), range, initialType, new HashSet<>());
|
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
@ -83,8 +82,8 @@ public class FloodFillTool implements BlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recurse(EditSession editSession, BlockVector pos, Vector origin, int size, BlockType initialType,
|
private void recurse(EditSession editSession, BlockVector3 pos, BlockVector3 origin, int size, BlockType initialType,
|
||||||
Set<BlockVector> visited) throws MaxChangedBlocksException {
|
Set<BlockVector3> visited) throws MaxChangedBlocksException {
|
||||||
|
|
||||||
if (origin.distance(pos) > size || visited.contains(pos)) {
|
if (origin.distance(pos) > size || visited.contains(pos)) {
|
||||||
return;
|
return;
|
||||||
@ -98,17 +97,17 @@ public class FloodFillTool implements BlockTool {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
recurse(editSession, pos.add(1, 0, 0).toBlockVector(),
|
recurse(editSession, pos.add(1, 0, 0),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(editSession, pos.add(-1, 0, 0).toBlockVector(),
|
recurse(editSession, pos.add(-1, 0, 0),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(editSession, pos.add(0, 0, 1).toBlockVector(),
|
recurse(editSession, pos.add(0, 0, 1),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(editSession, pos.add(0, 0, -1).toBlockVector(),
|
recurse(editSession, pos.add(0, 0, -1),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(editSession, pos.add(0, 1, 0).toBlockVector(),
|
recurse(editSession, pos.add(0, 1, 0),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(editSession, pos.add(0, -1, 0).toBlockVector(),
|
recurse(editSession, pos.add(0, -1, 0),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.entity.Player;
|
|||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -55,11 +56,12 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
try (EditSession eS = session.createEditSession(player)) {
|
try (EditSession eS = session.createEditSession(player)) {
|
||||||
eS.disableBuffering();
|
eS.disableBuffering();
|
||||||
BlockStateHolder applied = secondary.apply(pos.toVector());
|
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||||
|
BlockStateHolder applied = secondary.apply(blockPoint);
|
||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
eS.setBlock(pos.toVector(), secondary);
|
eS.setBlock(blockPoint, secondary);
|
||||||
} else {
|
} else {
|
||||||
eS.setBlock(pos.getDirection(), secondary);
|
eS.setBlock(pos.getDirection().toBlockPoint(), secondary);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
@ -75,11 +77,12 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
try (EditSession eS = session.createEditSession(player)) {
|
try (EditSession eS = session.createEditSession(player)) {
|
||||||
eS.disableBuffering();
|
eS.disableBuffering();
|
||||||
BlockStateHolder applied = primary.apply(pos.toVector());
|
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||||
|
BlockStateHolder applied = primary.apply(blockPoint);
|
||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
eS.setBlock(pos.toVector(), primary);
|
eS.setBlock(blockPoint, primary);
|
||||||
} else {
|
} else {
|
||||||
eS.setBlock(pos.getDirection(), primary);
|
eS.setBlock(pos.getDirection().toBlockPoint(), primary);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
|
@ -26,6 +26,7 @@ import com.sk89q.worldedit.blocks.MobSpawnerBlock;
|
|||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -44,13 +45,14 @@ public class QueryTool implements BlockTool {
|
|||||||
|
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
BlockStateHolder block = editSession.getFullBlock(clicked.toVector());
|
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||||
|
BlockStateHolder block = editSession.getFullBlock(blockPoint);
|
||||||
|
|
||||||
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
|
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
|
||||||
+ block.getBlockType().getName() + "\u00A77" + " ("
|
+ block.getBlockType().getName() + "\u00A77" + " ("
|
||||||
+ block.toString() + ") "
|
+ block.toString() + ") "
|
||||||
+ "\u00A7f"
|
+ "\u00A7f"
|
||||||
+ " (" + world.getBlockLightLevel(clicked.toVector()) + "/" + world.getBlockLightLevel(clicked.toVector().add(0, 1, 0)) + ")");
|
+ " (" + world.getBlockLightLevel(blockPoint) + "/" + world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")");
|
||||||
|
|
||||||
if (block instanceof MobSpawnerBlock) {
|
if (block instanceof MobSpawnerBlock) {
|
||||||
player.printRaw("\u00A7e" + "Mob Type: "
|
player.printRaw("\u00A7e" + "Mob Type: "
|
||||||
|
@ -19,15 +19,14 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -56,7 +55,8 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
|
|
||||||
BlockType initialType = world.getBlock(clicked.toVector()).getBlockType();
|
BlockVector3 origin = clicked.toVector().toBlockPoint();
|
||||||
|
BlockType initialType = world.getBlock(origin).getBlockType();
|
||||||
|
|
||||||
if (initialType.getMaterial().isAir()) {
|
if (initialType.getMaterial().isAir()) {
|
||||||
return true;
|
return true;
|
||||||
@ -70,8 +70,8 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
|
recurse(server, editSession, world, clicked.toVector().toBlockPoint(),
|
||||||
clicked.toVector(), range, initialType, new HashSet<>());
|
clicked.toVector().toBlockPoint(), range, initialType, new HashSet<>());
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
@ -82,8 +82,8 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void recurse(Platform server, EditSession editSession, World world, BlockVector pos,
|
private static void recurse(Platform server, EditSession editSession, World world, BlockVector3 pos,
|
||||||
Vector origin, double size, BlockType initialType, Set<BlockVector> visited) throws MaxChangedBlocksException {
|
BlockVector3 origin, double size, BlockType initialType, Set<BlockVector3> visited) throws MaxChangedBlocksException {
|
||||||
|
|
||||||
final double distanceSq = origin.distanceSq(pos);
|
final double distanceSq = origin.distanceSq(pos);
|
||||||
if (distanceSq > size*size || visited.contains(pos)) {
|
if (distanceSq > size*size || visited.contains(pos)) {
|
||||||
@ -100,17 +100,17 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
|
|
||||||
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
||||||
|
|
||||||
recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(1, 0, 0),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(-1, 0, 0),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, 0, 1),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, 0, -1),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, 1, 0),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, -1, 0),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
|||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -43,7 +44,8 @@ public class SinglePickaxe implements BlockTool {
|
|||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
final BlockType blockType = world.getBlock(clicked.toVector()).getBlockType();
|
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||||
|
final BlockType blockType = world.getBlock(blockPoint).getBlockType();
|
||||||
if (blockType == BlockTypes.BEDROCK
|
if (blockType == BlockTypes.BEDROCK
|
||||||
&& !player.canDestroyBedrock()) {
|
&& !player.canDestroyBedrock()) {
|
||||||
return true;
|
return true;
|
||||||
@ -51,7 +53,7 @@ public class SinglePickaxe implements BlockTool {
|
|||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
||||||
editSession.setBlock(clicked.toVector(), BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class TreePlanter implements BlockTool {
|
|||||||
boolean successful = false;
|
boolean successful = false;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0))) {
|
if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0).toBlockPoint())) {
|
||||||
successful = true;
|
successful = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A brush is a long-range build tool.
|
* A brush is a long-range build tool.
|
||||||
@ -38,6 +38,6 @@ public interface Brush {
|
|||||||
* @param size the size of the brush
|
* @param size the size of the brush
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException;
|
void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -40,7 +40,7 @@ public class ButcherBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
CylinderRegion region = CylinderRegion.createRadius(editSession, position, size);
|
CylinderRegion region = CylinderRegion.createRadius(editSession, position, size);
|
||||||
List<? extends Entity> entities = editSession.getEntities(region);
|
List<? extends Entity> entities = editSession.getEntities(region);
|
||||||
Operations.completeLegacy(new EntityVisitor(entities.iterator(), flags.createFunction()));
|
Operations.completeLegacy(new EntityVisitor(entities.iterator(), flags.createFunction()));
|
||||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
|
||||||
@ -42,10 +42,10 @@ public class ClipboardBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
Region region = clipboard.getRegion();
|
Region region = clipboard.getRegion();
|
||||||
Vector centerOffset = region.getCenter().subtract(clipboard.getOrigin());
|
BlockVector3 centerOffset = region.getCenter().toBlockPoint().subtract(clipboard.getOrigin());
|
||||||
|
|
||||||
Operation operation = holder
|
Operation operation = holder
|
||||||
.createPaste(editSession)
|
.createPaste(editSession)
|
||||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class CylinderBrush implements Brush {
|
public class CylinderBrush implements Brush {
|
||||||
@ -35,7 +35,7 @@ public class CylinderBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
@ -39,21 +39,21 @@ public class GravityBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
final double startY = fullHeight ? editSession.getWorld().getMaxY() : position.getBlockY() + size;
|
final double startY = fullHeight ? editSession.getWorld().getMaxY() : position.getBlockY() + size;
|
||||||
for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
||||||
for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
||||||
double y = startY;
|
double y = startY;
|
||||||
final List<BlockStateHolder> blockTypes = new ArrayList<>();
|
final List<BlockStateHolder> blockTypes = new ArrayList<>();
|
||||||
for (; y > position.getBlockY() - size; --y) {
|
for (; y > position.getBlockY() - size; --y) {
|
||||||
final Vector pt = new Vector(x, y, z);
|
final BlockVector3 pt = new BlockVector3(x, y, z);
|
||||||
final BlockStateHolder block = editSession.getBlock(pt);
|
final BlockStateHolder block = editSession.getBlock(pt);
|
||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
blockTypes.add(block);
|
blockTypes.add(block);
|
||||||
editSession.setBlock(pt, BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(pt, BlockTypes.AIR.getDefaultState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vector pt = new Vector(x, y, z);
|
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||||
Collections.reverse(blockTypes);
|
Collections.reverse(blockTypes);
|
||||||
for (int i = 0; i < blockTypes.size();) {
|
for (int i = 0; i < blockTypes.size();) {
|
||||||
if (editSession.getBlock(pt).getBlockType().getMaterial().isAir()) {
|
if (editSession.getBlock(pt).getBlockType().getMaterial().isAir()) {
|
||||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class HollowCylinderBrush implements Brush {
|
public class HollowCylinderBrush implements Brush {
|
||||||
@ -35,7 +35,7 @@ public class HollowCylinderBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,15 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class HollowSphereBrush implements Brush {
|
public class HollowSphereBrush implements Brush {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.function.Contextual;
|
import com.sk89q.worldedit.function.Contextual;
|
||||||
import com.sk89q.worldedit.function.EditContext;
|
import com.sk89q.worldedit.function.EditContext;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||||
|
|
||||||
public class OperationFactoryBrush implements Brush {
|
public class OperationFactoryBrush implements Brush {
|
||||||
@ -40,7 +40,7 @@ public class OperationFactoryBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
EditContext context = new EditContext();
|
EditContext context = new EditContext();
|
||||||
context.setDestination(editSession);
|
context.setDestination(editSession);
|
||||||
context.setRegion(regionFactory.createCenteredAt(position, size));
|
context.setRegion(regionFactory.createCenteredAt(position, size));
|
||||||
|
@ -21,8 +21,9 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||||
@ -39,10 +40,11 @@ public class SmoothBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
Location min = new Location(editSession.getWorld(), position.subtract(size, size, size));
|
Vector3 posDouble = position.toVector3();
|
||||||
Vector max = position.add(size, size + 10, size);
|
Location min = new Location(editSession.getWorld(), posDouble.subtract(size, size, size));
|
||||||
Region region = new CuboidRegion(editSession.getWorld(), min.toVector(), max);
|
BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint();
|
||||||
|
Region region = new CuboidRegion(editSession.getWorld(), min.toVector().toBlockPoint(), max);
|
||||||
HeightMap heightMap = new HeightMap(editSession, region);
|
HeightMap heightMap = new HeightMap(editSession, region);
|
||||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||||
heightMap.applyFilter(filter, iterations);
|
heightMap.applyFilter(filter, iterations);
|
||||||
|
@ -21,15 +21,15 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class SphereBrush implements Brush {
|
public class SphereBrush implements Brush {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState());
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,16 @@
|
|||||||
package com.sk89q.worldedit.entity;
|
package com.sk89q.worldedit.entity;
|
||||||
|
|
||||||
import com.sk89q.worldedit.PlayerDirection;
|
import com.sk89q.worldedit.PlayerDirection;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
|
|
||||||
@ -256,14 +257,14 @@ public interface Player extends Entity, Actor {
|
|||||||
* @param pitch the pitch (up/down) of the player's view in degrees
|
* @param pitch the pitch (up/down) of the player's view in degrees
|
||||||
* @param yaw the yaw (left/right) of the player's view in degrees
|
* @param yaw the yaw (left/right) of the player's view in degrees
|
||||||
*/
|
*/
|
||||||
void setPosition(Vector pos, float pitch, float yaw);
|
void setPosition(Vector3 pos, float pitch, float yaw);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the player.
|
* Move the player.
|
||||||
*
|
*
|
||||||
* @param pos where to move them
|
* @param pos where to move them
|
||||||
*/
|
*/
|
||||||
void setPosition(Vector pos);
|
void setPosition(Vector3 pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a fake block to the client.
|
* Sends a fake block to the client.
|
||||||
@ -275,5 +276,5 @@ public interface Player extends Entity, Actor {
|
|||||||
* @param pos The position of the block
|
* @param pos The position of the block
|
||||||
* @param block The block to send, null to reset
|
* @param block The block to send, null to reset
|
||||||
*/
|
*/
|
||||||
void sendFakeBlock(Vector pos, @Nullable BlockStateHolder block);
|
void sendFakeBlock(BlockVector3 pos, @Nullable BlockStateHolder block);
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
import static com.sk89q.worldedit.EditSession.Stage;
|
import static com.sk89q.worldedit.EditSession.Stage;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.event.Event;
|
import com.sk89q.worldedit.event.Event;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ import javax.annotation.Nullable;
|
|||||||
* is set to {@link Stage#BEFORE_HISTORY}, then you can drop (or log) changes
|
* is set to {@link Stage#BEFORE_HISTORY}, then you can drop (or log) changes
|
||||||
* before the change has reached the history, reordering, and actual change
|
* before the change has reached the history, reordering, and actual change
|
||||||
* extents, <em>but</em> that means that any changes made with
|
* extents, <em>but</em> that means that any changes made with
|
||||||
* {@link EditSession#rawSetBlock(Vector, BlockStateHolder)} will skip your
|
* {@link EditSession#rawSetBlock(BlockVector3, BlockStateHolder)} will skip your
|
||||||
* custom {@link Extent} because that method bypasses history (and reorder).
|
* custom {@link Extent} because that method bypasses history (and reorder).
|
||||||
* It is thus recommended that loggers intercept at {@link Stage#BEFORE_CHANGE}
|
* It is thus recommended that loggers intercept at {@link Stage#BEFORE_CHANGE}
|
||||||
* and block interceptors intercept at BOTH {@link Stage#BEFORE_CHANGE} and
|
* and block interceptors intercept at BOTH {@link Stage#BEFORE_CHANGE} and
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extension.factory;
|
package com.sk89q.worldedit.extension.factory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.NotABlockException;
|
import com.sk89q.worldedit.NotABlockException;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -37,6 +36,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
|||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -245,7 +245,7 @@ class DefaultBlockParser extends InputParser<BlockStateHolder> {
|
|||||||
} else if ("pos1".equalsIgnoreCase(typeString)) {
|
} else if ("pos1".equalsIgnoreCase(typeString)) {
|
||||||
// Get the block type from the "primary position"
|
// Get the block type from the "primary position"
|
||||||
final World world = context.requireWorld();
|
final World world = context.requireWorld();
|
||||||
final BlockVector primaryPosition;
|
final BlockVector3 primaryPosition;
|
||||||
try {
|
try {
|
||||||
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
|
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
|
||||||
} catch (IncompleteRegionException e) {
|
} catch (IncompleteRegionException e) {
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.extension.factory;
|
package com.sk89q.worldedit.extension.factory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||||
@ -42,6 +41,8 @@ import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
|||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.noise.RandomNoise;
|
import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
@ -134,7 +135,7 @@ class DefaultMaskParser extends InputParser<Mask> {
|
|||||||
} else {
|
} else {
|
||||||
submask = new ExistingBlockMask(extent);
|
submask = new ExistingBlockMask(extent);
|
||||||
}
|
}
|
||||||
OffsetMask offsetMask = new OffsetMask(submask, new Vector(0, firstChar == '>' ? -1 : 1, 0));
|
OffsetMask offsetMask = new OffsetMask(submask, new BlockVector3(0, firstChar == '>' ? -1 : 1, 0));
|
||||||
return new MaskIntersection(offsetMask, Masks.negate(submask));
|
return new MaskIntersection(offsetMask, Masks.negate(submask));
|
||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
@ -161,7 +162,7 @@ class DefaultMaskParser extends InputParser<Mask> {
|
|||||||
try {
|
try {
|
||||||
Expression exp = Expression.compile(component.substring(1), "x", "y", "z");
|
Expression exp = Expression.compile(component.substring(1), "x", "y", "z");
|
||||||
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(
|
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(
|
||||||
Request.request().getEditSession(), Vector.ONE, Vector.ZERO);
|
Request.request().getEditSession(), Vector3.ONE, Vector3.ZERO);
|
||||||
exp.setEnvironment(env);
|
exp.setEnvironment(env);
|
||||||
return new ExpressionMask(exp);
|
return new ExpressionMask(exp);
|
||||||
} catch (ExpressionException e) {
|
} catch (ExpressionException e) {
|
||||||
|
@ -21,16 +21,17 @@ package com.sk89q.worldedit.extension.platform;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.NotABlockException;
|
import com.sk89q.worldedit.NotABlockException;
|
||||||
import com.sk89q.worldedit.PlayerDirection;
|
import com.sk89q.worldedit.PlayerDirection;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.TargetBlock;
|
import com.sk89q.worldedit.util.TargetBlock;
|
||||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -105,7 +106,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
byte free = 0;
|
byte free = 0;
|
||||||
|
|
||||||
while (y <= world.getMaximumPoint().getBlockY() + 2) {
|
while (y <= world.getMaximumPoint().getBlockY() + 2) {
|
||||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
++free;
|
++free;
|
||||||
} else {
|
} else {
|
||||||
free = 0;
|
free = 0;
|
||||||
@ -113,7 +114,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
|
|
||||||
if (free == 2) {
|
if (free == 2) {
|
||||||
if (y - 1 != origY) {
|
if (y - 1 != origY) {
|
||||||
setPosition(new Vector(x + 0.5, y - 2 + 1, z + 0.5));
|
setPosition(new Vector3(x + 0.5, y - 2 + 1, z + 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -131,10 +132,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
int z = searchPos.getBlockZ();
|
int z = searchPos.getBlockZ();
|
||||||
|
|
||||||
while (y >= 0) {
|
while (y >= 0) {
|
||||||
final Vector pos = new Vector(x, y, z);
|
final BlockVector3 pos = new BlockVector3(x, y, z);
|
||||||
final BlockState id = world.getBlock(pos);
|
final BlockState id = world.getBlock(pos);
|
||||||
if (id.getBlockType().getMaterial().isMovementBlocker()) {
|
if (id.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
setPosition(new Vector(x + 0.5, y + 1, z + 0.5));
|
setPosition(new Vector3(x + 0.5, y + 1, z + 0.5));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +160,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
byte spots = 0;
|
byte spots = 0;
|
||||||
|
|
||||||
while (y <= world.getMaximumPoint().getY() + 2) {
|
while (y <= world.getMaximumPoint().getY() + 2) {
|
||||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
++free;
|
++free;
|
||||||
} else {
|
} else {
|
||||||
free = 0;
|
free = 0;
|
||||||
@ -168,7 +169,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
if (free == 2) {
|
if (free == 2) {
|
||||||
++spots;
|
++spots;
|
||||||
if (spots == 2) {
|
if (spots == 2) {
|
||||||
final Vector platform = new Vector(x, y - 2, z);
|
final BlockVector3 platform = new BlockVector3(x, y - 2, z);
|
||||||
final BlockStateHolder block = world.getBlock(platform);
|
final BlockStateHolder block = world.getBlock(platform);
|
||||||
final com.sk89q.worldedit.world.block.BlockType type = block.getBlockType();
|
final com.sk89q.worldedit.world.block.BlockType type = block.getBlockType();
|
||||||
|
|
||||||
@ -177,7 +178,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(platform.add(0.5, 1, 0.5));
|
setPosition(platform.toVector3().add(0.5, 1, 0.5));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +200,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
byte free = 0;
|
byte free = 0;
|
||||||
|
|
||||||
while (y >= 1) {
|
while (y >= 1) {
|
||||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
++free;
|
++free;
|
||||||
} else {
|
} else {
|
||||||
free = 0;
|
free = 0;
|
||||||
@ -210,14 +211,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
// lightly and also check to see if there's something to
|
// lightly and also check to see if there's something to
|
||||||
// stand upon
|
// stand upon
|
||||||
while (y >= 0) {
|
while (y >= 0) {
|
||||||
final Vector platform = new Vector(x, y, z);
|
final BlockVector3 platform = new BlockVector3(x, y, z);
|
||||||
final BlockStateHolder block = world.getBlock(platform);
|
final BlockStateHolder block = world.getBlock(platform);
|
||||||
final BlockType type = block.getBlockType();
|
final BlockType type = block.getBlockType();
|
||||||
|
|
||||||
// Don't want to end up in lava
|
// Don't want to end up in lava
|
||||||
if (!type.getMaterial().isAir() && type != BlockTypes.LAVA) {
|
if (!type.getMaterial().isAir() && type != BlockTypes.LAVA) {
|
||||||
// Found a block!
|
// Found a block!
|
||||||
setPosition(platform.add(0.5, 1, 0.5));
|
setPosition(platform.toVector3().add(0.5, 1, 0.5));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,13 +249,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
Extent world = getLocation().getExtent();
|
Extent world = getLocation().getExtent();
|
||||||
|
|
||||||
// No free space above
|
// No free space above
|
||||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isAir()) {
|
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (y <= world.getMaximumPoint().getY()) {
|
while (y <= world.getMaximumPoint().getY()) {
|
||||||
// Found a ceiling!
|
// Found a ceiling!
|
||||||
if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
int platformY = Math.max(initialY, y - 3 - clearance);
|
int platformY = Math.max(initialY, y - 3 - clearance);
|
||||||
floatAt(x, platformY + 1, z, alwaysGlass);
|
floatAt(x, platformY + 1, z, alwaysGlass);
|
||||||
return true;
|
return true;
|
||||||
@ -282,7 +283,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
final Extent world = getLocation().getExtent();
|
final Extent world = getLocation().getExtent();
|
||||||
|
|
||||||
while (y <= world.getMaximumPoint().getY() + 2) {
|
while (y <= world.getMaximumPoint().getY() + 2) {
|
||||||
if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
break; // Hit something
|
break; // Hit something
|
||||||
} else if (y > maxY + 1) {
|
} else if (y > maxY + 1) {
|
||||||
break;
|
break;
|
||||||
@ -300,24 +301,24 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
@Override
|
@Override
|
||||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
||||||
try {
|
try {
|
||||||
Vector spot = new Vector(x, y - 1, z);
|
BlockVector3 spot = new BlockVector3(x, y - 1, z);
|
||||||
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
|
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState());
|
getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState());
|
||||||
}
|
}
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setPosition(new Vector(x + 0.5, y, z + 0.5));
|
setPosition(new Vector3(x + 0.5, y, z + 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getBlockIn() {
|
public Location getBlockIn() {
|
||||||
return getLocation().setPosition(getLocation().toVector().toBlockVector());
|
return getLocation().setPosition(getLocation().toVector().floor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getBlockOn() {
|
public Location getBlockOn() {
|
||||||
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().toBlockVector());
|
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -392,7 +393,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
boolean inFree = false;
|
boolean inFree = false;
|
||||||
|
|
||||||
while ((block = hitBlox.getNextBlock()) != null) {
|
while ((block = hitBlox.getNextBlock()) != null) {
|
||||||
boolean free = !world.getBlock(block.toVector()).getBlockType().getMaterial().isMovementBlocker();
|
boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType().getMaterial().isMovementBlocker();
|
||||||
|
|
||||||
if (firstBlock) {
|
if (firstBlock) {
|
||||||
firstBlock = false;
|
firstBlock = false;
|
||||||
@ -426,7 +427,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPosition(Vector pos) {
|
public void setPosition(Vector3 pos) {
|
||||||
setPosition(pos, getLocation().getPitch(), getLocation().getYaw());
|
setPosition(pos, getLocation().getPitch(), getLocation().getYaw());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +500,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendFakeBlock(Vector pos, BlockStateHolder block) {
|
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.command.tool.BlockTool;
|
import com.sk89q.worldedit.command.tool.BlockTool;
|
||||||
import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
|
import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
|
||||||
@ -38,6 +37,8 @@ import com.sk89q.worldedit.event.platform.PlatformInitializeEvent;
|
|||||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||||
import com.sk89q.worldedit.event.platform.PlayerInputEvent;
|
import com.sk89q.worldedit.event.platform.PlayerInputEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
@ -302,7 +303,7 @@ public class PlatformManager {
|
|||||||
Actor actor = createProxyActor(event.getCause());
|
Actor actor = createProxyActor(event.getCause());
|
||||||
|
|
||||||
Location location = event.getLocation();
|
Location location = event.getLocation();
|
||||||
Vector vector = location.toVector();
|
Vector3 vector = location.toVector();
|
||||||
|
|
||||||
// At this time, only handle interaction from players
|
// At this time, only handle interaction from players
|
||||||
if (actor instanceof Player) {
|
if (actor instanceof Player) {
|
||||||
@ -321,8 +322,9 @@ public class PlatformManager {
|
|||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
|
|
||||||
if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) {
|
BlockVector3 blockPoint = vector.toBlockPoint();
|
||||||
selector.explainPrimarySelection(actor, session, vector);
|
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
|
selector.explainPrimarySelection(actor, session, blockPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -356,8 +358,9 @@ public class PlatformManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) {
|
BlockVector3 blockPoint = vector.toBlockPoint();
|
||||||
selector.explainSecondarySelection(actor, session, vector);
|
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
|
selector.explainSecondarySelection(actor, session, blockPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -21,12 +21,13 @@ package com.sk89q.worldedit.extension.platform;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.session.SessionKey;
|
import com.sk89q.worldedit.session.SessionKey;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
@ -92,7 +93,7 @@ class PlayerProxy extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||||
basePlayer.setPosition(pos, pitch, yaw);
|
basePlayer.setPosition(pos, pitch, yaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +159,7 @@ class PlayerProxy extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendFakeBlock(Vector pos, BlockStateHolder block) {
|
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
|
||||||
basePlayer.sendFakeBlock(pos, block);
|
basePlayer.sendFakeBlock(pos, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,17 @@ package com.sk89q.worldedit.extent;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -66,17 +66,17 @@ public abstract class AbstractDelegateExtent implements Extent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(Vector position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return extent.getBlock(position);
|
return extent.getBlock(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(Vector position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return extent.getFullBlock(position);
|
return extent.getFullBlock(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
return extent.setBlock(location, block);
|
return extent.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,22 +97,22 @@ public abstract class AbstractDelegateExtent implements Extent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(Vector2D position) {
|
public BaseBiome getBiome(BlockVector2 position) {
|
||||||
return extent.getBiome(position);
|
return extent.getBiome(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||||
return extent.setBiome(position, biome);
|
return extent.setBiome(position, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
return extent.getMinimumPoint();
|
return extent.getMinimumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
return extent.getMaximumPoint();
|
return extent.getMaximumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,17 +21,17 @@ package com.sk89q.worldedit.extent;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.history.change.BlockChange;
|
import com.sk89q.worldedit.history.change.BlockChange;
|
||||||
import com.sk89q.worldedit.history.change.EntityCreate;
|
import com.sk89q.worldedit.history.change.EntityCreate;
|
||||||
import com.sk89q.worldedit.history.change.EntityRemove;
|
import com.sk89q.worldedit.history.change.EntityRemove;
|
||||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -59,9 +59,9 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
BaseBlock previous = getFullBlock(location);
|
BaseBlock previous = getFullBlock(location);
|
||||||
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
changeSet.add(new BlockChange(location, previous, block));
|
||||||
return super.setBlock(location, block);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
*
|
*
|
||||||
* @return the minimum point
|
* @return the minimum point
|
||||||
*/
|
*/
|
||||||
Vector getMinimumPoint();
|
BlockVector3 getMinimumPoint();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum point in the extent.
|
* Get the maximum point in the extent.
|
||||||
@ -56,7 +56,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
*
|
*
|
||||||
* @return the maximum point
|
* @return the maximum point
|
||||||
*/
|
*/
|
||||||
Vector getMaximumPoint();
|
BlockVector3 getMaximumPoint();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all entities within the given region.
|
* Get a list of all entities within the given region.
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +45,7 @@ public interface InputExtent {
|
|||||||
* @param position position of the block
|
* @param position position of the block
|
||||||
* @return the block
|
* @return the block
|
||||||
*/
|
*/
|
||||||
BlockState getBlock(Vector position);
|
BlockState getBlock(BlockVector3 position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a immutable snapshot of the block at the given location.
|
* Get a immutable snapshot of the block at the given location.
|
||||||
@ -53,7 +53,7 @@ public interface InputExtent {
|
|||||||
* @param position position of the block
|
* @param position position of the block
|
||||||
* @return the block
|
* @return the block
|
||||||
*/
|
*/
|
||||||
BaseBlock getFullBlock(Vector position);
|
BaseBlock getFullBlock(BlockVector3 position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the biome at the given location.
|
* Get the biome at the given location.
|
||||||
@ -64,6 +64,6 @@ public interface InputExtent {
|
|||||||
* @param position the (x, z) location to check the biome at
|
* @param position the (x, z) location to check the biome at
|
||||||
* @return the biome at the location
|
* @return the biome at the location
|
||||||
*/
|
*/
|
||||||
BaseBiome getBiome(Vector2D position);
|
BaseBiome getBiome(BlockVector2 position);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.extent;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +65,7 @@ public class MaskingExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
return mask.test(location) && super.setBlock(location, block);
|
return mask.test(location) && super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,16 +19,16 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -44,16 +44,14 @@ import javax.annotation.Nullable;
|
|||||||
*/
|
*/
|
||||||
public class NullExtent implements Extent {
|
public class NullExtent implements Extent {
|
||||||
|
|
||||||
private final Vector nullPoint = new Vector(0, 0, 0);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
return nullPoint;
|
return BlockVector3.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
return nullPoint;
|
return BlockVector3.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,28 +71,28 @@ public class NullExtent implements Extent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(Vector position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return BlockTypes.AIR.getDefaultState();
|
return BlockTypes.AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(Vector position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return getBlock(position).toBaseBlock();
|
return getBlock(position).toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(Vector2D position) {
|
public BaseBiome getBiome(BlockVector2 position) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public interface OutputExtent {
|
|||||||
* @return true if the block was successfully set (return value may not be accurate)
|
* @return true if the block was successfully set (return value may not be accurate)
|
||||||
* @throws WorldEditException thrown on an error
|
* @throws WorldEditException thrown on an error
|
||||||
*/
|
*/
|
||||||
boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException;
|
boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the biome.
|
* Set the biome.
|
||||||
@ -59,7 +59,7 @@ public interface OutputExtent {
|
|||||||
* @param biome the biome to set to
|
* @param biome the biome to set to
|
||||||
* @return true if the biome was successfully set (return value may not be accurate)
|
* @return true if the biome was successfully set (return value may not be accurate)
|
||||||
*/
|
*/
|
||||||
boolean setBiome(Vector2D position, BaseBiome biome);
|
boolean setBiome(BlockVector2 position, BaseBiome biome);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an {@link Operation} that should be called to tie up loose ends
|
* Return an {@link Operation} that should be called to tie up loose ends
|
||||||
|
@ -21,14 +21,14 @@ package com.sk89q.worldedit.extent.buffer;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.Masks;
|
import com.sk89q.worldedit.function.mask.Masks;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||||
@ -44,19 +44,19 @@ import java.util.Map;
|
|||||||
* actual application of the changes.
|
* actual application of the changes.
|
||||||
*
|
*
|
||||||
* <p>This buffer will not attempt to return results from the buffer when
|
* <p>This buffer will not attempt to return results from the buffer when
|
||||||
* accessor methods (such as {@link #getBlock(Vector)}) are called.</p>
|
* accessor methods (such as {@link #getBlock(BlockVector3)}) are called.</p>
|
||||||
*/
|
*/
|
||||||
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
|
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
|
||||||
|
|
||||||
private final Map<BlockVector, BlockStateHolder> buffer = new LinkedHashMap<>();
|
private final Map<BlockVector3, BlockStateHolder> buffer = new LinkedHashMap<>();
|
||||||
private final Mask mask;
|
private final Mask mask;
|
||||||
private Vector min = null;
|
private BlockVector3 min = null;
|
||||||
private Vector max = null;
|
private BlockVector3 max = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new extent buffer that will buffer every change.
|
* Create a new extent buffer that will buffer every change.
|
||||||
*
|
*
|
||||||
* @param delegate the delegate extent for {@link Extent#getBlock(Vector)}, etc. calls
|
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||||
*/
|
*/
|
||||||
public ForgetfulExtentBuffer(Extent delegate) {
|
public ForgetfulExtentBuffer(Extent delegate) {
|
||||||
this(delegate, Masks.alwaysTrue());
|
this(delegate, Masks.alwaysTrue());
|
||||||
@ -66,7 +66,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
* Create a new extent buffer that will buffer changes that meet the criteria
|
* Create a new extent buffer that will buffer changes that meet the criteria
|
||||||
* of the given mask.
|
* of the given mask.
|
||||||
*
|
*
|
||||||
* @param delegate the delegate extent for {@link Extent#getBlock(Vector)}, etc. calls
|
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||||
* @param mask the mask
|
* @param mask the mask
|
||||||
*/
|
*/
|
||||||
public ForgetfulExtentBuffer(Extent delegate, Mask mask) {
|
public ForgetfulExtentBuffer(Extent delegate, Mask mask) {
|
||||||
@ -77,22 +77,22 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
// Update minimum
|
// Update minimum
|
||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = location;
|
min = location;
|
||||||
} else {
|
} else {
|
||||||
min = Vector.getMinimum(min, location);
|
min = min.getMinimum(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update maximum
|
// Update maximum
|
||||||
if (max == null) {
|
if (max == null) {
|
||||||
max = location;
|
max = location;
|
||||||
} else {
|
} else {
|
||||||
max = Vector.getMaximum(max, location);
|
max = max.getMaximum(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockVector blockVector = location.toBlockVector();
|
BlockVector3 blockVector = location;
|
||||||
if (mask.test(blockVector)) {
|
if (mask.test(blockVector)) {
|
||||||
buffer.put(blockVector, block);
|
buffer.put(blockVector, block);
|
||||||
return true;
|
return true;
|
||||||
@ -102,8 +102,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockStateHolder apply(Vector pos) {
|
public BlockStateHolder apply(BlockVector3 pos) {
|
||||||
BlockStateHolder block = buffer.get(pos.toBlockVector());
|
BlockStateHolder block = buffer.get(pos);
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
return block;
|
return block;
|
||||||
} else {
|
} else {
|
||||||
@ -119,32 +119,32 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
public Region asRegion() {
|
public Region asRegion() {
|
||||||
return new AbstractRegion(null) {
|
return new AbstractRegion(null) {
|
||||||
@Override
|
@Override
|
||||||
public Vector getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
return min != null ? min : new Vector();
|
return min != null ? min : BlockVector3.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
return max != null ? max : new Vector();
|
return max != null ? max : BlockVector3.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void expand(Vector... changes) throws RegionOperationException {
|
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||||
throw new UnsupportedOperationException("Cannot change the size of this region");
|
throw new UnsupportedOperationException("Cannot change the size of this region");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contract(Vector... changes) throws RegionOperationException {
|
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||||
throw new UnsupportedOperationException("Cannot change the size of this region");
|
throw new UnsupportedOperationException("Cannot change the size of this region");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Vector position) {
|
public boolean contains(BlockVector3 position) {
|
||||||
return buffer.containsKey(position.toBlockVector());
|
return buffer.containsKey(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<BlockVector> iterator() {
|
public Iterator<BlockVector3> iterator() {
|
||||||
return buffer.keySet().iterator();
|
return buffer.keySet().iterator();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -19,15 +19,15 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.cache;
|
package com.sk89q.worldedit.extent.cache;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the same cached {@link BlockState} for repeated calls to
|
* Returns the same cached {@link BlockState} for repeated calls to
|
||||||
* {@link #getBlock(Vector)} with the same position.
|
* {@link #getBlock(BlockVector3)} with the same position.
|
||||||
*/
|
*/
|
||||||
public class LastAccessExtentCache extends AbstractDelegateExtent {
|
public class LastAccessExtentCache extends AbstractDelegateExtent {
|
||||||
|
|
||||||
@ -43,23 +43,22 @@ public class LastAccessExtentCache extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(Vector position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
BlockVector blockVector = position.toBlockVector();
|
|
||||||
CachedBlock lastBlock = this.lastBlock;
|
CachedBlock lastBlock = this.lastBlock;
|
||||||
if (lastBlock != null && lastBlock.position.equals(blockVector)) {
|
if (lastBlock != null && lastBlock.position.equals(position)) {
|
||||||
return lastBlock.block;
|
return lastBlock.block;
|
||||||
} else {
|
} else {
|
||||||
BlockState block = super.getBlock(position);
|
BlockState block = super.getBlock(position);
|
||||||
this.lastBlock = new CachedBlock(blockVector, block);
|
this.lastBlock = new CachedBlock(position, block);
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CachedBlock {
|
private static class CachedBlock {
|
||||||
private final BlockVector position;
|
private final BlockVector3 position;
|
||||||
private final BlockState block;
|
private final BlockState block;
|
||||||
|
|
||||||
private CachedBlock(BlockVector position, BlockState block) {
|
private CachedBlock(BlockVector3 position, BlockState block) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,16 @@ package com.sk89q.worldedit.extent.clipboard;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -48,7 +48,7 @@ import javax.annotation.Nullable;
|
|||||||
public class BlockArrayClipboard implements Clipboard {
|
public class BlockArrayClipboard implements Clipboard {
|
||||||
|
|
||||||
private final Region region;
|
private final Region region;
|
||||||
private Vector origin;
|
private BlockVector3 origin;
|
||||||
private final BlockStateHolder[][][] blocks;
|
private final BlockStateHolder[][][] blocks;
|
||||||
private final List<ClipboardEntity> entities = new ArrayList<>();
|
private final List<ClipboardEntity> entities = new ArrayList<>();
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
this.region = region.clone();
|
this.region = region.clone();
|
||||||
this.origin = region.getMinimumPoint();
|
this.origin = region.getMinimumPoint();
|
||||||
|
|
||||||
Vector dimensions = getDimensions();
|
BlockVector3 dimensions = getDimensions();
|
||||||
blocks = new BlockStateHolder[dimensions.getBlockX()][dimensions.getBlockY()][dimensions.getBlockZ()];
|
blocks = new BlockStateHolder[dimensions.getBlockX()][dimensions.getBlockY()][dimensions.getBlockZ()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,27 +74,27 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getOrigin() {
|
public BlockVector3 getOrigin() {
|
||||||
return origin;
|
return origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOrigin(Vector origin) {
|
public void setOrigin(BlockVector3 origin) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getDimensions() {
|
public BlockVector3 getDimensions() {
|
||||||
return region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
return region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
return region.getMinimumPoint();
|
return region.getMinimumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
return region.getMaximumPoint();
|
return region.getMaximumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
public List<? extends Entity> getEntities(Region region) {
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
List<Entity> filtered = new ArrayList<>();
|
List<Entity> filtered = new ArrayList<>();
|
||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
if (region.contains(entity.getLocation().toVector())) {
|
if (region.contains(entity.getLocation().toVector().toBlockPoint())) {
|
||||||
filtered.add(entity);
|
filtered.add(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,9 +123,9 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(Vector position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
if (region.contains(position)) {
|
if (region.contains(position)) {
|
||||||
Vector v = position.subtract(region.getMinimumPoint());
|
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||||
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
return block.toImmutableState();
|
return block.toImmutableState();
|
||||||
@ -136,9 +136,9 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(Vector position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
if (region.contains(position)) {
|
if (region.contains(position)) {
|
||||||
Vector v = position.subtract(region.getMinimumPoint());
|
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||||
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
return block.toBaseBlock();
|
return block.toBaseBlock();
|
||||||
@ -149,9 +149,9 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||||
if (region.contains(position)) {
|
if (region.contains(position)) {
|
||||||
Vector v = position.subtract(region.getMinimumPoint());
|
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||||
blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = block;
|
blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = block;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -160,12 +160,12 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(Vector2D position) {
|
public BaseBiome getBiome(BlockVector2 position) {
|
||||||
return new BaseBiome(0);
|
return new BaseBiome(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.clipboard;
|
package com.sk89q.worldedit.extent.clipboard;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,20 +42,20 @@ public interface Clipboard extends Extent {
|
|||||||
*
|
*
|
||||||
* @return the dimensions
|
* @return the dimensions
|
||||||
*/
|
*/
|
||||||
Vector getDimensions();
|
BlockVector3 getDimensions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the origin point from which the copy was made from.
|
* Get the origin point from which the copy was made from.
|
||||||
*
|
*
|
||||||
* @return the origin
|
* @return the origin
|
||||||
*/
|
*/
|
||||||
Vector getOrigin();
|
BlockVector3 getOrigin();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the origin point from which the copy was made from.
|
* Set the origin point from which the copy was made from.
|
||||||
*
|
*
|
||||||
* @param origin the origin
|
* @param origin the origin
|
||||||
*/
|
*/
|
||||||
void setOrigin(Vector origin);
|
void setOrigin(BlockVector3 origin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,13 @@ import com.sk89q.jnbt.NamedTag;
|
|||||||
import com.sk89q.jnbt.ShortTag;
|
import com.sk89q.jnbt.ShortTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.SignCompatibilityHandler;
|
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.SignCompatibilityHandler;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
@ -105,7 +104,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
|||||||
// Metadata
|
// Metadata
|
||||||
// ====================================================================
|
// ====================================================================
|
||||||
|
|
||||||
Vector origin;
|
BlockVector3 origin;
|
||||||
Region region;
|
Region region;
|
||||||
|
|
||||||
// Get information
|
// Get information
|
||||||
@ -117,18 +116,18 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
|||||||
int originX = requireTag(schematic, "WEOriginX", IntTag.class).getValue();
|
int originX = requireTag(schematic, "WEOriginX", IntTag.class).getValue();
|
||||||
int originY = requireTag(schematic, "WEOriginY", IntTag.class).getValue();
|
int originY = requireTag(schematic, "WEOriginY", IntTag.class).getValue();
|
||||||
int originZ = requireTag(schematic, "WEOriginZ", IntTag.class).getValue();
|
int originZ = requireTag(schematic, "WEOriginZ", IntTag.class).getValue();
|
||||||
Vector min = new Vector(originX, originY, originZ);
|
BlockVector3 min = new BlockVector3(originX, originY, originZ);
|
||||||
|
|
||||||
int offsetX = requireTag(schematic, "WEOffsetX", IntTag.class).getValue();
|
int offsetX = requireTag(schematic, "WEOffsetX", IntTag.class).getValue();
|
||||||
int offsetY = requireTag(schematic, "WEOffsetY", IntTag.class).getValue();
|
int offsetY = requireTag(schematic, "WEOffsetY", IntTag.class).getValue();
|
||||||
int offsetZ = requireTag(schematic, "WEOffsetZ", IntTag.class).getValue();
|
int offsetZ = requireTag(schematic, "WEOffsetZ", IntTag.class).getValue();
|
||||||
Vector offset = new Vector(offsetX, offsetY, offsetZ);
|
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
|
||||||
|
|
||||||
origin = min.subtract(offset);
|
origin = min.subtract(offset);
|
||||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
|
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
origin = new Vector(0, 0, 0);
|
origin = BlockVector3.ZERO;
|
||||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE));
|
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================================================================
|
// ====================================================================
|
||||||
@ -162,7 +161,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
|||||||
|
|
||||||
// Need to pull out tile entities
|
// Need to pull out tile entities
|
||||||
List<Tag> tileEntities = requireTag(schematic, "TileEntities", ListTag.class).getValue();
|
List<Tag> tileEntities = requireTag(schematic, "TileEntities", ListTag.class).getValue();
|
||||||
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||||
|
|
||||||
for (Tag tag : tileEntities) {
|
for (Tag tag : tileEntities) {
|
||||||
if (!(tag instanceof CompoundTag)) continue;
|
if (!(tag instanceof CompoundTag)) continue;
|
||||||
@ -206,7 +205,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockVector vec = new BlockVector(x, y, z);
|
BlockVector3 vec = new BlockVector3(x, y, z);
|
||||||
tileEntitiesMap.put(vec, values);
|
tileEntitiesMap.put(vec, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +219,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
|||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
for (int z = 0; z < length; ++z) {
|
for (int z = 0; z < length; ++z) {
|
||||||
int index = y * width * length + z * width + x;
|
int index = y * width * length + z * width + x;
|
||||||
BlockVector pt = new BlockVector(x, y, z);
|
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||||
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
|
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -31,8 +31,6 @@ import com.sk89q.jnbt.NBTInputStream;
|
|||||||
import com.sk89q.jnbt.NamedTag;
|
import com.sk89q.jnbt.NamedTag;
|
||||||
import com.sk89q.jnbt.ShortTag;
|
import com.sk89q.jnbt.ShortTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
@ -40,6 +38,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -96,7 +95,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Clipboard readVersion1(Map<String, Tag> schematic) throws IOException {
|
private Clipboard readVersion1(Map<String, Tag> schematic) throws IOException {
|
||||||
Vector origin;
|
BlockVector3 origin;
|
||||||
Region region;
|
Region region;
|
||||||
|
|
||||||
Map<String, Tag> metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue();
|
Map<String, Tag> metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue();
|
||||||
@ -110,19 +109,19 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
throw new IOException("Invalid offset specified in schematic.");
|
throw new IOException("Invalid offset specified in schematic.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector min = new Vector(offsetParts[0], offsetParts[1], offsetParts[2]);
|
BlockVector3 min = new BlockVector3(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||||
|
|
||||||
if (metadata.containsKey("WEOffsetX")) {
|
if (metadata.containsKey("WEOffsetX")) {
|
||||||
// We appear to have WorldEdit Metadata
|
// We appear to have WorldEdit Metadata
|
||||||
int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
|
int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
|
||||||
int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
|
int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
|
||||||
int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
|
int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
|
||||||
Vector offset = new Vector(offsetX, offsetY, offsetZ);
|
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
|
||||||
origin = min.subtract(offset);
|
origin = min.subtract(offset);
|
||||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
|
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||||
} else {
|
} else {
|
||||||
origin = min;
|
origin = min;
|
||||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE));
|
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
int paletteMax = requireTag(schematic, "PaletteMax", IntTag.class).getValue();
|
int paletteMax = requireTag(schematic, "PaletteMax", IntTag.class).getValue();
|
||||||
@ -151,7 +150,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
|
|
||||||
byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
|
byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
|
||||||
|
|
||||||
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
List<Map<String, Tag>> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream()
|
List<Map<String, Tag>> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream()
|
||||||
.map(tag -> (CompoundTag) tag)
|
.map(tag -> (CompoundTag) tag)
|
||||||
@ -160,7 +159,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
|
|
||||||
for (Map<String, Tag> tileEntity : tileEntityTags) {
|
for (Map<String, Tag> tileEntity : tileEntityTags) {
|
||||||
int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
|
int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
|
||||||
tileEntitiesMap.put(new BlockVector(pos[0], pos[1], pos[2]).toBlockVector(), tileEntity);
|
tileEntitiesMap.put(new BlockVector3(pos[0], pos[1], pos[2]), tileEntity);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IOException("Failed to load Tile Entities: " + e.getMessage());
|
throw new IOException("Failed to load Tile Entities: " + e.getMessage());
|
||||||
@ -193,7 +192,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
int z = (index % (width * length)) / width;
|
int z = (index % (width * length)) / width;
|
||||||
int x = (index % (width * length)) % width;
|
int x = (index % (width * length)) % width;
|
||||||
BlockState state = palette.get(value);
|
BlockState state = palette.get(value);
|
||||||
BlockVector pt = new BlockVector(x, y, z);
|
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||||
try {
|
try {
|
||||||
if (tileEntitiesMap.containsKey(pt)) {
|
if (tileEntitiesMap.containsKey(pt)) {
|
||||||
Map<String, Tag> values = Maps.newHashMap(tileEntitiesMap.get(pt));
|
Map<String, Tag> values = Maps.newHashMap(tileEntitiesMap.get(pt));
|
||||||
|
@ -30,11 +30,10 @@ import com.sk89q.jnbt.NBTOutputStream;
|
|||||||
import com.sk89q.jnbt.ShortTag;
|
import com.sk89q.jnbt.ShortTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -76,9 +75,9 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
*/
|
*/
|
||||||
private Map<String, Tag> write1(Clipboard clipboard) throws IOException {
|
private Map<String, Tag> write1(Clipboard clipboard) throws IOException {
|
||||||
Region region = clipboard.getRegion();
|
Region region = clipboard.getRegion();
|
||||||
Vector origin = clipboard.getOrigin();
|
BlockVector3 origin = clipboard.getOrigin();
|
||||||
Vector min = region.getMinimumPoint();
|
BlockVector3 min = region.getMinimumPoint();
|
||||||
Vector offset = min.subtract(origin);
|
BlockVector3 offset = min.subtract(origin);
|
||||||
int width = region.getWidth();
|
int width = region.getWidth();
|
||||||
int height = region.getHeight();
|
int height = region.getHeight();
|
||||||
int length = region.getLength();
|
int length = region.getLength();
|
||||||
@ -127,7 +126,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
int z0 = min.getBlockZ() + z;
|
int z0 = min.getBlockZ() + z;
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
int x0 = min.getBlockX() + x;
|
int x0 = min.getBlockX() + x;
|
||||||
BlockVector point = new BlockVector(x0, y0, z0);
|
BlockVector3 point = new BlockVector3(x0, y0, z0);
|
||||||
BaseBlock block = clipboard.getFullBlock(point);
|
BaseBlock block = clipboard.getFullBlock(point);
|
||||||
if (block.getNbtData() != null) {
|
if (block.getNbtData() != null) {
|
||||||
Map<String, Tag> values = new HashMap<>();
|
Map<String, Tag> values = new HashMap<>();
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.inventory;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -82,7 +82,7 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||||
if (blockBag != null) {
|
if (blockBag != null) {
|
||||||
BlockState existing = getExtent().getBlock(position);
|
BlockState existing = getExtent().getBlock(position);
|
||||||
|
|
||||||
|
@ -19,15 +19,14 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.reorder;
|
package com.sk89q.worldedit.extent.reorder;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.RunContext;
|
import com.sk89q.worldedit.function.operation.RunContext;
|
||||||
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.collection.LocatedBlockList;
|
import com.sk89q.worldedit.util.collection.LocatedBlockList;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -49,11 +48,11 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent {
|
|||||||
* Comparator optimized for sorting chunks by the region file they reside
|
* Comparator optimized for sorting chunks by the region file they reside
|
||||||
* in. This allows for file caches to be used while loading the chunk.
|
* in. This allows for file caches to be used while loading the chunk.
|
||||||
*/
|
*/
|
||||||
private static final Comparator<Vector2D> REGION_OPTIMIZED_SORT =
|
private static final Comparator<BlockVector2> REGION_OPTIMIZED_SORT =
|
||||||
Comparator.<Vector2D, Vector2D>comparing(vec -> vec.divide(32).floor(), Vector2D.COMPARING_GRID_ARRANGEMENT)
|
Comparator.comparing((BlockVector2 vec) -> vec.divide(32), BlockVector2.COMPARING_GRID_ARRANGEMENT)
|
||||||
.thenComparing(Vector2D.COMPARING_GRID_ARRANGEMENT);
|
.thenComparing(BlockVector2.COMPARING_GRID_ARRANGEMENT);
|
||||||
|
|
||||||
private final SortedMap<BlockVector2D, LocatedBlockList> batches = new TreeMap<>(REGION_OPTIMIZED_SORT);
|
private final SortedMap<BlockVector2, LocatedBlockList> batches = new TreeMap<>(REGION_OPTIMIZED_SORT);
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
public ChunkBatchingExtent(Extent extent) {
|
public ChunkBatchingExtent(Extent extent) {
|
||||||
@ -74,11 +73,11 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return getExtent().setBlock(location, block);
|
return getExtent().setBlock(location, block);
|
||||||
}
|
}
|
||||||
BlockVector2D chunkPos = new BlockVector2D(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
BlockVector2 chunkPos = new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||||
batches.computeIfAbsent(chunkPos, k -> new LocatedBlockList()).add(location, block);
|
batches.computeIfAbsent(chunkPos, k -> new LocatedBlockList()).add(location, block);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
package com.sk89q.worldedit.extent.reorder;
|
package com.sk89q.worldedit.extent.reorder;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.Blocks;
|
import com.sk89q.worldedit.blocks.Blocks;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
@ -30,6 +28,7 @@ import com.sk89q.worldedit.function.operation.Operation;
|
|||||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||||
import com.sk89q.worldedit.function.operation.RunContext;
|
import com.sk89q.worldedit.function.operation.RunContext;
|
||||||
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.LocatedBlock;
|
import com.sk89q.worldedit.util.LocatedBlock;
|
||||||
import com.sk89q.worldedit.util.collection.LocatedBlockList;
|
import com.sk89q.worldedit.util.collection.LocatedBlockList;
|
||||||
@ -95,7 +94,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
BlockState existing = getBlock(location);
|
BlockState existing = getBlock(location);
|
||||||
|
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
@ -104,18 +103,18 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
|||||||
|
|
||||||
if (Blocks.shouldPlaceLast(block.getBlockType())) {
|
if (Blocks.shouldPlaceLast(block.getBlockType())) {
|
||||||
// Place torches, etc. last
|
// Place torches, etc. last
|
||||||
stage2.add(location.toBlockVector(), block);
|
stage2.add(location, block);
|
||||||
return !existing.equalsFuzzy(block);
|
return !existing.equalsFuzzy(block);
|
||||||
} else if (Blocks.shouldPlaceFinal(block.getBlockType())) {
|
} else if (Blocks.shouldPlaceFinal(block.getBlockType())) {
|
||||||
// Place signs, reed, etc even later
|
// Place signs, reed, etc even later
|
||||||
stage3.add(location.toBlockVector(), block);
|
stage3.add(location, block);
|
||||||
return !existing.equalsFuzzy(block);
|
return !existing.equalsFuzzy(block);
|
||||||
} else if (Blocks.shouldPlaceLast(existing.getBlockType())) {
|
} else if (Blocks.shouldPlaceLast(existing.getBlockType())) {
|
||||||
// Destroy torches, etc. first
|
// Destroy torches, etc. first
|
||||||
super.setBlock(location, BlockTypes.AIR.getDefaultState());
|
super.setBlock(location, BlockTypes.AIR.getDefaultState());
|
||||||
return super.setBlock(location, block);
|
return super.setBlock(location, block);
|
||||||
} else {
|
} else {
|
||||||
stage1.add(location.toBlockVector(), block);
|
stage1.add(location, block);
|
||||||
return !existing.equalsFuzzy(block);
|
return !existing.equalsFuzzy(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,21 +134,21 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
|||||||
public Operation resume(RunContext run) throws WorldEditException {
|
public Operation resume(RunContext run) throws WorldEditException {
|
||||||
Extent extent = getExtent();
|
Extent extent = getExtent();
|
||||||
|
|
||||||
final Set<BlockVector> blocks = new HashSet<>();
|
final Set<BlockVector3> blocks = new HashSet<>();
|
||||||
final Map<BlockVector, BlockStateHolder> blockTypes = new HashMap<>();
|
final Map<BlockVector3, BlockStateHolder> blockTypes = new HashMap<>();
|
||||||
for (LocatedBlock entry : stage3) {
|
for (LocatedBlock entry : stage3) {
|
||||||
final BlockVector pt = entry.getLocation().toBlockVector();
|
final BlockVector3 pt = entry.getLocation();
|
||||||
blocks.add(pt);
|
blocks.add(pt);
|
||||||
blockTypes.put(pt, entry.getBlock());
|
blockTypes.put(pt, entry.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!blocks.isEmpty()) {
|
while (!blocks.isEmpty()) {
|
||||||
BlockVector current = blocks.iterator().next();
|
BlockVector3 current = blocks.iterator().next();
|
||||||
if (!blocks.contains(current)) {
|
if (!blocks.contains(current)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Deque<BlockVector> walked = new LinkedList<>();
|
final Deque<BlockVector3> walked = new LinkedList<>();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
walked.addFirst(current);
|
walked.addFirst(current);
|
||||||
@ -162,13 +161,13 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
|||||||
Property<Object> halfProperty = blockStateHolder.getBlockType().getProperty("half");
|
Property<Object> halfProperty = blockStateHolder.getBlockType().getProperty("half");
|
||||||
if (blockStateHolder.getState(halfProperty).equals("lower")) {
|
if (blockStateHolder.getState(halfProperty).equals("lower")) {
|
||||||
// Deal with lower door halves being attached to the floor AND the upper half
|
// Deal with lower door halves being attached to the floor AND the upper half
|
||||||
BlockVector upperBlock = current.add(0, 1, 0).toBlockVector();
|
BlockVector3 upperBlock = current.add(0, 1, 0);
|
||||||
if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) {
|
if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) {
|
||||||
walked.addFirst(upperBlock);
|
walked.addFirst(upperBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (BlockCategories.RAILS.contains(blockStateHolder.getBlockType())) {
|
} else if (BlockCategories.RAILS.contains(blockStateHolder.getBlockType())) {
|
||||||
BlockVector lowerBlock = current.add(0, -1, 0).toBlockVector();
|
BlockVector3 lowerBlock = current.add(0, -1, 0);
|
||||||
if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) {
|
if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) {
|
||||||
walked.addFirst(lowerBlock);
|
walked.addFirst(lowerBlock);
|
||||||
}
|
}
|
||||||
@ -192,7 +191,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BlockVector pt : walked) {
|
for (BlockVector3 pt : walked) {
|
||||||
extent.setBlock(pt, blockTypes.get(pt));
|
extent.setBlock(pt, blockTypes.get(pt));
|
||||||
blocks.remove(pt);
|
blocks.remove(pt);
|
||||||
}
|
}
|
||||||
|
@ -22,16 +22,17 @@ package com.sk89q.worldedit.extent.transform;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
|
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -84,17 +85,17 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(Vector position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return transformBlock(super.getBlock(position), false);
|
return transformBlock(super.getBlock(position), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(Vector position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return transformBlock(super.getFullBlock(position), false);
|
return transformBlock(super.getFullBlock(position), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
return super.setBlock(location, transformBlock(block, true));
|
return super.setBlock(location, transformBlock(block, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
|||||||
if (property instanceof DirectionalProperty) {
|
if (property instanceof DirectionalProperty) {
|
||||||
Direction value = (Direction) block.getState(property);
|
Direction value = (Direction) block.getState(property);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
Vector newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector());
|
Vector3 newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector());
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL));
|
changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL));
|
||||||
}
|
}
|
||||||
@ -171,9 +172,9 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
|||||||
* @return a new state or null if none could be found
|
* @return a new state or null if none could be found
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
private static Vector getNewStateValue(DirectionalProperty state, Transform transform, Vector oldDirection) {
|
private static Vector3 getNewStateValue(DirectionalProperty state, Transform transform, Vector3 oldDirection) {
|
||||||
Vector newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector.ZERO)).normalize();
|
Vector3 newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||||
Vector newValue = null;
|
Vector3 newValue = null;
|
||||||
double closest = -2;
|
double closest = -2;
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ package com.sk89q.worldedit.extent.validation;
|
|||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +77,7 @@ public class BlockChangeLimiter extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
if (limit >= 0) {
|
if (limit >= 0) {
|
||||||
if (count >= limit) {
|
if (count >= limit) {
|
||||||
throw new MaxChangedBlocksException(limit);
|
throw new MaxChangedBlocksException(limit);
|
||||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.validation;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -49,7 +49,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
final int y = location.getBlockY();
|
final int y = location.getBlockY();
|
||||||
final BlockType type = block.getBlockType();
|
final BlockType type = block.getBlockType();
|
||||||
if (y < 0 || y > world.getMaxY()) {
|
if (y < 0 || y > world.getMaxY()) {
|
||||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -51,7 +51,7 @@ public class BlockQuirkExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||||
BlockType existing = getExtent().getBlock(position).getBlockType();
|
BlockType existing = getExtent().getBlock(position).getBlockType();
|
||||||
|
|
||||||
if (existing.getMaterial().hasContainer()) {
|
if (existing.getMaterial().hasContainer()) {
|
||||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
world.checkLoadedChunk(location);
|
world.checkLoadedChunk(location);
|
||||||
return super.setBlock(location, block);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.extent.world;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.RunContext;
|
import com.sk89q.worldedit.function.operation.RunContext;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ import java.util.Set;
|
|||||||
public class FastModeExtent extends AbstractDelegateExtent {
|
public class FastModeExtent extends AbstractDelegateExtent {
|
||||||
|
|
||||||
private final World world;
|
private final World world;
|
||||||
private final Set<BlockVector2D> dirtyChunks = new HashSet<>();
|
private final Set<BlockVector2> dirtyChunks = new HashSet<>();
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,9 +84,9 @@ public class FastModeExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
dirtyChunks.add(new BlockVector2D(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
dirtyChunks.add(new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||||
return world.setBlock(location, block, false);
|
return world.setBlock(location, block, false);
|
||||||
} else {
|
} else {
|
||||||
return world.setBlock(location, block, true);
|
return world.setBlock(location, block, true);
|
||||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
if (toolUse && block.getBlockType().getMaterial().isAir()) {
|
if (toolUse && block.getBlockType().getMaterial().isAir()) {
|
||||||
world.simulateBlockMine(location);
|
world.simulateBlockMine(location);
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -81,7 +81,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
for (RegionFunction function : functions) {
|
for (RegionFunction function : functions) {
|
||||||
if (function.apply(position)) {
|
if (function.apply(position)) {
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function;
|
package com.sk89q.worldedit.function;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.regions.FlatRegion;
|
import com.sk89q.worldedit.regions.FlatRegion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,6 +36,6 @@ public interface FlatRegionFunction {
|
|||||||
* @return true if something was changed
|
* @return true if something was changed
|
||||||
* @throws WorldEditException thrown on an error
|
* @throws WorldEditException thrown on an error
|
||||||
*/
|
*/
|
||||||
boolean apply(Vector2D position) throws WorldEditException;
|
boolean apply(BlockVector2 position) throws WorldEditException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.function;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes calls to {@link #apply(com.sk89q.worldedit.Vector2D)} to the
|
* Passes calls to {@link #apply(BlockVector2)} to the
|
||||||
* delegate {@link com.sk89q.worldedit.function.FlatRegionFunction} if they
|
* delegate {@link com.sk89q.worldedit.function.FlatRegionFunction} if they
|
||||||
* match the given mask.
|
* match the given mask.
|
||||||
*/
|
*/
|
||||||
@ -50,7 +50,7 @@ public class FlatRegionMaskingFilter implements FlatRegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector2D position) throws WorldEditException {
|
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||||
return mask.test(position) && function.apply(position);
|
return mask.test(position) && function.apply(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.function;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a {@link RegionFunction} to the first ground block.
|
* Applies a {@link RegionFunction} to the first ground block.
|
||||||
@ -76,12 +76,12 @@ public class GroundFunction implements LayerFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGround(Vector position) {
|
public boolean isGround(BlockVector3 position) {
|
||||||
return mask.test(position);
|
return mask.test(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
if (function.apply(position)) {
|
if (function.apply(position)) {
|
||||||
affected++;
|
affected++;
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function;
|
package com.sk89q.worldedit.function;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that takes a position and a depth.
|
* A function that takes a position and a depth.
|
||||||
@ -35,7 +35,7 @@ public interface LayerFunction {
|
|||||||
* @param position return whether the given block is the ground
|
* @param position return whether the given block is the ground
|
||||||
* @return true if the search should stop
|
* @return true if the search should stop
|
||||||
*/
|
*/
|
||||||
boolean isGround(Vector position);
|
boolean isGround(BlockVector3 position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the function to the given position.
|
* Apply the function to the given position.
|
||||||
@ -48,5 +48,5 @@ public interface LayerFunction {
|
|||||||
* @return true whether this method should be called for further layers
|
* @return true whether this method should be called for further layers
|
||||||
* @throws WorldEditException thrown on an error
|
* @throws WorldEditException thrown on an error
|
||||||
*/
|
*/
|
||||||
boolean apply(Vector position, int depth) throws WorldEditException;
|
boolean apply(BlockVector3 position, int depth) throws WorldEditException;
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function;
|
package com.sk89q.worldedit.function;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a function on points in a region.
|
* Performs a function on points in a region.
|
||||||
@ -34,6 +34,6 @@ public interface RegionFunction {
|
|||||||
* @return true if something was changed
|
* @return true if something was changed
|
||||||
* @throws WorldEditException thrown on an error
|
* @throws WorldEditException thrown on an error
|
||||||
*/
|
*/
|
||||||
boolean apply(Vector position) throws WorldEditException;
|
boolean apply(BlockVector3 position) throws WorldEditException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.function;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes calls to {@link #apply(com.sk89q.worldedit.Vector)} to the
|
* Passes calls to {@link #apply(BlockVector3)} to the
|
||||||
* delegate {@link com.sk89q.worldedit.function.RegionFunction} if they
|
* delegate {@link com.sk89q.worldedit.function.RegionFunction} if they
|
||||||
* match the given mask.
|
* match the given mask.
|
||||||
*/
|
*/
|
||||||
@ -49,7 +49,7 @@ public class RegionMaskingFilter implements RegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
return mask.test(position) && function.apply(position);
|
return mask.test(position) && function.apply(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.function.biome;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,7 +49,7 @@ public class BiomeReplace implements FlatRegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector2D position) throws WorldEditException {
|
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||||
return extent.setBiome(position, biome);
|
return extent.setBiome(position, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.block;
|
package com.sk89q.worldedit.function.block;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Countable;
|
import com.sk89q.worldedit.util.Countable;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
@ -47,7 +47,7 @@ public class BlockDistributionCounter implements RegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
BlockStateHolder blk = extent.getBlock(position);
|
BlockStateHolder blk = extent.getBlock(position);
|
||||||
if (fuzzy) {
|
if (fuzzy) {
|
||||||
blk = ((BlockState) blk).toFuzzy();
|
blk = ((BlockState) blk).toFuzzy();
|
||||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.block;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces blocks with a given pattern.
|
* Replaces blocks with a given pattern.
|
||||||
@ -49,7 +49,7 @@ public class BlockReplace implements RegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
return extent.setBlock(position, pattern.apply(position));
|
return extent.setBlock(position, pattern.apply(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,12 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.block;
|
package com.sk89q.worldedit.function.block;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps a count of the number of times that {@link #apply(Vector)} is called.
|
* Keeps a count of the number of times that {@link #apply(BlockVector3)} is
|
||||||
|
* called.
|
||||||
*/
|
*/
|
||||||
public class Counter implements RegionFunction {
|
public class Counter implements RegionFunction {
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ import com.sk89q.worldedit.function.RegionFunction;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
count++;
|
count++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -23,15 +23,16 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.Direction.Flag;
|
import com.sk89q.worldedit.util.Direction.Flag;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies blocks from one extent to another.
|
* Copies blocks from one extent to another.
|
||||||
@ -40,8 +41,8 @@ public class ExtentBlockCopy implements RegionFunction {
|
|||||||
|
|
||||||
private final Extent source;
|
private final Extent source;
|
||||||
private final Extent destination;
|
private final Extent destination;
|
||||||
private final Vector from;
|
private final BlockVector3 from;
|
||||||
private final Vector to;
|
private final BlockVector3 to;
|
||||||
private final Transform transform;
|
private final Transform transform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,7 +54,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
|||||||
* @param to the destination offset
|
* @param to the destination offset
|
||||||
* @param transform a transform to apply to positions (after source offset, before destination offset)
|
* @param transform a transform to apply to positions (after source offset, before destination offset)
|
||||||
*/
|
*/
|
||||||
public ExtentBlockCopy(Extent source, Vector from, Extent destination, Vector to, Transform transform) {
|
public ExtentBlockCopy(Extent source, BlockVector3 from, Extent destination, BlockVector3 to, Transform transform) {
|
||||||
checkNotNull(source);
|
checkNotNull(source);
|
||||||
checkNotNull(from);
|
checkNotNull(from);
|
||||||
checkNotNull(destination);
|
checkNotNull(destination);
|
||||||
@ -67,10 +68,10 @@ public class ExtentBlockCopy implements RegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
BaseBlock block = source.getFullBlock(position);
|
BaseBlock block = source.getFullBlock(position);
|
||||||
Vector orig = position.subtract(from);
|
BlockVector3 orig = position.subtract(from);
|
||||||
Vector transformed = transform.apply(orig);
|
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
|
||||||
|
|
||||||
// Apply transformations to NBT data if necessary
|
// Apply transformations to NBT data if necessary
|
||||||
block = transformNbtData(block);
|
block = transformNbtData(block);
|
||||||
@ -96,7 +97,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
|||||||
Direction direction = MCDirections.fromRotation(rot);
|
Direction direction = MCDirections.fromRotation(rot);
|
||||||
|
|
||||||
if (direction != null) {
|
if (direction != null) {
|
||||||
Vector vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector.ZERO)).normalize();
|
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||||
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
|
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
|
||||||
|
|
||||||
if (newDirection != null) {
|
if (newDirection != null) {
|
||||||
|
@ -22,11 +22,11 @@ package com.sk89q.worldedit.function.block;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.LayerFunction;
|
import com.sk89q.worldedit.function.LayerFunction;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,12 +61,12 @@ public class Naturalizer implements LayerFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGround(Vector position) {
|
public boolean isGround(BlockVector3 position) {
|
||||||
return mask.test(position);
|
return mask.test(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||||
if (mask.test(position)) {
|
if (mask.test(position)) {
|
||||||
affected++;
|
affected++;
|
||||||
switch (depth) {
|
switch (depth) {
|
||||||
|
@ -23,13 +23,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.EntityFunction;
|
import com.sk89q.worldedit.function.EntityFunction;
|
||||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.Direction.Flag;
|
import com.sk89q.worldedit.util.Direction.Flag;
|
||||||
@ -42,8 +43,8 @@ import com.sk89q.worldedit.util.Location;
|
|||||||
public class ExtentEntityCopy implements EntityFunction {
|
public class ExtentEntityCopy implements EntityFunction {
|
||||||
|
|
||||||
private final Extent destination;
|
private final Extent destination;
|
||||||
private final Vector from;
|
private final Vector3 from;
|
||||||
private final Vector to;
|
private final Vector3 to;
|
||||||
private final Transform transform;
|
private final Transform transform;
|
||||||
private boolean removing;
|
private boolean removing;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
* @param to the destination position
|
* @param to the destination position
|
||||||
* @param transform the transformation to apply to both position and orientation
|
* @param transform the transformation to apply to both position and orientation
|
||||||
*/
|
*/
|
||||||
public ExtentEntityCopy(Vector from, Extent destination, Vector to, Transform transform) {
|
public ExtentEntityCopy(Vector3 from, Extent destination, Vector3 to, Transform transform) {
|
||||||
checkNotNull(from);
|
checkNotNull(from);
|
||||||
checkNotNull(destination);
|
checkNotNull(destination);
|
||||||
checkNotNull(to);
|
checkNotNull(to);
|
||||||
@ -91,13 +92,13 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
Location newLocation;
|
Location newLocation;
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
|
|
||||||
Vector pivot = from.round().add(0.5, 0.5, 0.5);
|
Vector3 pivot = from.round().add(0.5, 0.5, 0.5);
|
||||||
Vector newPosition = transform.apply(location.toVector().subtract(pivot));
|
Vector3 newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||||
Vector newDirection;
|
Vector3 newDirection;
|
||||||
|
|
||||||
newDirection = transform.isIdentity() ?
|
newDirection = transform.isIdentity() ?
|
||||||
entity.getLocation().getDirection()
|
entity.getLocation().getDirection()
|
||||||
: transform.apply(location.getDirection()).subtract(transform.apply(Vector.ZERO)).normalize();
|
: transform.apply(location.getDirection()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||||
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
||||||
|
|
||||||
// Some entities store their position data in NBT
|
// Some entities store their position data in NBT
|
||||||
@ -134,8 +135,8 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
boolean hasFacing = tag.containsKey("Facing");
|
boolean hasFacing = tag.containsKey("Facing");
|
||||||
|
|
||||||
if (hasTilePosition) {
|
if (hasTilePosition) {
|
||||||
Vector tilePosition = new Vector(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ"));
|
Vector3 tilePosition = new Vector3(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ"));
|
||||||
Vector newTilePosition = transform.apply(tilePosition.subtract(from)).add(to);
|
BlockVector3 newTilePosition = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint();
|
||||||
|
|
||||||
CompoundTagBuilder builder = tag.createBuilder()
|
CompoundTagBuilder builder = tag.createBuilder()
|
||||||
.putInt("TileX", newTilePosition.getBlockX())
|
.putInt("TileX", newTilePosition.getBlockX())
|
||||||
@ -155,7 +156,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
Direction direction = MCDirections.fromHanging(d);
|
Direction direction = MCDirections.fromHanging(d);
|
||||||
|
|
||||||
if (direction != null) {
|
if (direction != null) {
|
||||||
Vector vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector.ZERO)).normalize();
|
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||||
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL);
|
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL);
|
||||||
|
|
||||||
if (newDirection != null) {
|
if (newDirection != null) {
|
||||||
|
@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.NullExtent;
|
import com.sk89q.worldedit.extent.NullExtent;
|
||||||
@ -32,6 +31,7 @@ import com.sk89q.worldedit.function.EditContext;
|
|||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.RunContext;
|
import com.sk89q.worldedit.function.operation.RunContext;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.NullRegion;
|
import com.sk89q.worldedit.regions.NullRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public class Deform implements Contextual<Operation> {
|
|||||||
private Region region;
|
private Region region;
|
||||||
private String expression;
|
private String expression;
|
||||||
private Mode mode = Mode.UNIT_CUBE;
|
private Mode mode = Mode.UNIT_CUBE;
|
||||||
private Vector offset = new Vector();
|
private Vector3 offset = Vector3.ZERO;
|
||||||
|
|
||||||
public Deform(String expression) {
|
public Deform(String expression) {
|
||||||
this(new NullExtent(), new NullRegion(), expression);
|
this(new NullExtent(), new NullRegion(), expression);
|
||||||
@ -104,11 +104,11 @@ public class Deform implements Contextual<Operation> {
|
|||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getOffset() {
|
public Vector3 getOffset() {
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOffset(Vector offset) {
|
public void setOffset(Vector3 offset) {
|
||||||
checkNotNull(offset, "offset");
|
checkNotNull(offset, "offset");
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
@ -120,31 +120,31 @@ public class Deform implements Contextual<Operation> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation createFromContext(final EditContext context) {
|
public Operation createFromContext(final EditContext context) {
|
||||||
final Vector zero;
|
final Vector3 zero;
|
||||||
Vector unit;
|
Vector3 unit;
|
||||||
|
|
||||||
Region region = firstNonNull(context.getRegion(), this.region);
|
Region region = firstNonNull(context.getRegion(), this.region);
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case UNIT_CUBE:
|
case UNIT_CUBE:
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||||
final Vector max = region.getMaximumPoint();
|
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||||
|
|
||||||
zero = max.add(min).multiply(0.5);
|
zero = max.add(min).multiply(0.5);
|
||||||
unit = max.subtract(zero);
|
unit = max.subtract(zero);
|
||||||
|
|
||||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||||
break;
|
break;
|
||||||
case RAW_COORD:
|
case RAW_COORD:
|
||||||
zero = Vector.ZERO;
|
zero = Vector3.ZERO;
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
break;
|
break;
|
||||||
case OFFSET:
|
case OFFSET:
|
||||||
default:
|
default:
|
||||||
zero = offset;
|
zero = offset;
|
||||||
unit = Vector.ONE;
|
unit = Vector3.ONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DeformOperation(context.getDestination(), region, zero, unit, expression);
|
return new DeformOperation(context.getDestination(), region, zero, unit, expression);
|
||||||
@ -153,11 +153,11 @@ public class Deform implements Contextual<Operation> {
|
|||||||
private static final class DeformOperation implements Operation {
|
private static final class DeformOperation implements Operation {
|
||||||
private final Extent destination;
|
private final Extent destination;
|
||||||
private final Region region;
|
private final Region region;
|
||||||
private final Vector zero;
|
private final Vector3 zero;
|
||||||
private final Vector unit;
|
private final Vector3 unit;
|
||||||
private final String expression;
|
private final String expression;
|
||||||
|
|
||||||
private DeformOperation(Extent destination, Region region, Vector zero, Vector unit, String expression) {
|
private DeformOperation(Extent destination, Region region, Vector3 zero, Vector3 unit, String expression) {
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.region = region;
|
this.region = region;
|
||||||
this.zero = zero;
|
this.zero = zero;
|
||||||
|
@ -20,12 +20,12 @@
|
|||||||
package com.sk89q.worldedit.function.generator;
|
package com.sk89q.worldedit.function.generator;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ public class FloraGenerator implements RegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
BlockStateHolder block = editSession.getBlock(position);
|
BlockStateHolder block = editSession.getBlock(position);
|
||||||
|
|
||||||
if (block.getBlockType() == BlockTypes.GRASS_BLOCK) {
|
if (block.getBlockType() == BlockTypes.GRASS_BLOCK) {
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
package com.sk89q.worldedit.function.generator;
|
package com.sk89q.worldedit.function.generator;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -49,7 +49,7 @@ public class ForestGenerator implements RegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
BlockStateHolder block = editSession.getBlock(position);
|
BlockStateHolder block = editSession.getBlock(position);
|
||||||
BlockType t = block.getBlockType();
|
BlockType t = block.getBlockType();
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.generator;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -84,12 +84,12 @@ public class GardenPatchGenerator implements RegionFunction {
|
|||||||
* @param basePos the base position
|
* @param basePos the base position
|
||||||
* @param pos the vine position
|
* @param pos the vine position
|
||||||
*/
|
*/
|
||||||
private void placeVine(Vector basePos, Vector pos) throws MaxChangedBlocksException {
|
private void placeVine(BlockVector3 basePos, BlockVector3 pos) throws MaxChangedBlocksException {
|
||||||
if (pos.distance(basePos) > 4) return;
|
if (pos.distance(basePos) > 4) return;
|
||||||
if (!editSession.getBlock(pos).getBlockType().getMaterial().isAir()) return;
|
if (!editSession.getBlock(pos).getBlockType().getMaterial().isAir()) return;
|
||||||
|
|
||||||
for (int i = -1; i > -3; --i) {
|
for (int i = -1; i > -3; --i) {
|
||||||
Vector testPos = pos.add(0, i, 0);
|
BlockVector3 testPos = pos.add(0, i, 0);
|
||||||
if (editSession.getBlock(testPos).getBlockType().getMaterial().isAir()) {
|
if (editSession.getBlock(testPos).getBlockType().getMaterial().isAir()) {
|
||||||
pos = testPos;
|
pos = testPos;
|
||||||
} else {
|
} else {
|
||||||
@ -102,7 +102,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
|||||||
|
|
||||||
int t = random.nextInt(4);
|
int t = random.nextInt(4);
|
||||||
int h = random.nextInt(3) - 1;
|
int h = random.nextInt(3) - 1;
|
||||||
Vector p;
|
BlockVector3 p;
|
||||||
|
|
||||||
BlockState log = BlockTypes.OAK_LOG.getDefaultState();
|
BlockState log = BlockTypes.OAK_LOG.getDefaultState();
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
if (!editSession.getBlock(position).getBlockType().getMaterial().isAir()) {
|
if (!editSession.getBlock(position).getBlockType().getMaterial().isAir()) {
|
||||||
position = position.add(0, 1, 0);
|
position = position.add(0, 1, 0);
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
|||||||
* @return if block was changed
|
* @return if block was changed
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
private static boolean setBlockIfAir(EditSession session, Vector position, BlockStateHolder block) throws MaxChangedBlocksException {
|
private static boolean setBlockIfAir(EditSession session, BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException {
|
||||||
return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block);
|
return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -90,7 +90,7 @@ public class BiomeMask2D extends AbstractMask2D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Vector2D vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
BaseBiome biome = extent.getBiome(vector);
|
BaseBiome biome = extent.getBiome(vector);
|
||||||
return biomes.contains(biome);
|
return biomes.contains(biome);
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -41,7 +41,7 @@ public class BlockCategoryMask extends AbstractExtentMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Vector vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return category.contains(getExtent().getBlock(vector));
|
return category.contains(getExtent().getBlock(vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -94,7 +94,7 @@ public class BlockMask extends AbstractExtentMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Vector vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
BlockStateHolder block = getExtent().getBlock(vector);
|
BlockStateHolder block = getExtent().getBlock(vector);
|
||||||
for (BlockStateHolder testBlock : blocks) {
|
for (BlockStateHolder testBlock : blocks) {
|
||||||
if (testBlock.equalsFuzzy(block)) {
|
if (testBlock.equalsFuzzy(block)) {
|
||||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren