Modding:Modding Efficiently: Difference between revisions
From Vintage Story Wiki
Line 31: | Line 31: | ||
b) For regular full chunk scans, I recommend a separate background thread that loads the chunk and access the raw block data via <code>chunk.Blocks</code>. It's an array indexed with <code>(y * chunksize + z) * chunksize + x</code>, where the xyz are local coordinate from 0 to chunkize-1<br> | b) For regular full chunk scans, I recommend a separate background thread that loads the chunk and access the raw block data via <code>chunk.Blocks</code>. It's an array indexed with <code>(y * chunksize + z) * chunksize + x</code>, where the xyz are local coordinate from 0 to chunkize-1<br> | ||
c) For rare area scans, there is `api.World.GetBlockAccessorPrefetch()`. This blockaccessor lets you pre-load an area and then rather efficiently iterate through each block in given area | c) For rare area scans, there is `api.World.GetBlockAccessorPrefetch()`. This blockaccessor lets you pre-load an area and then rather efficiently iterate through each block in given area | ||
</li> | |||
</ul> |