3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 02:20:07 +01:00

Added support for non-128 worldheights

Dieser Commit ist enthalten in:
zml2008 2011-12-12 19:20:31 -08:00 committet von TomyLobo
Ursprung e01aad00d8
Commit 98216e2762
24 geänderte Dateien mit 190 neuen und 102 gelöschten Zeilen

Datei anzeigen

@ -168,7 +168,7 @@ public class EditSession {
public boolean rawSetBlock(Vector pt, BaseBlock block) {
final int y = pt.getBlockY();
final int type = block.getType();
if (y < 0 || y > 127) {
if (y < 0 || y > world.getMaxY()) {
return false;
}
@ -1046,7 +1046,7 @@ public class EditSession {
*/
public int removeAbove(Vector pos, int size, int height)
throws MaxChangedBlocksException {
int maxY = Math.min(127, pos.getBlockY() + height - 1);
int maxY = Math.min(world.getMaxY(), pos.getBlockY() + height - 1);
--size;
int affected = 0;
@ -1122,7 +1122,7 @@ public class EditSession {
int minX = pos.getBlockX() - size;
int maxX = pos.getBlockX() + size;
int minY = Math.max(0, pos.getBlockY() - size);
int maxY = Math.min(127, pos.getBlockY() + size);
int maxY = Math.min(world.getMaxY(), pos.getBlockY() + size);
int minZ = pos.getBlockZ() - size;
int maxZ = pos.getBlockZ() + size;
@ -1584,7 +1584,7 @@ public class EditSession {
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
int upperY = Math.min(127, max.getBlockY() + 1);
int upperY = Math.min(world.getMaxY(), max.getBlockY() + 1);
int lowerY = Math.max(0, min.getBlockY() - 1);
int affected = 0;
@ -1599,7 +1599,7 @@ public class EditSession {
for (int y = upperY; y >= lowerY; --y) {
Vector above = new Vector(x, y + 1, z);
if (y + 1 <= 127 && !getBlock(new Vector(x, y, z)).isAir()
if (y + 1 <= world.getMaxY() && !getBlock(new Vector(x, y, z)).isAir()
&& getBlock(above).isAir()) {
if (setBlock(above, block)) {
++affected;
@ -1626,7 +1626,7 @@ public class EditSession {
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
int upperY = Math.min(127, max.getBlockY() + 1);
int upperY = Math.min(world.getMaxY(), max.getBlockY() + 1);
int lowerY = Math.max(0, min.getBlockY() - 1);
int affected = 0;
@ -1641,7 +1641,7 @@ public class EditSession {
for (int y = upperY; y >= lowerY; --y) {
Vector above = new Vector(x, y + 1, z);
if (y + 1 <= 127 && !getBlock(new Vector(x, y, z)).isAir()
if (y + 1 <= world.getMaxY() && !getBlock(new Vector(x, y, z)).isAir()
&& getBlock(above).isAir()) {
if (setBlock(above, pattern.next(above))) {
++affected;
@ -1668,7 +1668,7 @@ public class EditSession {
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
int upperY = Math.min(127, max.getBlockY() + 1);
int upperY = Math.min(world.getMaxY(), max.getBlockY() + 1);
int lowerY = Math.max(0, min.getBlockY() - 1);
int affected = 0;
@ -2020,8 +2020,8 @@ public class EditSession {
if (pos.getBlockY() - height - 1 < 0) {
height = pos.getBlockY() + 1;
} else if (pos.getBlockY() + height - 1 > 127) {
height = 127 - pos.getBlockY() + 1;
} else if (pos.getBlockY() + height - 1 > world.getMaxY()) {
height = world.getMaxY() - pos.getBlockY() + 1;
}
final double invRadiusX = 1 / radiusX;
@ -2253,7 +2253,7 @@ public class EditSession {
continue;
}
for (int y = 127; y >= 1; --y) {
for (int y = world.getMaxY(); y >= 1; --y) {
Vector pt = new Vector(x, y, z);
int id = getBlockType(pt);
@ -2312,7 +2312,7 @@ public class EditSession {
continue;
}
for (int y = 127; y >= 1; --y) {
for (int y = world.getMaxY(); y >= 1; --y) {
Vector pt = new Vector(x, y, z);
int id = getBlockType(pt);
@ -2334,7 +2334,7 @@ public class EditSession {
}
// Too high?
if (y == 127) {
if (y == world.getMaxY()) {
break;
}
@ -2376,7 +2376,7 @@ public class EditSession {
continue;
}
loop: for (int y = 127; y >= 1; --y) {
loop: for (int y = world.getMaxY(); y >= 1; --y) {
final Vector pt = new Vector(x, y, z);
final int id = getBlockType(pt);

Datei anzeigen

@ -230,7 +230,7 @@ public abstract class LocalPlayer extends LocalCommandSender {
return false;
}
while (y <= 127) {
while (y <= world.getMaxY()) {
// Found a ceiling!
if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
int platformY = Math.max(initialY, y - 3 - clearance);
@ -257,7 +257,7 @@ public abstract class LocalPlayer extends LocalCommandSender {
int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 1);
int z = pos.getBlockZ();
int maxY = Math.min(128, initialY + distance);
int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
LocalWorld world = getPosition().getWorld();
while (y <= 129) {

Datei anzeigen

@ -56,7 +56,6 @@ public class LocalSession {
private LocalConfiguration config;
private long expirationTime = 0;
private LocalWorld selectionWorld;
private RegionSelector selector = new CuboidRegionSelector();
private boolean placeAtPos1 = false;
private LinkedList<EditSession> history = new LinkedList<EditSession>();
@ -183,10 +182,10 @@ public class LocalSession {
* @return position
*/
public RegionSelector getRegionSelector(LocalWorld world) {
if (selectionWorld == null) {
selectionWorld = world;
} else if (!selectionWorld.equals(world)) {
selectionWorld = world;
if (selector.getIncompleteRegion().getWorld() == null) {
selector = new CuboidRegionSelector(world);
} else if (!selector.getIncompleteRegion().getWorld().equals(world)) {
selector.getIncompleteRegion().setWorld(world);
selector.clear();
}
return selector;
@ -198,6 +197,7 @@ public class LocalSession {
*
* @return position
*/
@Deprecated
public RegionSelector getRegionSelector() {
return selector;
}
@ -209,7 +209,7 @@ public class LocalSession {
* @param selector
*/
public void setRegionSelector(LocalWorld world, RegionSelector selector) {
selectionWorld = world;
selector.getIncompleteRegion().setWorld(world);
this.selector = selector;
}
@ -230,7 +230,7 @@ public class LocalSession {
* @return
*/
public boolean isSelectionDefined(LocalWorld world) {
if (selectionWorld == null || !selectionWorld.equals(world)) {
if (selector.getIncompleteRegion().getWorld() == null || !selector.getIncompleteRegion().getWorld().equals(world)) {
return false;
}
return selector.isDefined();
@ -258,7 +258,7 @@ public class LocalSession {
* @throws IncompleteRegionException
*/
public Region getSelection(LocalWorld world) throws IncompleteRegionException {
if (selectionWorld == null || !selectionWorld.equals(world)) {
if (selector.getIncompleteRegion().getWorld() == null || !selector.getIncompleteRegion().getWorld().equals(world)) {
throw new IncompleteRegionException();
}
return selector.getRegion();
@ -270,7 +270,7 @@ public class LocalSession {
* @return
*/
public LocalWorld getSelectionWorld() {
return selectionWorld;
return selector.getIncompleteRegion().getWorld();
}
/**

Datei anzeigen

@ -357,7 +357,7 @@ public abstract class LocalWorld {
*
* @return
*/
public int getHeight() {
public int getMaxY() {
return 127;
}

Datei anzeigen

@ -226,14 +226,14 @@ public class BukkitWorld extends LocalWorld {
*/
@Override
public boolean regenerate(Region region, EditSession editSession) {
BaseBlock[] history = new BaseBlock[16 * 16 * 128];
BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
for (Vector2D chunk : region.getChunks()) {
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
// First save all the blocks inside
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 128; ++y) {
for (int y = 0; y < (getMaxY() + 1); ++y) {
for (int z = 0; z < 16; ++z) {
Vector pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
@ -250,7 +250,7 @@ public class BukkitWorld extends LocalWorld {
// Then restore
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 128; ++y) {
for (int y = 0; y < (getMaxY() + 1); ++y) {
for (int z = 0; z < 16; ++z) {
Vector pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
@ -761,7 +761,7 @@ public class BukkitWorld extends LocalWorld {
}
@Override
public int getHeight() {
public int getMaxY() {
return world.getMaxHeight() - 1;
}
@ -775,7 +775,6 @@ public class BukkitWorld extends LocalWorld {
}
private static final int chunkSizeX = 16;
private static final int chunkSizeY = 128;
private static final int chunkSizeZ = 16;
@Override
@ -810,8 +809,8 @@ public class BukkitWorld extends LocalWorld {
boolean xBorder = x == 0 || x == chunkSizeX - 1;
for (int z = 0; z < chunkSizeZ; ++z) {
boolean zBorder = z == 0 || z == chunkSizeZ - 1;
for (int y = 0; y < chunkSizeY; ++y) {
final int index = y + z * chunkSizeY + x * chunkSizeY * chunkSizeZ;
for (int y = 0; y < world.getMaxHeight(); ++y) {
final int index = y + z * world.getMaxHeight() + x * world.getMaxHeight() * chunkSizeZ;
byte blockID = blocks[index];
if (!BlockType.emitsLight(blockID)) {
if (xBorder || zBorder && BlockType.isTranslucent(blockID)) {

Datei anzeigen

@ -58,6 +58,6 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
}
public int getHeight() {
return editSession.getWorld().getHeight();
return editSession.getWorld().getMaxY();
}
}

Datei anzeigen

@ -378,7 +378,7 @@ public class WorldEditPlugin extends JavaPlugin {
}
LocalSession session = controller.getSession(wrapPlayer(player));
RegionSelector selector = session.getRegionSelector();
RegionSelector selector = session.getRegionSelector(BukkitUtil.getLocalWorld(player.getWorld()));
try {
Region region = selector.getRegion();

Datei anzeigen

@ -45,7 +45,7 @@ public class CuboidSelection extends RegionSelection {
throw new IllegalArgumentException("Null point 2 not permitted");
}
CuboidRegionSelector sel = new CuboidRegionSelector();
CuboidRegionSelector sel = new CuboidRegionSelector(BukkitUtil.getLocalWorld(world));
sel.selectPrimary(pt1);
sel.selectSecondary(pt2);

Datei anzeigen

@ -21,8 +21,11 @@ package com.sk89q.worldedit.bukkit.selections;
import java.util.Collections;
import java.util.List;
import com.sk89q.worldedit.LocalWorld;
import org.bukkit.World;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.regions.*;
public class Polygonal2DSelection extends RegionSelection {
@ -36,13 +39,13 @@ public class Polygonal2DSelection extends RegionSelection {
public Polygonal2DSelection(World world, List<BlockVector2D> points, int minY, int maxY) {
super(world);
LocalWorld lWorld = BukkitUtil.getLocalWorld(world);
minY = Math.min(Math.max(0, minY), 127);
maxY = Math.min(Math.max(0, maxY), 127);
Polygonal2DRegionSelector sel = new Polygonal2DRegionSelector();
poly2d = new Polygonal2DRegion(points, minY, maxY);
minY = Math.min(Math.max(0, minY), world.getMaxHeight());
maxY = Math.min(Math.max(0, maxY), world.getMaxHeight());
Polygonal2DRegionSelector sel = new Polygonal2DRegionSelector(BukkitUtil.getLocalWorld(world));
poly2d = new Polygonal2DRegion(lWorld, points, minY, maxY);
sel.learnChanges();
setRegionSelector(sel);

Datei anzeigen

@ -264,8 +264,8 @@ public class RegionCommands {
region.expand(dir.multiply(count));
region.contract(dir.multiply(count));
session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
} catch (RegionOperationException e) {
player.printError(e.getMessage());
}
@ -309,8 +309,8 @@ public class RegionCommands {
region.expand(shiftVector);
region.contract(shiftVector);
session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
} catch (RegionOperationException e) {
player.printError(e.getMessage());
}

Datei anzeigen

@ -194,7 +194,7 @@ public class SelectionCommands {
final Vector2D max2D = ChunkStore.toChunk(region.getMaximumPoint());
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
max = new Vector(max2D.getBlockX() * 16 + 15, 127, max2D.getBlockZ() * 16 + 15);
max = new Vector(max2D.getBlockX() * 16 + 15, player.getWorld().getMaxY(), max2D.getBlockZ() * 16 + 15);
player.print("Chunks selected: ("
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - ("
@ -203,13 +203,13 @@ public class SelectionCommands {
final Vector2D min2D = ChunkStore.toChunk(player.getBlockIn());
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
max = min.add(15, 127, 15);
max = min.add(15, player.getWorld().getMaxY(), 15);
player.print("Chunk selected: "
+ min2D.getBlockX() + ", " + min2D.getBlockZ());
}
CuboidRegionSelector selector = new CuboidRegionSelector();
CuboidRegionSelector selector = new CuboidRegionSelector(player.getWorld());
selector.selectPrimary(min);
selector.selectSecondary(max);
session.setRegionSelector(player.getWorld(), selector);
@ -276,11 +276,11 @@ public class SelectionCommands {
Region region = session.getSelection(player.getWorld());
try {
int oldSize = region.getArea();
region.expand(new Vector(0, 128, 0));
region.expand(new Vector(0, -128, 0));
session.getRegionSelector().learnChanges();
region.expand(new Vector(0, (player.getWorld().getMaxY() + 1), 0));
region.expand(new Vector(0, -(player.getWorld().getMaxY() + 1), 0));
session.getRegionSelector(player.getWorld()).learnChanges();
int newSize = region.getArea();
session.getRegionSelector().explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region expanded " + (newSize - oldSize)
+ " blocks [top-to-bottom].");
} catch (RegionOperationException e) {
@ -323,10 +323,10 @@ public class SelectionCommands {
region.expand(dir.multiply(reverseChange));
}
session.getRegionSelector().learnChanges();
session.getRegionSelector(player.getWorld()).learnChanges();
int newSize = region.getArea();
session.getRegionSelector().explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region expanded " + (newSize - oldSize) + " blocks.");
}
@ -374,10 +374,11 @@ public class SelectionCommands {
if (reverseChange != 0) {
region.contract(dir.multiply(reverseChange));
}
session.getRegionSelector().learnChanges();
session.getRegionSelector(player.getWorld()).learnChanges();
int newSize = region.getArea();
session.getRegionSelector().explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region contracted " + (oldSize - newSize) + " blocks.");
} catch (RegionOperationException e) {
@ -409,9 +410,9 @@ public class SelectionCommands {
Region region = session.getSelection(player.getWorld());
region.expand(dir.multiply(change));
region.contract(dir.multiply(change));
session.getRegionSelector().learnChanges();
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region shifted.");
} catch (RegionOperationException e) {
@ -453,9 +454,9 @@ public class SelectionCommands {
region.expand((new Vector(0, 0, -1)).multiply(change));
}
session.getRegionSelector().learnChanges();
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region outset.");
} catch (RegionOperationException e) {
@ -496,9 +497,9 @@ public class SelectionCommands {
region.contract((new Vector(0, 0, -1)).multiply(change));
}
session.getRegionSelector().learnChanges();
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region inset.");
}
@ -520,9 +521,9 @@ public class SelectionCommands {
.subtract(region.getMinimumPoint())
.add(1, 1, 1);
player.print("Type: " + session.getRegionSelector().getTypeName());
player.print("Type: " + session.getRegionSelector(player.getWorld()).getTypeName());
for (String line : session.getRegionSelector().getInformationLines()) {
for (String line : session.getRegionSelector(player.getWorld()).getInformationLines()) {
player.print(line);
}
@ -625,7 +626,7 @@ public class SelectionCommands {
selector = new ExtendingCuboidRegionSelector(oldSelector);
player.print("Cuboid: left click for a starting point, right click to extend");
} else if (typeName.equalsIgnoreCase("poly")) {
selector = new Polygonal2DRegionSelector();
selector = new Polygonal2DRegionSelector(world);
player.print("2D polygon selector: Left/right click to add a point.");
} else {
player.printError("Only 'cuboid', 'extend' and 'poly' are accepted.");

Datei anzeigen

@ -173,7 +173,8 @@ public class UtilityCommands {
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
we.checkMaxRadius(size);
int height = args.argsLength() > 1 ? Math.min(128, args.getInteger(1) + 2) : 128;
LocalWorld world = player.getWorld();
int height = args.argsLength() > 1 ? Math.min((world.getMaxY() + 1), args.getInteger(1) + 2) : (world.getMaxY() + 1);
int affected = editSession.removeAbove(
session.getPlacementPosition(player), size, height);
@ -195,7 +196,8 @@ public class UtilityCommands {
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
we.checkMaxRadius(size);
int height = args.argsLength() > 1 ? Math.min(128, args.getInteger(1) + 2) : 128;
LocalWorld world = player.getWorld();
int height = args.argsLength() > 1 ? Math.min((world.getMaxY() + 1), args.getInteger(1) + 2) : (world.getMaxY() + 1);
int affected = editSession.removeBelow(session.getPlacementPosition(player), size, height);
player.print(affected + " block(s) have been removed.");
@ -251,7 +253,7 @@ public class UtilityCommands {
Vector base = session.getPlacementPosition(player);
Vector min = base.subtract(size, size, size);
Vector max = base.add(size, size, size);
Region region = new CuboidRegion(min, max);
Region region = new CuboidRegion(player.getWorld(), min, max);
if (to instanceof SingleBlockPattern) {
affected = editSession.replaceBlocks(region, from, ((SingleBlockPattern) to).getBlock());

Datei anzeigen

@ -37,7 +37,9 @@ public class Chunk {
private byte[] data;
private int rootX;
private int rootZ;
private Map<BlockVector, Map<String, Tag>> tileEntities;
private Map<BlockVector, Map<String,Tag>> tileEntities;
private LocalWorld world;
/**
* Construct the chunk with a compound tag.
@ -45,8 +47,9 @@ public class Chunk {
* @param tag
* @throws DataException
*/
public Chunk(CompoundTag tag) throws DataException {
public Chunk(LocalWorld world, CompoundTag tag) throws DataException {
rootTag = tag;
this.world = world;
blocks = getChildTag(
rootTag.getValue(), "Blocks", ByteArrayTag.class).getValue();
@ -57,14 +60,14 @@ public class Chunk {
rootZ = getChildTag(
rootTag.getValue(), "zPos", IntTag.class).getValue();
if (blocks.length != 32768) {
if (blocks.length != 16*16*(world.getMaxY() + 1)) {
throw new InvalidFormatException("Chunk blocks byte array expected "
+ "to be 32,768 bytes; found " + blocks.length);
+ "to be " + 16*16*(world.getMaxY() + 1) + " bytes; found " + blocks.length);
}
if (data.length != 16384) {
if (data.length != 16*16*((world.getMaxY() + 1)/2)) {
throw new InvalidFormatException("Chunk block data byte array "
+ "expected to be 16,384 bytes; found " + data.length);
+ "expected to be " + 16*16*((world.getMaxY() + 1)/2) + " bytes; found " + data.length);
}
}
@ -79,7 +82,7 @@ public class Chunk {
int x = pos.getBlockX() - rootX * 16;
int y = pos.getBlockY();
int z = pos.getBlockZ() - rootZ * 16;
int index = y + (z * 128 + (x * 128 * 16));
int index = y + (z * (world.getMaxY() + 1) + (x * (world.getMaxY() + 1) * 16));
try {
return blocks[index];
@ -99,7 +102,7 @@ public class Chunk {
int x = pos.getBlockX() - rootX * 16;
int y = pos.getBlockY();
int z = pos.getBlockZ() - rootZ * 16;
int index = y + (z * 128 + (x * 128 * 16));
int index = y + (z * (world.getMaxY() + 1) + (x * (world.getMaxY() + 1) * 16));
boolean shift = index % 2 == 0;
index /= 2;

Datei anzeigen

@ -50,7 +50,7 @@ public abstract class ChunkStore {
* @throws DataException
* @throws IOException
*/
public abstract CompoundTag getChunkTag(Vector2D pos, String world)
public abstract CompoundTag getChunkTag(Vector2D pos, LocalWorld world)
throws DataException, IOException;
/**
@ -62,9 +62,9 @@ public abstract class ChunkStore {
* @throws IOException
* @throws DataException
*/
public Chunk getChunk(Vector2D pos, String world)
public Chunk getChunk(Vector2D pos, LocalWorld world)
throws DataException, IOException {
return new Chunk(getChunkTag(pos, world));
return new Chunk(world, getChunkTag(pos, world));
}
/**

Datei anzeigen

@ -74,7 +74,7 @@ public abstract class LegacyChunkStore extends ChunkStore {
* @throws IOException
*/
@Override
public CompoundTag getChunkTag(Vector2D pos, String world)
public CompoundTag getChunkTag(Vector2D pos, LocalWorld world)
throws DataException, IOException {
int x = pos.getBlockX();
int z = pos.getBlockZ();

Datei anzeigen

@ -25,6 +25,7 @@ import java.util.Map;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector2D;
public abstract class McRegionChunkStore extends ChunkStore {
@ -65,10 +66,11 @@ public abstract class McRegionChunkStore extends ChunkStore {
}
@Override
public CompoundTag getChunkTag(Vector2D pos, String worldname) throws DataException,
public CompoundTag getChunkTag(Vector2D pos, LocalWorld world) throws DataException,
IOException {
McRegionReader reader = getReader(pos, worldname);
McRegionReader reader = getReader(pos, world.getName());
InputStream stream = reader.getChunkInputStream(pos);
NBTInputStream nbt = new NBTInputStream(stream);
Tag tag;

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.data.ChunkStore;
@ -40,6 +41,10 @@ public class CuboidRegion implements Region {
* Store the second point.
*/
private Vector pos2;
/**
* Stores the world.
*/
private LocalWorld world;
/**
* Construct a new instance of this cuboid region.
@ -48,7 +53,19 @@ public class CuboidRegion implements Region {
* @param pos2
*/
public CuboidRegion(Vector pos1, Vector pos2) {
this(null, pos1, pos2);
}
/**
* Construct a new instance of this cuboid region.
*
* @param world
* @param pos1
* @param pos2
*/
public CuboidRegion(LocalWorld world, Vector pos1, Vector pos2) {
this.pos1 = pos1;
this.world = world;
this.pos2 = pos2;
}
@ -172,8 +189,8 @@ public class CuboidRegion implements Region {
}
}
pos1 = pos1.clampY(0, 127);
pos2 = pos2.clampY(0, 127);
pos1 = pos1.clampY(0, world.getMaxY());
pos2 = pos2.clampY(0, world.getMaxY());
}
/**
@ -224,8 +241,8 @@ public class CuboidRegion implements Region {
}
}
pos1 = pos1.clampY(0, 127);
pos2 = pos2.clampY(0, 127);
pos1 = pos1.clampY(0, world == null ? 127 : world.getMaxY());
pos2 = pos2.clampY(0, world == null ? 127 : world.getMaxY());
}
/**
@ -353,4 +370,12 @@ public class CuboidRegion implements Region {
public String toString() {
return getMinimumPoint() + " - " + getMaximumPoint();
}
public LocalWorld getWorld() {
return world;
}
public void setWorld(LocalWorld world) {
this.world = world;
}
}

Datei anzeigen

@ -25,6 +25,7 @@ import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.cui.CUIPointBasedRegion;
import com.sk89q.worldedit.cui.SelectionPointEvent;
@ -37,12 +38,18 @@ import com.sk89q.worldedit.cui.SelectionPointEvent;
public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion {
protected BlockVector pos1;
protected BlockVector pos2;
protected CuboidRegion region = new CuboidRegion(new Vector(), new Vector());
protected CuboidRegion region;
public CuboidRegionSelector(LocalWorld world) {
region = new CuboidRegion(world, new Vector(), new Vector());
}
public CuboidRegionSelector() {
this((LocalWorld)null);
}
public CuboidRegionSelector(RegionSelector oldSelector) {
region = new CuboidRegion(oldSelector.getIncompleteRegion().getWorld(), new Vector(), new Vector());
if (oldSelector instanceof CuboidRegionSelector) {
final CuboidRegionSelector cuboidRegionSelector = (CuboidRegionSelector) oldSelector;

Datei anzeigen

@ -27,6 +27,7 @@ import java.util.List;
import java.util.Set;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.data.ChunkStore;
@ -43,30 +44,43 @@ public class Polygonal2DRegion implements Region {
protected int minY;
protected int maxY;
protected boolean hasY = false;
protected LocalWorld world;
/**
* Construct the region
*/
public Polygonal2DRegion() {
this(null);
}
/**
* Construct the region.
*
* @param world
*/
public Polygonal2DRegion() {
public Polygonal2DRegion(LocalWorld world) {
points = new ArrayList<BlockVector2D>();
minY = 0;
maxY = 0;
hasY = false;
this.world = world;
recalculate();
}
/**
* Construct the region.
*
* @param world
* @param points
* @param minY
* @param maxY
*/
public Polygonal2DRegion(List<BlockVector2D> points, int minY, int maxY) {
public Polygonal2DRegion(LocalWorld world, List<BlockVector2D> points, int minY, int maxY) {
this.points = points;
this.minY = minY;
this.maxY = maxY;
hasY = true;
this.world = world;
recalculate();
}
@ -109,6 +123,9 @@ public class Polygonal2DRegion implements Region {
minY = Math.min(oldMinY, oldMaxY);
maxY = Math.max(oldMinY, oldMaxY);
minY = Math.min(Math.max(0, minY), world == null ? 127 : world.getMaxY());
maxY = Math.min(Math.max(0, maxY), world == null ? 127 : world.getMaxY());
min = new BlockVector(minX, minY, minZ);
max = new BlockVector(maxX, maxY, maxZ);
}
@ -567,4 +584,12 @@ public class Polygonal2DRegion implements Region {
throw new UnsupportedOperationException("Not supported");
}
}
public LocalWorld getWorld() {
return world;
}
public void setWorld(LocalWorld world) {
this.world = world;
}
}

Datei anzeigen

@ -26,6 +26,7 @@ import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.cui.CUIPointBasedRegion;
import com.sk89q.worldedit.cui.SelectionMinMaxEvent;
@ -39,7 +40,11 @@ import com.sk89q.worldedit.cui.SelectionShapeEvent;
*/
public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedRegion {
protected BlockVector pos1;
protected Polygonal2DRegion region = new Polygonal2DRegion();
protected Polygonal2DRegion region;
public Polygonal2DRegionSelector(LocalWorld world) {
region = new Polygonal2DRegion(world);
}
public boolean selectPrimary(Vector pos) {
if (pos.equals(pos1)) {
@ -47,7 +52,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR
}
pos1 = pos.toBlockVector();
region = new Polygonal2DRegion();
region = new Polygonal2DRegion(region.getWorld());
region.addPoint(pos);
region.expandY(pos.getBlockY());
@ -124,7 +129,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR
public void clear() {
pos1 = null;
region = new Polygonal2DRegion();
region = new Polygonal2DRegion(region.getWorld());
}
public String getTypeName() {

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import java.util.Set;
@ -101,4 +102,18 @@ public interface Region extends Iterable<BlockVector> {
* @return
*/
public Set<Vector2D> getChunks();
/**
* Get the world the selection is in
*
* @return
*/
public LocalWorld getWorld();
/**
* Sets the world the selection is in
*
* @return
*/
public void setWorld(LocalWorld world);
}

Datei anzeigen

@ -147,7 +147,7 @@ public class SnapshotRestore {
Chunk chunk;
try {
chunk = chunkStore.getChunk(chunkPos, editSession.getWorld().getName());
chunk = chunkStore.getChunk(chunkPos, editSession.getWorld());
// Good, the chunk could be at least loaded
// Now just copy blocks!

Datei anzeigen

@ -23,6 +23,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.HeightMap;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.filtering.GaussianKernel;
import com.sk89q.worldedit.filtering.HeightMapFilter;
import com.sk89q.worldedit.patterns.Pattern;
@ -45,9 +46,9 @@ public class SmoothBrush implements Brush {
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
throws MaxChangedBlocksException {
double rad = size;
Vector min = pos.subtract(rad, rad, rad);
WorldVector min = new WorldVector(editSession.getWorld(), pos.subtract(rad, rad, rad));
Vector max = pos.add(rad, rad + 10, rad);
Region region = new CuboidRegion(min, max);
Region region = new CuboidRegion(editSession.getWorld(), min, max);
HeightMap heightMap = new HeightMap(editSession, region, naturalOnly);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
heightMap.applyFilter(filter, iterations);

Datei anzeigen

@ -115,7 +115,7 @@ public class TargetBlock {
if (world.getBlockType(getCurrentBlock()) == BlockID.AIR) {
if (searchForLastBlock) {
lastBlock = getCurrentBlock();
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= 127) {
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
searchForLastBlock = false;
}
}