Wrap external NBT loading with try-catch to avoid corrupting block if external NBT data is corrupt. Closes #926.

This commit is contained in:
Florian Nücke 2015-02-20 21:11:28 +01:00
parent 21dd3aade9
commit b6dbef7095

View File

@ -83,11 +83,16 @@ object SaveHandler {
def loadNBT(nbt: NBTTagCompound, name: String): NBTTagCompound = {
val data = load(nbt, name)
if (data.length > 0) {
if (data.length > 0) try {
val bais = new ByteArrayInputStream(data)
val dis = new DataInputStream(bais)
CompressedStreamTools.read(dis)
}
catch {
case t: Throwable =>
OpenComputers.log.warn("There was an error trying to restore a block's state from external data. This indicates that data was somehow corrupted.", t)
new NBTTagCompound()
}
else new NBTTagCompound()
}