Started refactoring Clipboards

This commit is contained in:
MattBDev
2020-02-27 21:34:59 -05:00
parent fb45fd51fb
commit 0bf0848758
10 changed files with 48 additions and 353 deletions

View File

@ -76,13 +76,13 @@ public class BlockArrayClipboard implements Clipboard {
* @param region the bounding region
*/
public BlockArrayClipboard(Region region, UUID clipboardId) {
this(region, Clipboard.create(region.getDimensions(), clipboardId));
this(region, Clipboard.create(region, clipboardId));
}
public BlockArrayClipboard(Region region, Clipboard clipboard) {
checkNotNull(clipboard);
public BlockArrayClipboard(Region region, Clipboard parent) {
checkNotNull(parent);
checkNotNull(region);
this.parent = clipboard;
this.parent = parent;
this.region = region;
this.origin = region.getMinimumPoint();
}

View File

@ -75,13 +75,13 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
return ReadOnlyClipboard.of(session, region);
}
static Clipboard create(BlockVector3 size, UUID uuid) {
static Clipboard create(Region region, UUID uuid) {
if (Settings.IMP.CLIPBOARD.USE_DISK) {
return new DiskOptimizedClipboard(size, uuid);
return new DiskOptimizedClipboard(region, uuid);
} else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) {
return new CPUOptimizedClipboard(size);
return new CPUOptimizedClipboard(region);
} else {
return new MemoryOptimizedClipboard(size);
return new MemoryOptimizedClipboard(region);
}
}

View File

@ -443,8 +443,8 @@ public class SchematicReader implements ClipboardReader {
if (set.getState(PropertyKey.WEST) == Boolean.FALSE && merge(fc, group, x - 1, y, z)) set = set.with(PropertyKey.WEST, true);
if (group == 2) {
int ns = ((Boolean) set.getState(PropertyKey.NORTH) ? 1 : 0) + ((Boolean) set.getState(PropertyKey.SOUTH) ? 1 : 0);
int ew = ((Boolean) set.getState(PropertyKey.EAST) ? 1 : 0) + ((Boolean) set.getState(PropertyKey.WEST) ? 1 : 0);
int ns = (set.getState(PropertyKey.NORTH) ? 1 : 0) + ((Boolean) set.getState(PropertyKey.SOUTH) ? 1 : 0);
int ew = (set.getState(PropertyKey.EAST) ? 1 : 0) + ((Boolean) set.getState(PropertyKey.WEST) ? 1 : 0);
if (Math.abs(ns - ew) != 2 || fc.getBlock(x, y + 1, z).getBlockType().getMaterial().isSolid()) {
set = set.with(PropertyKey.UP, true);
}

View File

@ -153,7 +153,6 @@ public class SpongeSchematicReader extends NBTSchematicReader {
}
private BlockArrayClipboard readVersion1(CompoundTag schematicTag) throws IOException {
BlockVector3 origin;
Region region;
Map<String, Tag> schematic = schematicTag.getValue();
@ -172,22 +171,8 @@ public class SpongeSchematicReader extends NBTSchematicReader {
offsetParts = new int[] {0, 0, 0};
}
BlockVector3 min = BlockVector3.at(offsetParts[0], offsetParts[1], offsetParts[2]);
CompoundTag metadataTag = getTag(schematic, "Metadata", CompoundTag.class);
if (metadataTag != null && metadataTag.containsKey("WEOffsetX")) {
// We appear to have WorldEdit Metadata
Map<String, Tag> metadata = metadataTag.getValue();
int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ);
origin = min.subtract(offset);
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
} else {
origin = min;
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
}
BlockVector3 origin = BlockVector3.at(offsetParts[0], offsetParts[1], offsetParts[2]);
region = new CuboidRegion(origin, BlockVector3.ZERO.add(width, height, length).subtract(BlockVector3.ONE));
IntTag paletteMaxTag = getTag(schematic, "PaletteMax", IntTag.class);
Map<String, Tag> paletteObject = requireTag(schematic, "Palette", CompoundTag.class).getValue();
@ -397,4 +382,4 @@ public class SpongeSchematicReader extends NBTSchematicReader {
public void close() throws IOException {
inputStream.close();
}
}
}