/** Send message to all within 64 blocks that have this chunk loaded */ public static void sendToNearby(World world, BlockPos pos, IMessage toSend) { if (world instanceof WorldServer) { WorldServer ws = (WorldServer) world; for (EntityPlayer player : ws.playerEntities) { EntityPlayerMP playerMP = (EntityPlayerMP) player; if (playerMP.getDistanceSq(pos) < 64 * 64 && ws.getPlayerChunkMap() .isPlayerWatchingChunk(playerMP, pos.getX() >> 4, pos.getZ() >> 4)) { HANDLER.sendTo(toSend, playerMP); } } } }