mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 19:25:20 -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 = {
|
def loadNBT(nbt: NBTTagCompound, name: String): NBTTagCompound = {
|
||||||
val data = load(nbt, name)
|
val data = load(nbt, name)
|
||||||
if (data.length > 0) {
|
if (data.length > 0) try {
|
||||||
val bais = new ByteArrayInputStream(data)
|
val bais = new ByteArrayInputStream(data)
|
||||||
val dis = new DataInputStream(bais)
|
val dis = new DataInputStream(bais)
|
||||||
CompressedStreamTools.read(dis)
|
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()
|
else new NBTTagCompound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user