mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Don't error out when global block defs file is empty or has too few elements (Thanks Odd0002)
This commit is contained in:
parent
357195a8d7
commit
d55d4c954a
@ -73,7 +73,7 @@ namespace MCGalaxy {
|
||||
|
||||
|
||||
internal static BlockDefinition[] Load(bool global, Level lvl) {
|
||||
BlockDefinition[] defs = new BlockDefinition[Block.Count];
|
||||
BlockDefinition[] defs = null;
|
||||
string path = global ? GlobalPath : "blockdefs/lvl_" + lvl.MapName + ".json";
|
||||
try {
|
||||
if (File.Exists(path)) {
|
||||
@ -82,7 +82,13 @@ namespace MCGalaxy {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.LogError(ex);
|
||||
defs = new BlockDefinition[Block.Count];
|
||||
}
|
||||
if (defs == null) defs = new BlockDefinition[Block.Count];
|
||||
|
||||
// File was probably manually modified - fix it up
|
||||
if (defs.Length < Block.Count) {
|
||||
Logger.Log(LogType.Warning, "Expected " + Block.Count + " blocks in " + path + ", but only had " + defs.Length);
|
||||
Array.Resize(ref defs, Block.Count);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Block.Count; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user