Confirmedusers, Bureaucrats, editor, Administrators
1,778
edits
No edit summary |
|||
Line 29: | Line 29: | ||
<li><strong>Block Search</strong><br> | <li><strong>Block Search</strong><br> | ||
a) If you want an entity to find a certain, not extremely common block, use the [https://github.com/anegostudios/vsessentialsmod/blob/master/Systems/POIRegistry.cs POI Registry]. This registry lets block entities register a point of interest that entities can search through very efficiently. They are also partitioned into chunk column buckets to additionally reduce the search space.<br> | a) If you want an entity to find a certain, not extremely common block, use the [https://github.com/anegostudios/vsessentialsmod/blob/master/Systems/POIRegistry.cs POI Registry]. This registry lets block entities register a point of interest that entities can search through very efficiently. They are also partitioned into chunk column buckets to additionally reduce the search space.<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 | 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 |