Empty folders causes crash in Craft.Net.Anvil
kaltinril opened this issue · 0 comments
Exception thrown in Region.cs:
- ArgumentException was unhandled.
- The requested chunk is not loaded. Parameter name: position
This is caused by the attempted load of a world, where there are empty folders in it.
The existing code for Craft.Net.Anvil\Level.cs needs to be updated.
Line 323:
d => !Directory.GetFiles(d).Any(f => !f.EndsWith(".mca") && !f.EndsWith(".mcr")));
The existing code above uses ! (NOT) which:
1.) Causes empty folders to get picked up and an exception thrown.
2.) Makes it more confusing to read.
Replace by removing the ! and adjusting the && into a ||
d => Directory.GetFiles(d).Any(f => f.EndsWith(".mca") || f.EndsWith(".mcr")));
Functionality should be the same, however, empty folders will not be picked up.
To Reproduced error:
Create empty folders (DIM1 and DIM-1) in the Test World folder (Just like the Craft.Net.Anvil.Test has in it already).
var level = Level.LoadFrom("C:\folderpath\Test World")
Then make a call to the following to see the error:
level.DefaultWorld.GetBlockID(....)