Update to final Sponge schem v2 spec.

Read lenient, write strict.
Dieser Commit ist enthalten in:
wizjany 2019-05-09 16:59:06 -04:00
Ursprung e2e903ca5e
Commit 56908a7d62
3 geänderte Dateien mit 11 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -61,12 +61,6 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class ClipboardCommands {
/**
* Create a new instance.
*/
public ClipboardCommands() {
}
@Command(
name = "/copy",
desc = "Copy the selection to the clipboard"
@ -78,7 +72,7 @@ public class ClipboardCommands {
boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
Mask mask) throws WorldEditException {
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
clipboard.setOrigin(session.getPlacementPosition(player));

Datei anzeigen

@ -172,7 +172,10 @@ public class SpongeSchematicReader extends NBTSchematicReader {
byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
ListTag tileEntities = getTag(schematic, "TileEntities", ListTag.class);
ListTag tileEntities = getTag(schematic, "BlockEntities", ListTag.class);
if (tileEntities == null) {
tileEntities = getTag(schematic, "TileEntities", ListTag.class);
}
if (tileEntities != null) {
List<Map<String, Tag>> tileEntityTags = tileEntities.getValue().stream()
.map(tag -> (CompoundTag) tag)

Datei anzeigen

@ -21,7 +21,6 @@ package com.sk89q.worldedit.extent.clipboard.io;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.CompoundTag;
@ -52,6 +51,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -85,9 +85,8 @@ public class SpongeSchematicWriter implements ClipboardWriter {
*
* @param clipboard The clipboard
* @return The schematic map
* @throws IOException If an error occurs
*/
private Map<String, Tag> write2(Clipboard clipboard) throws IOException {
private Map<String, Tag> write2(Clipboard clipboard) {
Region region = clipboard.getRegion();
BlockVector3 origin = clipboard.getOrigin();
BlockVector3 min = region.getMinimumPoint();
@ -190,7 +189,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
schematic.put("Palette", new CompoundTag(paletteTag));
schematic.put("BlockData", new ByteArrayTag(buffer.toByteArray()));
schematic.put("TileEntities", new ListTag(CompoundTag.class, tileEntities));
schematic.put("BlockEntities", new ListTag(CompoundTag.class, tileEntities));
// version 2 stuff
if (clipboard.hasBiomes()) {
@ -265,7 +264,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
values.put("Rotation", writeRotation(e.getLocation()));
return new CompoundTag(values);
}).filter(e -> e != null).collect(Collectors.toList());
}).filter(Objects::nonNull).collect(Collectors.toList());
if (entities.isEmpty()) {
return;
}
@ -273,7 +272,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
}
private Tag writeVector(Vector3 vector) {
List<DoubleTag> list = new ArrayList<DoubleTag>();
List<DoubleTag> list = new ArrayList<>();
list.add(new DoubleTag(vector.getX()));
list.add(new DoubleTag(vector.getY()));
list.add(new DoubleTag(vector.getZ()));
@ -281,7 +280,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
}
private Tag writeRotation(Location location) {
List<FloatTag> list = new ArrayList<FloatTag>();
List<FloatTag> list = new ArrayList<>();
list.add(new FloatTag(location.getYaw()));
list.add(new FloatTag(location.getPitch()));
return new ListTag(FloatTag.class, list);