Added some error handling for legacy conversions of schematics.

Dieser Commit ist enthalten in:
Matthew Miller 2018-07-31 12:11:10 +10:00
Ursprung 57eaa5f8f2
Commit fdb7ada295

Datei anzeigen

@ -43,6 +43,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.storage.NBTConversions;
@ -199,11 +200,13 @@ public class SchematicReader implements ClipboardReader {
int index = y * width * length + z * width + x;
BlockState block = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
if (block != null) {
for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) {
if (handler.isAffectedBlock(block)) {
handler.updateNBT(block, values);
}
}
}
BlockVector vec = new BlockVector(x, y, z);
tileEntitiesMap.put(vec, values);
@ -223,11 +226,15 @@ public class SchematicReader implements ClipboardReader {
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
try {
if (state != null) {
if (tileEntitiesMap.containsKey(pt)) {
clipboard.setBlock(region.getMinimumPoint().add(pt), new BaseBlock(state, new CompoundTag(tileEntitiesMap.get(pt))));
} else {
clipboard.setBlock(region.getMinimumPoint().add(pt), state);
}
} else {
log.warning("Unknown block when pasting schematic: " + blocks[index] + ":" + blockData[index] + ". Please report this issue.");
}
} catch (WorldEditException e) {
switch (failedBlockSets) {
case 0:
@ -259,8 +266,13 @@ public class SchematicReader implements ClipboardReader {
Location location = NBTConversions.toLocation(clipboard, compound.getListTag("Pos"), compound.getListTag("Rotation"));
if (!id.isEmpty()) {
BaseEntity state = new BaseEntity(EntityTypes.get(id), compound);
EntityType entityType = EntityTypes.get(id.toLowerCase());
if (entityType != null) {
BaseEntity state = new BaseEntity(entityType, compound);
clipboard.createEntity(location, state);
} else {
log.warning("Unknown entity when pasting schematic: " + id.toLowerCase());
}
}
}
}