MCPcopy Create free account
hub / github.com/cabaletta/baritone / guessPosition

Method guessPosition

src/main/java/baritone/cache/CachedWorld.java:208–232  ·  view source on GitHub ↗

If we are still in this world and dimension, return player feet, otherwise return most recently modified chunk

()

Source from the content-addressed store, hash-verified

206 * If we are still in this world and dimension, return player feet, otherwise return most recently modified chunk
207 */
208 private BlockPos guessPosition() {
209 for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
210 IWorldData data = ibaritone.getWorldProvider().getCurrentWorld();
211 if (data != null && data.getCachedWorld() == this && ibaritone.getPlayerContext().player() != null) {
212 return ibaritone.getPlayerContext().playerFeet();
213 }
214 }
215 CachedChunk mostRecentlyModified = null;
216 for (CachedRegion region : allRegions()) {
217 if (region == null) {
218 continue;
219 }
220 CachedChunk ch = region.mostRecentlyModified();
221 if (ch == null) {
222 continue;
223 }
224 if (mostRecentlyModified == null || mostRecentlyModified.cacheTimestamp < ch.cacheTimestamp) {
225 mostRecentlyModified = ch;
226 }
227 }
228 if (mostRecentlyModified == null) {
229 return new BlockPos(0, 0, 0);
230 }
231 return new BlockPos((mostRecentlyModified.x << 4) + 8, 0, (mostRecentlyModified.z << 4) + 8);
232 }
233
234 private synchronized List<CachedRegion> allRegions() {
235 return new ArrayList<>(this.cachedRegions.values());

Callers 1

pruneMethod · 0.95

Calls 10

getProviderMethod · 0.95
getCachedWorldMethod · 0.95
allRegionsMethod · 0.95
playerFeetMethod · 0.80
mostRecentlyModifiedMethod · 0.80
getAllBaritonesMethod · 0.65
getCurrentWorldMethod · 0.65
getWorldProviderMethod · 0.65
playerMethod · 0.65
getPlayerContextMethod · 0.65

Tested by

no test coverage detected