mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Update to working PlotSquared repo; Update to PlotSquared C>Captions class rename; Cleaning and minor modifications to SpongeSchematicReader
This commit is contained in:
@ -127,200 +127,14 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
return fc;
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
if (Settings.IMP.CLIPBOARD.USE_DISK) {
|
||||
return fc = new DiskOptimizedClipboard(size, 1, 1, uuid);
|
||||
} else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) {
|
||||
return fc = new CPUOptimizedClipboard(size, 1, 1);
|
||||
//=======
|
||||
//
|
||||
// BlockVector3 min = BlockVector3.at(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||
//
|
||||
// if (metadata.containsKey("WEOffsetX")) {
|
||||
// // We appear to have WorldEdit Metadata
|
||||
// int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
|
||||
// int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
|
||||
// int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
|
||||
// BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ);
|
||||
// origin = min.subtract(offset);
|
||||
// region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
} else {
|
||||
return fc = new MemoryOptimizedClipboard(size, 1, 1);
|
||||
}
|
||||
}
|
||||
// BlockVector3 min = new BlockVector3(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||
//
|
||||
// if (metadata.containsKey("WEOffsetX")) {
|
||||
// // We appear to have WorldEdit Metadata
|
||||
// int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
|
||||
// int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
|
||||
// int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
|
||||
// BlockVector3 offset = new BlockVector3(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));
|
||||
// }
|
||||
//
|
||||
// int paletteMax = requireTag(schematic, "PaletteMax", IntTag.class).getValue();
|
||||
// Map<String, Tag> paletteObject = requireTag(schematic, "Palette", CompoundTag.class).getValue();
|
||||
// if (paletteObject.size() != paletteMax) {
|
||||
// throw new IOException("Differing given palette size to actual size");
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
// private Clipboard readVersion1(UUID uuid) throws IOException {
|
||||
// width = height = length = offsetX = offsetY = offsetZ = Integer.MIN_VALUE;
|
||||
//
|
||||
// final BlockArrayClipboard clipboard = new BlockArrayClipboard(new CuboidRegion(new Vector(0, 0, 0), new Vector(0, 0, 0)), fc);
|
||||
// FastByteArrayOutputStream blocksOut = new FastByteArrayOutputStream();
|
||||
// FastByteArrayOutputStream biomesOut = new FastByteArrayOutputStream();
|
||||
//
|
||||
// NBTStreamer streamer = new NBTStreamer(inputStream);
|
||||
// streamer.addReader("Schematic.Width", (BiConsumer<Integer, Short>) (i, v) -> width = v);
|
||||
// streamer.addReader("Schematic.Height", (BiConsumer<Integer, Short>) (i, v) -> height = v);
|
||||
// streamer.addReader("Schematic.Length", (BiConsumer<Integer, Short>) (i, v) -> length = v);
|
||||
// streamer.addReader("Schematic.Offset", (BiConsumer<Integer, int[]>) (i, v) -> min = new BlockVector(v[0], v[1], v[2]));
|
||||
// streamer.addReader("Schematic.Metadata.WEOffsetX", (BiConsumer<Integer, Integer>) (i, v) -> offsetX = v);
|
||||
// streamer.addReader("Schematic.Metadata.WEOffsetY", (BiConsumer<Integer, Integer>) (i, v) -> offsetY = v);
|
||||
// streamer.addReader("Schematic.Metadata.WEOffsetZ", (BiConsumer<Integer, Integer>) (i, v) -> offsetZ = v);
|
||||
// streamer.addReader("Schematic.Palette", (BiConsumer<Integer, HashMap<String, Tag>>) (i, v) -> {
|
||||
// palette = new char[v.size()];
|
||||
// for (Map.Entry<String, Tag> entry : v.entrySet()) {
|
||||
// BlockState state = BlockState.get(entry.getKey());
|
||||
// int index = ((IntTag) entry.getValue()).getValue();
|
||||
// palette[index] = (char) state.getOrdinal();
|
||||
// }
|
||||
//<<<<<<< HEAD
|
||||
// });
|
||||
// streamer.addReader("Schematic.BlockData.#", new NBTStreamer.LazyReader() {
|
||||
// @Override
|
||||
// public void accept(Integer arrayLen, DataInputStream dis) {
|
||||
// try (FaweOutputStream blocks = new FaweOutputStream(new LZ4BlockOutputStream(blocksOut))) {
|
||||
// IOUtil.copy(dis, blocks, arrayLen);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//=======
|
||||
// palette.put(id, state);
|
||||
// }
|
||||
//
|
||||
// byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
|
||||
//
|
||||
// Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
// try {
|
||||
// List<Map<String, Tag>> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream()
|
||||
// .map(tag -> (CompoundTag) tag)
|
||||
// .map(CompoundTag::getValue)
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// for (Map<String, Tag> tileEntity : tileEntityTags) {
|
||||
// int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
|
||||
// tileEntitiesMap.put(new BlockVector3(pos[0], pos[1], pos[2]), tileEntity);
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
// }
|
||||
// });
|
||||
// streamer.addReader("Schematic.Biomes.#", new NBTStreamer.LazyReader() {
|
||||
// @Override
|
||||
// public void accept(Integer arrayLen, DataInputStream dis) {
|
||||
// try (FaweOutputStream biomes = new FaweOutputStream(new LZ4BlockOutputStream(biomesOut))) {
|
||||
// IOUtil.copy(dis, biomes, arrayLen);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// streamer.addReader("Schematic.TileEntities.#", new BiConsumer<Integer, CompoundTag>() {
|
||||
// @Override
|
||||
// public void accept(Integer index, CompoundTag value) {
|
||||
// if (fc == null) {
|
||||
// setupClipboard(0, uuid);
|
||||
// }
|
||||
// int[] pos = value.getIntArray("Pos");
|
||||
// int x = pos[0];
|
||||
// int y = pos[1];
|
||||
// int z = pos[2];
|
||||
// fc.setTile(x, y, z, value);
|
||||
// }
|
||||
// });
|
||||
// streamer.addReader("Schematic.Entities.#", new BiConsumer<Integer, CompoundTag>() {
|
||||
// @Override
|
||||
// public void accept(Integer index, CompoundTag compound) {
|
||||
// if (fc == null) {
|
||||
// setupClipboard(0, uuid);
|
||||
// }
|
||||
// String id = compound.getString("id");
|
||||
// if (id.isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
// ListTag positionTag = compound.getListTag("Pos");
|
||||
// ListTag directionTag = compound.getListTag("Rotation");
|
||||
// EntityType type = EntityTypes.parse(id);
|
||||
// if (type != null) {
|
||||
// compound.getValue().put("Id", new StringTag(type.getId()));
|
||||
// BaseEntity state = new BaseEntity(type, compound);
|
||||
// fc.createEntity(clipboard, positionTag.asDouble(0), positionTag.asDouble(1), positionTag.asDouble(2), (float) directionTag.asDouble(0), (float) directionTag.asDouble(1), state);
|
||||
// } else {
|
||||
// Fawe.debug("Invalid entity: " + id);
|
||||
// }
|
||||
// }
|
||||
//<<<<<<< HEAD
|
||||
// });
|
||||
// streamer.readFully();
|
||||
// if (fc == null) setupClipboard(length * width * height, uuid);
|
||||
// Vector origin = min;
|
||||
// CuboidRegion region;
|
||||
// if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) {
|
||||
// origin = origin.subtract(new Vector(offsetX, offsetY, offsetZ));
|
||||
// region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
|
||||
// } else {
|
||||
// region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
|
||||
// }
|
||||
// if (blocksOut.getSize() != 0) {
|
||||
// try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(blocksOut.toByteArrays())))) {
|
||||
// int volume = width * height * length;
|
||||
// if (palette.length < 128) {
|
||||
// for (int index = 0; index < volume; index++) {
|
||||
// BlockState state = BlockTypes.states[palette[fis.read()]];
|
||||
// fc.setBlock(index, state);
|
||||
//=======
|
||||
// // index = (y * length + z) * width + x
|
||||
// int y = index / (width * length);
|
||||
// int z = (index % (width * length)) / width;
|
||||
// int x = (index % (width * length)) % width;
|
||||
// BlockState state = palette.get(value);
|
||||
// BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
// try {
|
||||
// if (tileEntitiesMap.containsKey(pt)) {
|
||||
// Map<String, Tag> values = Maps.newHashMap(tileEntitiesMap.get(pt));
|
||||
// for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) {
|
||||
// if (handler.isAffectedBlock(state)) {
|
||||
// handler.updateNBT(state, values);
|
||||
// }
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
// }
|
||||
// } else {
|
||||
// for (int index = 0; index < volume; index++) {
|
||||
// BlockState state = BlockTypes.states[palette[fis.readVarInt()]];
|
||||
// fc.setBlock(index, state);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (biomesOut.getSize() != 0) {
|
||||
// try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(biomesOut.toByteArrays())))) {
|
||||
// int volume = width * length;
|
||||
// for (int index = 0; index < volume; index++) {
|
||||
// fc.setBiome(index, fis.read());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// fc.setDimensions(new Vector(width, height, length));
|
||||
// clipboard.init(region, fc);
|
||||
// clipboard.setOrigin(origin);
|
||||
// return clipboard;
|
||||
// }
|
||||
|
||||
private Clipboard readVersion1(UUID uuid) throws IOException {
|
||||
width = height = length = offsetX = offsetY = offsetZ = Integer.MIN_VALUE;
|
||||
@ -344,7 +158,6 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
int index = ((IntTag) entry.getValue()).getValue();
|
||||
palette[index] = (char) state.getOrdinal();
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
});
|
||||
streamer.addReader("Schematic.BlockData.#", new NBTStreamer.LazyReader() {
|
||||
@Override
|
||||
@ -354,23 +167,6 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//=======
|
||||
// palette.put(id, state);
|
||||
// }
|
||||
//
|
||||
// byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
|
||||
//
|
||||
// Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
// try {
|
||||
// List<Map<String, Tag>> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream()
|
||||
// .map(tag -> (CompoundTag) tag)
|
||||
// .map(CompoundTag::getValue)
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// for (Map<String, Tag> tileEntity : tileEntityTags) {
|
||||
// int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
|
||||
// tileEntitiesMap.put(BlockVector3.at(pos[0], pos[1], pos[2]), tileEntity);
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
}
|
||||
});
|
||||
streamer.addReader("Schematic.Biomes.#", new NBTStreamer.LazyReader() {
|
||||
@ -395,7 +191,6 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
int z = pos[2];
|
||||
fc.setTile(x, y, z, value);
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
});
|
||||
streamer.addReader("Schematic.Entities.#", new BiConsumer<Integer, CompoundTag>() {
|
||||
@Override
|
||||
@ -421,6 +216,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
});
|
||||
streamer.readFully();
|
||||
if (fc == null) setupClipboard(length * width * height, uuid);
|
||||
else fc.setDimensions(BlockVector3.at(width, height, length));
|
||||
BlockVector3 origin = min;
|
||||
CuboidRegion region;
|
||||
if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) {
|
||||
@ -436,32 +232,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
for (int index = 0; index < volume; index++) {
|
||||
BlockState state = BlockTypes.states[palette[fis.read()]];
|
||||
fc.setBlock(index, state);
|
||||
//=======
|
||||
// // index = (y * length + z) * width + x
|
||||
// int y = index / (width * length);
|
||||
// int z = (index % (width * length)) / width;
|
||||
// int x = (index % (width * length)) % width;
|
||||
// BlockState state = palette.get(value);
|
||||
// BlockVector3 pt = BlockVector3.at(x, y, z);
|
||||
// try {
|
||||
// if (tileEntitiesMap.containsKey(pt)) {
|
||||
// Map<String, Tag> values = Maps.newHashMap(tileEntitiesMap.get(pt));
|
||||
// for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) {
|
||||
// if (handler.isAffectedBlock(state)) {
|
||||
// handler.updateNBT(state, values);
|
||||
// }
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
//=======
|
||||
// values.put("x", new IntTag(pt.getBlockX()));
|
||||
// values.put("y", new IntTag(pt.getBlockY()));
|
||||
// values.put("z", new IntTag(pt.getBlockZ()));
|
||||
// values.put("id", values.get("Id"));
|
||||
// values.remove("Id");
|
||||
// values.remove("Pos");
|
||||
// clipboard.setBlock(pt, state.toBaseBlock(new CompoundTag(values)));
|
||||
//>>>>>>> f54d6afb... Make BaseBlock more memory efficient, and make it clear in the API that it's not intended to be used for every single block.
|
||||
} else {
|
||||
for (int index = 0; index < volume; index++) {
|
||||
BlockState state = BlockTypes.states[palette[fis.readVarInt()]];
|
||||
@ -478,7 +249,6 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
}
|
||||
}
|
||||
fc.setDimensions(BlockVector3.at(width, height, length));
|
||||
clipboard.init(region, fc);
|
||||
clipboard.setOrigin(origin);
|
||||
return clipboard;
|
||||
|
Reference in New Issue
Block a user