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) @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class ClipboardCommands { public class ClipboardCommands {
/**
* Create a new instance.
*/
public ClipboardCommands() {
}
@Command( @Command(
name = "/copy", name = "/copy",
desc = "Copy the selection to the clipboard" desc = "Copy the selection to the clipboard"
@ -78,7 +72,7 @@ public class ClipboardCommands {
boolean copyEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes, 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 { Mask mask) throws WorldEditException {
BlockArrayClipboard clipboard = new BlockArrayClipboard(region); BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
clipboard.setOrigin(session.getPlacementPosition(player)); clipboard.setOrigin(session.getPlacementPosition(player));

Datei anzeigen

@ -172,7 +172,10 @@ public class SpongeSchematicReader extends NBTSchematicReader {
byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue(); byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>(); 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) { if (tileEntities != null) {
List<Map<String, Tag>> tileEntityTags = tileEntities.getValue().stream() List<Map<String, Tag>> tileEntityTags = tileEntities.getValue().stream()
.map(tag -> (CompoundTag) tag) .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 static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -52,6 +51,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -85,9 +85,8 @@ public class SpongeSchematicWriter implements ClipboardWriter {
* *
* @param clipboard The clipboard * @param clipboard The clipboard
* @return The schematic map * @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(); Region region = clipboard.getRegion();
BlockVector3 origin = clipboard.getOrigin(); BlockVector3 origin = clipboard.getOrigin();
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
@ -190,7 +189,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
schematic.put("Palette", new CompoundTag(paletteTag)); schematic.put("Palette", new CompoundTag(paletteTag));
schematic.put("BlockData", new ByteArrayTag(buffer.toByteArray())); 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 // version 2 stuff
if (clipboard.hasBiomes()) { if (clipboard.hasBiomes()) {
@ -265,7 +264,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
values.put("Rotation", writeRotation(e.getLocation())); values.put("Rotation", writeRotation(e.getLocation()));
return new CompoundTag(values); return new CompoundTag(values);
}).filter(e -> e != null).collect(Collectors.toList()); }).filter(Objects::nonNull).collect(Collectors.toList());
if (entities.isEmpty()) { if (entities.isEmpty()) {
return; return;
} }
@ -273,7 +272,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
} }
private Tag writeVector(Vector3 vector) { 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.getX()));
list.add(new DoubleTag(vector.getY())); list.add(new DoubleTag(vector.getY()));
list.add(new DoubleTag(vector.getZ())); list.add(new DoubleTag(vector.getZ()));
@ -281,7 +280,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
} }
private Tag writeRotation(Location location) { 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.getYaw()));
list.add(new FloatTag(location.getPitch())); list.add(new FloatTag(location.getPitch()));
return new ListTag(FloatTag.class, list); return new ListTag(FloatTag.class, list);