mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
Wrap external NBT loading with try-catch to avoid corrupting block if external NBT data is corrupt. Closes #926.
This commit is contained in:
parent
21dd3aade9
commit
b6dbef7095
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user