Use getTag instead of requireTag in a few places.

This commit is contained in:
wizjany 2019-03-29 23:44:18 -04:00
parent d7d2d03ee8
commit 42d0d6e79a
2 changed files with 8 additions and 13 deletions

View File

@ -253,9 +253,8 @@ public class MCEditSchematicReader extends NBTSchematicReader {
// Entities // Entities
// ==================================================================== // ====================================================================
try { List<Tag> entityTags = getTag(schematic, "Entities", ListTag.class).getValue();
List<Tag> entityTags = requireTag(schematic, "Entities", ListTag.class).getValue(); if (entityTags != null) {
for (Tag tag : entityTags) { for (Tag tag : entityTags) {
if (tag instanceof CompoundTag) { if (tag instanceof CompoundTag) {
CompoundTag compound = (CompoundTag) tag; CompoundTag compound = (CompoundTag) tag;
@ -273,7 +272,6 @@ public class MCEditSchematicReader extends NBTSchematicReader {
} }
} }
} }
} catch (IOException ignored) { // No entities? No problem
} }
return clipboard; return clipboard;

View File

@ -87,12 +87,10 @@ public class SpongeSchematicReader extends NBTSchematicReader {
// Check // Check
Map<String, Tag> schematic = schematicTag.getValue(); Map<String, Tag> schematic = schematicTag.getValue();
int version = requireTag(schematic, "Version", IntTag.class).getValue(); int version = requireTag(schematic, "Version", IntTag.class).getValue();
switch (version) { if (version == 1) {
case 1:
return readVersion1(schematicTag); return readVersion1(schematicTag);
default:
throw new IOException("This schematic version is currently not supported");
} }
throw new IOException("This schematic version is currently not supported");
} }
private Clipboard readVersion1(CompoundTag schematicTag) throws IOException { private Clipboard readVersion1(CompoundTag schematicTag) throws IOException {
@ -152,8 +150,9 @@ 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<>();
try { ListTag tileEntities = getTag(schematic, "TileEntities", ListTag.class);
List<Map<String, Tag>> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream() if (tileEntities != null) {
List<Map<String, Tag>> tileEntityTags = tileEntities.getValue().stream()
.map(tag -> (CompoundTag) tag) .map(tag -> (CompoundTag) tag)
.map(CompoundTag::getValue) .map(CompoundTag::getValue)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -162,8 +161,6 @@ public class SpongeSchematicReader extends NBTSchematicReader {
int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue(); int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
tileEntitiesMap.put(BlockVector3.at(pos[0], pos[1], pos[2]), tileEntity); tileEntitiesMap.put(BlockVector3.at(pos[0], pos[1], pos[2]), tileEntity);
} }
} catch (Exception e) {
throw new IOException("Failed to load Tile Entities: " + e.getMessage());
} }
BlockArrayClipboard clipboard = new BlockArrayClipboard(region); BlockArrayClipboard clipboard = new BlockArrayClipboard(region);