Class NetherPathfinder
java.lang.Object
com.zenith.feature.pathfinder.process.elytra.pathfinder.NetherPathfinder
- All Implemented Interfaces:
AutoCloseable
A pathfinder and raytracer over a cache of one-bit-per-block chunks, for flying the nether by
elytra. One instance is what the native library called a context: a world's dimension,
the loaded chunks it has been given, and a search that can be cancelled.
The method names are the ones the native API had, with objects where it had pointers: a chunk
is a Chunk that stays valid for as long as it is referenced, and there is nothing to free.
Lookups, inserts, the search and rays may all run at the same time from different threads.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat a ray or a search makes of a chunk the table does not hold.static enum -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocateAndInsertChunk(int x, int z) Inserts a new, empty chunk from the game at (x, z), replacing any chunk there, and returns it to be filled.booleancancel()Asks a running search to stop.intHow many chunks the table holds.voidclose()voidcullFarChunks(int chunkX, int chunkZ, int maxDistanceBlocks) Forgets every chunk more than maxDistanceBlocks (in whole chunks) from (chunkX, chunkZ).getChunk(int x, int z) The chunk at (x, z), or null.getChunkOrDefault(int x, int z, boolean solid) The chunk at (x, z), or the shared all-solid or all-air chunk if there is none.intbooleanhasChunkFromCaller(int x, int z) pathFind(int x1, int y1, int z1, int x2, int y2, int z2, boolean atLeastX4, boolean refine, int failTimeoutInMillis, boolean defaultAir, double fakeChunkCost) A path from (x1, y1, z1) towards (x2, y2, z2), or null if none was found in time or the search was cancelled.voidremoveChunk(int cx, int cz)
-
Constructor Details
-
NetherPathfinder
- Parameters:
dimension- the dimension the chunks are from, which decides their heightmaxHeight- the height the search and rays stay under, 1 to 384
-
-
Method Details
-
getDimension
-
getMaxHeight
public int getMaxHeight() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
allocateAndInsertChunk
Inserts a new, empty chunk from the game at (x, z), replacing any chunk there, and returns it to be filled. -
getChunkOrDefault
The chunk at (x, z), or the shared all-solid or all-air chunk if there is none. Do not write to the shared ones. -
getChunk
The chunk at (x, z), or null. -
hasChunkFromCaller
public boolean hasChunkFromCaller(int x, int z) -
cullFarChunks
public void cullFarChunks(int chunkX, int chunkZ, int maxDistanceBlocks) Forgets every chunk more than maxDistanceBlocks (in whole chunks) from (chunkX, chunkZ). -
chunkCount
public int chunkCount()How many chunks the table holds. -
pathFind
public PathSegment pathFind(int x1, int y1, int z1, int x2, int y2, int z2, boolean atLeastX4, boolean refine, int failTimeoutInMillis, boolean defaultAir, double fakeChunkCost) A path from (x1, y1, z1) towards (x2, y2, z2), or null if none was found in time or the search was cancelled. The segment is finished if it reached the goal.- Parameters:
atLeastX4- do not squeeze through cubes smaller than 4 blocksrefine- drop points that are visible from an earlier onefailTimeoutInMillis- give up after this long with nothing; 0 for 30 secondsdefaultAir- treat unknown chunks as air for provisional route planningfakeChunkCost- the cost of a step through a chunk that was not given by the game, against 1 for one that was
-
cancel
public boolean cancel()Asks a running search to stop. Returns whether it had already been asked. -
removeChunk
public void removeChunk(int cx, int cz)
-