use of com.qouteall.immersive_portals.ducks.IEThreadedAnvilChunkStorage in project ImmersivePortalsMod by qouteall.
the class MixinEntityTracker method updateCameraPosition_.
@Override
public void updateCameraPosition_(ServerPlayerEntity player) {
IEThreadedAnvilChunkStorage storage = McHelper.getIEStorage(entity.dimension);
if (player != this.entity) {
Vec3d relativePos = (new Vec3d(player.x, player.y, player.z)).subtract(this.entry.method_18759());
int maxWatchDistance = Math.min(this.maxDistance, (storage.getWatchDistance() - 1) * 16);
boolean isWatchedNow = player.dimension == entity.dimension && relativePos.x >= (double) (-maxWatchDistance) && relativePos.x <= (double) maxWatchDistance && relativePos.z >= (double) (-maxWatchDistance) && relativePos.z <= (double) maxWatchDistance && this.entity.canBeSpectated(player);
isWatchedNow = isWatchedNow || SGlobal.chunkTrackingGraph.isPlayerWatchingChunk(player, new DimensionalChunkPos(entity.dimension, new ChunkPos(entity.getBlockPos())));
if (isWatchedNow) {
boolean shouldTrack = this.entity.teleporting;
if (!shouldTrack) {
ChunkPos chunkPos_1 = new ChunkPos(this.entity.chunkX, this.entity.chunkZ);
ChunkHolder chunkHolder_1 = storage.getChunkHolder_(chunkPos_1.toLong());
if (chunkHolder_1 != null && chunkHolder_1.getWorldChunk() != null) {
shouldTrack = true;
}
// else {
// retry it next tick
// ModMain.serverTaskList.addTask(() -> {
// Helper.log("Retry tracking player " + player.getName());
// updateCameraPosition_(player);
// return true;
// });
// }
}
if (shouldTrack && this.playersTracking.add(player)) {
this.entry.startTracking(player);
}
} else if (this.playersTracking.remove(player)) {
this.entry.stopTracking(player);
}
}
}
Aggregations